January 2019
Beginner
318 pages
8h 23m
English
Like other programming languages, there's no need to declare your variables first. In Python, just think of any name to give your variable and assign it a value. You can use that variable in your program. So, in Python, you can declare variables whenever you need them.
In Python, the value of a variable may change during the program execution, as well as the type. In the following line of code, we assign the value 100 to a variable:
n = 100Here are assigning 100 to the variable n. Now, we are going to increase the value of n by 1:>>> n = n + 1>>> print(n)101>>>
The following is an example of a type of variable that can change during execution:
a = 50 # data type is implicitly set to integera = 50 + 9.50 # data type is changed to ...
Read now
Unlock full access