Variables
I LOVE DOING THIS :)
Assignment Operator =
=
Do not start with a number, You cannot start a variable name with a number. The rest of the variable name can contain a number
More on Assignments
Another example where you can assign dicts, shown by {...}
, to a variable birthdays
Working with Variables
Variables will support any method the underlying type supports. For example, if an integer value is stored in a variable, then the variable will support integer functions such as addition
You can make a change in a variable and assign it to the same variable. This is done generally when some kind of data type change is done.
For example, you can take a number as input. This will take in the digit as a string. You can then take the string number and convert it to int and assign it to the same number
We will use a function range(3)
which returns three values.
Something that returns three values can be unpacked to three variables. This is like saying take whatever is in range(3)
and instead of assigning it to a single variable, break it up and assign individual values to the three variables. This is done using a comma between the variables.
Last updated