Skip to content
skillbld
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

Diagram
main.py · editable
Output
Press Run to execute this code.

The four everyday types

Mind map · click a dot to fold, drag to pan
TypeExampleUsed for
int42Whole numbers, counting
float3.14Decimals, measurements
str"hello"Text
boolTrueYes/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. 1

    What does the = sign do in Python?

  2. 2

    What is the type of 3.0?

  3. 3

    Which variable name is valid?

Finished today's lesson?