Editor

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

    x = 15
    if x > 10:
        print("big")
    elif x > 5:
        print("medium")
    else:
        print("small")
  2. Program 2

    x = 15
    if x > 10:
        print("big")
    if x > 5:
        print("medium")
  3. Program 3

    if []:
        print("yes")
    else:
        print("no")
  4. Program 4

    n = 0
    if n:
        print("set")
    print("done")
  5. Program 5

    age = 16
    label = "adult" if age >= 18 else "teen"
    print(label)
  6. Program 6

    x = 5
    if x > 2 and x < 4 or x == 5:
        print("A")
    else:
        print("B")
  7. Program 7

    day = 6
    match day:
        case 6 | 7:
            print("weekend")
        case _:
            print("weekday")
  8. Program 8

    x = "5"
    if x > 3:
        print("more")