1 of 67

Lesson 3

Decisions, Decisions!

csinschools.com

2 of 67

Previously, on CS in Schools...

  • The following code produces an error. Can you figure out what's wrong and how to fix it?

your_age = input("Enter your age:")

years_needed = 18 - your_age

2

3 of 67

Previously, on CS in Schools...

  • Which of the following lines of code correctly increases lives by 10?

a) lives = + 10

b) lives = lives + 10

c) lives + 10

d) increase lives by 10

3

4 of 67

Previously, on CS in Schools...

  • If the user types in 14 when asked for their age, what will be displayed on the screen after the following code is run:

age = input("Please enter your age:")

if age == "15":

print("We are not twins!")

if age == "14":

print("We could be twins!")

4

5 of 67

Learning objectives

By the end of this lesson, you should be able to:

  • understand the syntax of if and elif statements that can handle three or more options
  • produce a program that uses if and elif statements
  • understand the syntax of else statements
  • construct a program that can handle all other cases or when input doesn't make sense by using else statements

5

6 of 67

Python Reference Sheet

6

Python Reference Sheet

  • Print it out and use it!
  • Get it online. (Microsoft)

7 of 67

Activity: Academy Awards

7

8 of 67

if statements for multiple options

  • In the previous course, we learned about if statements and how to control what happens when the expression was either True or False
  • Notice that the Academy Awards quiz can do something more complicated:
    • Did you notice how it could recognise more than two different types of responses (a, b, c, or d)?
    • Did you notice that if you type a response that it doesn't understand, it can display an error message? (Try typing e or another answer that isn't a, b, c, or d)
  • When is it useful to be able to accept more than two responses?
  • What could you build if you could accept more than two responses?

8

Click here for more info on if statements

9 of 67

if statements for multiple options

  • When is it useful to be able to accept more than two responses?
    • Video games - direction, picking up objects, choosing what to do next
    • Changing the radio in your car - more than two radio stations!
    • Choosing a show on Netflix�
  • What could you build if you could accept more than two responses?
    • Games
    • Streaming sites
    • Remote controls
    • Online stores

9

Click here for more info on if statements

10 of 67

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.

11 of 67

Recap of Flowcharts

  • A flowchart is a special type of diagram that is used by programmers to help them lay out their step-by-step design for their programs
  • Flowcharts help us better understand the way computers make "decisions" and how they act differently based on different choices
  • Flowcharts are written in English, and they often don't use the same keywords as a programming language

11

Click here for more info on flowcharts

12 of 67

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

13 of 67

Constructing The Trivia Program's Flowchart

13

14 of 67

Trivia Program Flowchart

14

Start

15 of 67

Trivia Program Flowchart

15

Ask "Please enter your choice:"

Start

16 of 67

Trivia Program Flowchart

16

Ask "Please enter your choice:"

Is the answer "a"?

Start

17 of 67

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

18 of 67

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

19 of 67

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

20 of 67

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

21 of 67

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

22 of 67

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

23 of 67

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

24 of 67

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

25 of 67

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

26 of 67

if, elif, and else

27 of 67

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 ...

28 of 67

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 ...

29 of 67

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 ...

30 of 67

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":

31 of 67

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…")

32 of 67

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…")

33 of 67

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":

34 of 67

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":

35 of 67

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 ...

36 of 67

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 ...

37 of 67

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 ...

38 of 67

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.

39 of 67

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.

40 of 67

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":

41 of 67

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":

42 of 67

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 …")

43 of 67

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 …")

44 of 67

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":

45 of 67

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":

46 of 67

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 …")

47 of 67

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 …")

48 of 67

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":

49 of 67

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":

50 of 67

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 …")

51 of 67

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 …")

52 of 67

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…")

53 of 67

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 of 67

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 of 67

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 of 67

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 of 67

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 of 67

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 of 67

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 of 67

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 ...

61 of 67

Activity: Win a Car!

61

Activity 03.01Win a Car

Helpful hint:

  • Need some help?�
  • Have a look at slide 60 for a similar program

62 of 67

Activity: Your Solar System!

62

Activity 03.02Your Solar System

Helpful hint:

  • Need some help?�
  • Check out the cheat sheet!

63 of 67

Activity: In the Burrows!

63

Activity 03.03In the Burrows

Tutorial Video:

  • Need some help?�
  • Watch the tutorial video.

64 of 67

Glossary

  • else: A statement that means only if everything above is False,� do the following
  • elif: If the statement above is false, check if this is True

64

65 of 67

Summary

  • if and elif statements allow us to handle three or more options
  • The else statement is useful to handle all other cases or when the input() doesn't make sense

65

66 of 67

Reflection: Exit pass

  • What is one new thing you learnt today?
  • Write it on a sticky note and stick it on the board before you leave the classroom

66

67 of 67

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