🚀 Alguni Start learning

Unit 2: Making Choices

Teach your code to decide.

Unit 2 of 31 in Python for kids. Its 5 lessons are True or False, If / Else, And, Or, Not, Bug Squashing and Bouncer Bot — below is everything each one explains, and a question or two from it to try.

Every sample on this page was run through real Python before it shipped, and prints exactly what it says it prints.

This unit is free for ever, because the first two units of every track are. Try it in the app.

⚖️ True or False

Questions with only two answers

Some questions can only be True or False. Python compares things with > (bigger), < (smaller) and == (the same).

Python

print(5 > 3)
print(2 == 4)

It prints

True
False

Try it yourself

What does print(10 > 20) show?

  • True
  • False
  • 10
  • Error

Which one asks "are these the same?"

  • =
  • ==
  • >
  • !

Answer them in the app

🔀 If / Else

Do this, otherwise do that

if runs code only when something is True. else covers every other case. The indented lines underneath belong to that branch — the spaces matter in Python!

Python

age = 7
if age > 10:
    print("Big kid")
else:
    print("Little kid")

It prints

Little kid

Try it yourself

What does this print?

Python

coins = 12
if coins > 10:
    print("Rich!")
else:
    print("Keep saving")
  • Rich!
  • Keep saving
  • both lines
  • nothing

What is missing at the end of the if line?

Python

if rain == True
    print("Take a coat")
  • a colon :
  • a semicolon ;
  • a full stop .
  • nothing

Answer them in the app

🔗 And, Or, Not

Asking two things at once

and is True only when both sides are True. or is True when at least one side is.

Python

print(True and False)
print(True or False)

It prints

False
True

Flipping an answer over

not turns True into False and False into True.

Python

print(not True)
print(not 5 > 10)

It prints

False
True

Try it yourself

What does this print?

Python

age = 12
print(age > 10 and age < 15)

What does this print?

Python

rain = True
coat = False
print(rain and coat)

Answer them in the app

🐛 Bug Squashing

Everybody writes bugs

A bug is a mistake in code. Real programmers write them all day long — the skill is reading the error and fixing it. Python usually tells you which line went wrong.

Try it yourself

Python says: IndentationError. What does that mean?

  • A word is spelled wrong
  • The spaces at the start of a line are wrong
  • You used too many numbers
  • The file is too long

Answer it in the app

🏆 Bouncer Bot

Try it yourself

What does this print?

Python

n = 15
if n > 10:
    print("big")
else:
    print("small")

What does elif mean?

Python

if x > 10:
    print("big")
elif x > 5:
    print("medium")
else:
    print("small")
  • Stop the program
  • Else-if: try another question when the one above was False
  • Repeat the code
  • End of the file

Answer them in the app