BEGINNER PYTHON · CHAPTER 02

Python variables for beginners

Build your first Python programs with values, variables, expressions, and type conversions.

Practice Python variables →Download the chapter notebook

Understanding variables, expressions, and statements

A variable gives a value a name so you can use it again. Python distinguishes whole numbers, decimal numbers, and text. Practice choosing clear names, calculating with operators, and converting input before using it in arithmetic.

minutes = 90
hours = minutes / 60
print(hours)  # 1.5

Division with / produces a decimal result. Changing minutes changes the result without changing the calculation.

What you will practice

Work through eight coding missions, then test your understanding with ten multiple-choice questions. Each mission provides starter code, a hint, and feedback after you run it.

  1. Values and their types — Values and types
  2. Assignment and updates — Variables; Statements
  3. Arithmetic toolbox — Operators and operands; Modulus operator
  4. Precedence workshop — Order of operations; Exercise 4
  5. Joining and repeating text — String operations
  6. A personal welcome — Asking the user for input; Exercise 2
  7. Gross pay calculator — Choosing mnemonic variable names; Exercise 3
  8. Temperature converter — Exercises: Exercise 5

Your chapter progress is saved in this browser. Complete all 18 checks to unlock a certificate at your earned practice score, and download your notebook or grade report to keep a copy.

Read, practice, and try again

For the chapter reading, see Python for Everybody: Variables, expressions, and statements by Charles R. Severance (CC BY 4.0). ZHUDDLE adds its own practice activities and scoring. The browser runs Python after its first interpreter download; no local installation is required.

Start the variables exercises →