LESSON 02 – CONDITIONAL STATEMENTS

 


PRACTICE QUIZ

Complete the following work to prepare you for the quiz.  You will find solutions at the bottom.

 

 

PART 1 - State what the following programs will output to screen.

 

1

x=2

if x>2:

    print("A")

print("B")

 

2

a=5

if a<10:

    print("C")

print("D")

 

3

coco=55

if coco<20:

    print("Z")

else:

    print("Y")

 

4

dodo = 82

if dodo >= 80:

    print("M")

else:

    print("K")

print("L")

 

5

z = 1

if z == 1:

    print("HA")

elif z < 3:

    print("HO")

else:

    print("HI")

 

6

t=5

if t != 5:

    print("GO")

else:

    print("NO")

 

7

b=7

print("SO")

if b > 0:

    print("LO")

 

8

apple=-25

if apple > 0 and apple < 100:

    print("A")

else:

    print("B")

 

9

campeau=10

thor=5*2

if campeau == thor:

    print("OH YEAH")

else:

    print("WHATEVER")

 

10

i=3

if i != i * 2:

    print(i)

else:

    print("J")

 

11

k=2

if (k < 5):

    print("Z")

if (k < 10):

    print("Y")

if (k > 0):

    print("X")

 

12

k=2

if k < 5:

    print("N")

elif k < 10:

    print("O")

elif k > 0:

    print("T")

 

 

 

PART 2 – Verify your answers here.  If you are unsure about an answer, perhaps you should type the program into PyCharm and test it out.

 

PART 3 – Can you figure out why Mr. Campeau’s favourite practice questions were 5, 7 & 12?