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.
| Type | Holds | Example |
|---|---|---|
| int | whole numbers | age = 17 |
| float | decimals | price = 49.5 |
| str | text | name = "Asha" |
| bool | True or False | passed = 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?