Python Variable Exercises

Let’s check out some exercises that will help you understand Variables in Python better.

Exercise 2-a

Below is a good example of mixing numbers and text inside the print() function


Assign: 3 to variable glass_of_water.

You can simply assign a number to the variable glass_of_water by typing it on the left side of the equal sign and the number on the right side of it.

Number on the right side doesn’t have to be in quotes.

glass_of_water = 3

Exercise 2-b

Let's try to see what happens after assigning a new value to our variable. Note that program gets executed line by line.


Place the variable: glass_of_water inside the print function and observe what happens.

Alternatively, you can use “+=” operator. It’s often a more efficient way of incrementing variables.

You can read more about Python Operators here.

print (glass_of_water)

Need More Exercises?

Check out Holy Python AI+ for amazing Python learning tools.

*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython