Lesson 3
Decisions, Decisions!
csinschools.com
Previously, on CS in Schools...
your_age = input("Enter your age:")
years_needed = 18 - your_age
2
Previously, on CS in Schools...
a) lives = + 10
b) lives = lives + 10
c) lives + 10
d) increase lives by 10
3
Previously, on CS in Schools...
age = input("Please enter your age:")
if age == "15":
print("We are not twins!")
if age == "14":
print("We could be twins!")
4
Learning objectives
By the end of this lesson, you should be able to:
5
Python Reference Sheet
6
Python Reference Sheet
Activity: Academy Awards
7
if statements for multiple options
8
Click here for more info on if statements
if statements for multiple options
9
Click here for more info on if statements
Trivia Responses
10
| If the user answered... | The program displays... | 
| a | Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'. | 
| b | The answer is Ben-Hur. La La Land did, however, win 6 Academy Awards in 2016. | 
| c | The answer is Ben-Hur. Titanic did win 11 Academy Awards, but it occurred later, in 1998. | 
| d | The answer is Ben-Hur. Sound of Music won 5 Academy Awards in 1966. | 
| [anything else] | Sorry, that was not an option. | 
Recap of Flowcharts
11
Click here for more info on flowcharts
Summary of flowchart symbols
The start and end points of the program.
The program needs to input information (eg. from the user typing something in) or output something (eg. display text on the screen)
The program performs an operation or calculation.
The program is making a True/False decision.
12
True
False
Start
Ask user for name
End
Is the name "John"?
Display "Hey! I'm called John, too!"
Display "See ya later!"
Wait 5 seconds
Constructing The Trivia Program's Flowchart
13
Trivia Program Flowchart
14
Start
Trivia Program Flowchart
15
Ask "Please enter your choice:"
Start
Trivia Program Flowchart
16
Ask "Please enter your choice:"
Is the answer "a"?
Start
Trivia Program Flowchart
17
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
Start
Trivia Program Flowchart
18
Is the answer "b"?
False
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
Start
Trivia Program Flowchart
19
Is the answer "b"?
True
False
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
The answer is Ben-Hur. La La Land did, however, win 6 Academy Awards in 2016.
Start
Trivia Program Flowchart
20
Is the answer "b"?
Is the answer "c"?
True
False
False
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
The answer is Ben-Hur. La La Land did, however, win 6 Academy Awards in 2016.
Start
Trivia Program Flowchart
21
Is the answer "b"?
Is the answer "c"?
True
True
False
False
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
The answer is Ben-Hur. La La Land did, however, win 6 Academy Awards in 2016.
The answer is Ben-Hur. Titanic did win 11 Academy Awards, but it occurred later, in 1998.
Start
Trivia Program Flowchart
22
Is the answer "b"?
Is the answer "c"?
True
True
False
False
Is the answer "d"?
False
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
The answer is Ben-Hur. La La Land did, however, win 6 Academy Awards in 2016.
The answer is Ben-Hur. Titanic did win 11 Academy Awards, but it occurred later, in 1998.
Start
Trivia Program Flowchart
23
Is the answer "b"?
Is the answer "c"?
True
True
False
False
Is the answer "d"?
False
True
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
The answer is Ben-Hur. La La Land did, however, win 6 Academy Awards in 2016.
The answer is Ben-Hur. Titanic did win 11 Academy Awards, but it occurred later, in 1998.
The answer is Ben-Hur. Sound of Music won 5 Academy Awards in 1966.
Start
Trivia Program Flowchart
24
Is the answer "b"?
Is the answer "c"?
True
True
False
False
False
Is the answer "d"?
False
True
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land did, however, win 6 Academy Awards in 2016.
The answer is Ben-Hur. Titanic did win 11 Academy Awards, but it occurred later, in 1998.
The answer is Ben-Hur. Sound of Music won 5 Academy Awards in 1966.
Start
Trivia Program Flowchart
25
Is the answer "b"?
Is the answer "c"?
True
True
False
False
False
Is the answer "d"?
False
True
Ask "Please enter your choice:"
Is the answer "a"?
True
Display "Correct! It is one of the reasons for the saying 'bigger than Ben-Hur'."
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land did, however, win 6 Academy Awards in 2016.
The answer is Ben-Hur. Titanic did win 11 Academy Awards, but it occurred later, in 1998.
The answer is Ben-Hur. Sound of Music won 5 Academy Awards in 1966.
Start
End
if, elif, and else
if, elif, and else
27
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if, elif, and else
28
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if, elif, and else
29
if answer == "a":
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if, elif, and else
30
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
if, elif, and else
31
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
if, elif, and else
32
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
if, elif, and else
33
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
if, elif, and else
34
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
if, elif, and else
35
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
elif is an abbreviation for�"else if"
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if, elif, and else
36
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
It is used when we want to continue with checking for other options when the first option is False.
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if, elif, and else
37
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
It is used when we want to continue with checking for other options when the first option is False.
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if, elif, and else
38
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
False!
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
It is used when we want to continue with checking for other options when the first option is False.
if, elif, and else
39
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
False!
So, let's check this one...
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
It is used when we want to continue with checking for other options when the first option is False.
if, elif, and else
40
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
if, elif, and else
41
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
if, elif, and else
42
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
if, elif, and else
43
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
if, elif, and else
44
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
if, elif, and else
45
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
if, elif, and else
46
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
if, elif, and else
47
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
if, elif, and else
48
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
if, elif, and else
49
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
if, elif, and else
50
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
if, elif, and else
51
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
if, elif, and else
52
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
if, elif, and else
53
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
54
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
else always comes last
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
55
It means: only if everything else above it is False, then do the statement below.
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
56
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
It means: only if everything else above it is False, then do the statement below.
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
57
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
False!
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
False!
False!
False!
It means: only if everything else above it is False, then do the statement below.
58
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
59
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
Remember, else and elif are all optional!
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
60
if answer == "a":
print("Correct! It is one…")
elif answer == "b":
print("… La La Land …")
elif answer == "c":
print("… Titanic did …")
elif answer == "d":
print("… Sound of Music …")
else:
print("Sorry that was…")
Is the answer "b"?
Is the answer "c"?
True
True
False
Is the answer "d"?
True
Is the answer "a"?
True
Display "Correct! It is one ...
Display "Sorry, that was not an option."
The answer is Ben-Hur. La La Land ...
The answer is Ben-Hur. Titanic ...
The answer is Ben-Hur. Sound of Music ...
Activity: Win a Car!
61
Activity 03.01�Win a Car
Helpful hint:
Activity: Your Solar System!
62
Activity 03.02�Your Solar System
Helpful hint:
Activity: In the Burrows!
63
Activity 03.03�In the Burrows
Tutorial Video:
Glossary
64
Summary
65
Reflection: Exit pass
66
License Information
These CS in Schools lessons plans, worksheets, and other materials were created by Toan Huynh and Hugh Williams. They are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Images, in order of appearance:
67