Day 2 of 14 30 minVariablesint / float / str / booltype()
Give values a name, and meet the four types you will use every day.
By the end of today you can
- Create and reassign variables
- Recognise int, float, str and bool
- Check a value's type with type()
A variable is a name that points to a value. Think of it as a label you stick on a box.
Names point to values
main.py · editable
Output
Press Run to execute this code.
The four everyday types
| Type | Example | Used for |
|---|---|---|
int | 42 | Whole numbers, counting |
float | 3.14 | Decimals, measurements |
str | "hello" | Text |
bool | True | Yes/no decisions |
Use type() to ask Python what something is:
main.py · editable
Output
Press Run to execute this code.
Knowledge check
Test what you learned
3 questions · pick an answer to see if you're right
0/3
- 1
What does the = sign do in Python?
- 2
What is the type of 3.0?
- 3
Which variable name is valid?
Finished today's lesson?