Getting started · Lesson 2 of 25
Variables and types
Store values and check their type with type().
8 minutes3 games
Python needs no let and no type: write a name, = and a value. The basic types:
int: whole number,19.float: decimal,1.65.str: text,"Huda".bool:TrueorFalse(capitalised).None: “no value”.
name"Huda"str
age19int
height1.65float
is_studentTruebool
Python
name = "Huda" age = 19 height = 1.65 is_student = True phone = None print(name, age) print(type(age), type(height), type(name), type(is_student), type(phone)) x, y = 3, 7 # two at once x, y = y, x # swap print(x, y)
Step by step1 / 4
- ▶score = 10
- 2score = score + 5
- 3score += 1
- 4print(score)
Variables
| score | 10 |
Output
…
Complete the code
Complete: create city with the value Alex and print it.
city "Alex" (city)
What's the output?
a, b = 1, 2 a, b = b, a print(a, b)
What will this code print?
Exercise
Make a = 7 and b = 3, and print their product.
Expected output: 21
Python
Learn more from
Played 0 of 3 games
Sign in to save your progress and earn XP.