Variables in Python, are the reserved memory locations to store the values in a Python program. It means that, whenever you are creating a variable in Python programming, you are reserving some space in the memory for that variable.
Based on variable's data type, python interpreter allocates the memory and decides what can be stored in the reserved memory. Here is an example assigning values to the variables in Python:
# Python Variables - Example Program num1=10 num2=20 sum=num1+num2 print(sum)
Here is the sample output of the above Python program:
Here is one more example program, uses three variables in python namely m, n, and r
# Python Variables - Example Program m=54 n=45 r=0 r=m+n print("sum = ", r) r=m-n print("Subtract = ", r) r=m*n print("Multiply = ", r) r=m/n print("Divide = ", r)
Here is the output produced by the above Python program:
Here are the list of some more examples, uses variables in python: