Course contents0/6 done

Variables and data types

Names that hold values — numbers, text and True/False.

Lesson 2 of 6 8 min

You will learn

  • Create and update variables
  • Know int, float, str and bool
  • Use type() and f-strings

A variable is a labelled box

Writing marks = 92 stores 92 in a box labelled marks. Later code can read it or put a new value in the same box.

TypeHoldsExample
intwhole numbersage = 17
floatdecimalsprice = 49.5
strtextname = "Asha"
boolTrue or Falsepassed = True
Python · try it

Output appears here · Ctrl + Enter to run

Checkpoint

1. What is the type of 3.0?

2. After x = 5 and then x = x * 2, what is x?