Addition
Addition in Python is easy - just use "+" sign. You can add numbers or variables (or mix of numbers and variables).
9
1
2
3
4
a = 1
b = 2
c = a + b
print(c)
1234a = 1 b = 2 c = a + b print(c)
Sometimes people use alternative operator: "+=" (it is typically used for brevity). Please see example below (this basically means "increase variable on the left hand side by 1"):
9
1
2
3
x = 100
x+=1
print(x)
123x = 100 x+=1 print(x)
Taak
Swipe to start coding
Add line to print the sum of 20 and 22.
Oplossing
9
1
2
3
4
5
# Add line below to print the sum of 20 and 22
print(20 + 22)
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 2. Hoofdstuk 1
9
1
2
3
4
5
6
# Add line below to print the sum of 20 and 22
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.