1/ 19 Variables are used to store information, so that they can be used later on in your code.
In Python a ‘string’ is text and a ‘integer’ or ‘float’ is a number
‘car_brand’ and ‘brand_type’ are variables in the example below
Variables can be stored inside other variables
2/19
No special signs are allowed to be used in the name of variables, except for ‘_’ like.
Numbers are allowed in the name of a variable, but not at the start
So ‘1car’ is not OK and ‘car1’ is OK.
3/19
Lists
Lists store multiple pieces of information in a specific order.
A list always starts and ends with a square bracket ‘[‘ ‘]’.
Python starts counting at 0.
So the position or index number of the first item in the list is 0.
to print the first item, use #Code1
We can add items to the list by using the ‘append’ function.
See #Code2
A ‘for loop’ or looping allows you to perform the same action for multiple items in a list or group of items
4/19
A Tuple contains multiple items like a list.
The big difference is that a Tuple is immutable.
Which basically means you can’t change the values in a tuple
Unlike a list which is mutable or changeable
5/19
A dictionary is similar to a list.
It contains a set of item, but each item is associated with a key.
See below
The part before the colon is the ‘key’ and the part after the colon is the ‘value’
Together they are called a ‘key-value pair’.
6/19
The if statement is used in python when the program has to consider conditions
And reply in a certain way depending on the condition
7/19
While loops
The while loop continues the loop as long as a condition is valid
This code will continue to print the variable number
Adding 1 to the value in every iteration
Until the value 5 is reached
8/19
Functions
A function is a block of code that is written for a specific job
The function can be called by using the name of the function
Here’s an example
9/19
Functions part two
A keyword argument is a name-value pair, which directly links the argument to the parameter inside a function allowing to ignore the order inside a function.
10/19
Classes
A class defines the type of information an object can store and what functions it can do
Here’s an example
11/19
A class can use attributes and methods from another class. This is called inheritance.
12/19
BASIC DJANGO - now let's get into django
Best practice is to install django in a virtual environment
A virtual environment is an isolated environment where you can develop safely without
13/19
Create a project
To start with django you need to create a project, app, database and server
14/19
Include the app in the settings.py file inside your project.
Django doesn’t know our app exists yet, this way we tell django that there is an app called ‘myfirstapp’
15/19 Django is structured as follows.
When a user types audi.com/about.
This is what happens: Urls.py -> views.py -> Model(if there is one) -> template
The urls.py contains the location of the page
the views.py contains the content of the page
The models.py contains the data of the page
The template contains the structure and styling of the page
Create the content of your page in the views.py file inside your app
16/19
Create an ‘urls.py’ file inside your app and configure the links inside the app
17/19
Create a ‘templates’ folder inside your app. Create a home.html file inside your text editor with the following html tag: <h1> Hello </h1>. Put the file ‘home.html’ inside your templates folder.
18/19
This time go to the urls.py file in your project, not your app and include a reference to the urls.py file of your app. Don’t forget to write ‘include’ after ‘path’ on the import line.
19/19
you have learned how to create a basic django structure with one webpage
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Web3 py enables you to interact with the Ethereum chain using python!
Let me show how to use it 👇
First setup your develop environment.
We need a virtual environment and install the web3 py in it.
A virtual environment is a safe isolated environment, where you can develop and install python libraries, without affecting your pc if something goes wrong.
Create a virtual environment by typing this in the terminal:
python3 -m venv ./myenv
To activate the virtual environment, type this in the folder where you see the virtual environment. I called mine 'myv':
source ./myenv/bin/activate
A thread 🧵 explaining the code and steps we need to take.
LET'S GO
Now go and code some Python
Minting an nft with the Python sdk developed by @thirdweb_ requires a couple of steps.
We need to create a project in the dashboard and create an NFT module inside our project. We also need to connect a wallet. So if you don't have one, sign up with MetaMask or CoinWallet.
For the first part we need to take some steps in the dashboard at thirdweb.com/dashboard
Right now these steps are not in the Python sdk yet, but the team @thirdweb_ is working hard to get it all in the SDK.
If you want early access to the thirdweb go to thirdweb.com