Conditionals: What Does This Print
What does this print? · Beginner · about 6 min
Read each short program and type exactly what it prints, with each printed line on its own line. If a program stops with an error, type the error's name, like TypeError.
Example
x = 4 if x > 3: print("yes") print("done")
prints
yes done
Program 1
x = 15 if x > 10: print("big") elif x > 5: print("medium") else: print("small")
Program 2
x = 15 if x > 10: print("big") if x > 5: print("medium")
Program 3
if []: print("yes") else: print("no")
Program 4
n = 0 if n: print("set") print("done")
Program 5
age = 16 label = "adult" if age >= 18 else "teen" print(label)
Program 6
x = 5 if x > 2 and x < 4 or x == 5: print("A") else: print("B")
Program 7
day = 6 match day: case 6 | 7: print("weekend") case _: print("weekday")
Program 8
x = "5" if x > 3: print("more")