User input
Python Basic
Loop
Debugging
Debugging
100

In Rock Paper Scissors, what function lets the player type their choice?

input()

100

What do we call something that stores a value?

variable

100

True or False: A loop can repeat the same code many times.

True

100

What is wrong here?


If player_choice == "rock":

If should be lowercase: if

100

Which one is better for checking?

A

if choice == "rock" or choice == "paper" or choice == "scissors":
    print("Valid")

B

if choice in ["rock", "paper", "scissors"]:
    print("Valid")

B

200

Why do we often use .lower() or .capitalize() on user input?

To make the input match the expected format / avoid mistakes with capital letters


200

What is wrong with this variable name?

2name = "Tom"

Variable names cannot start with a number

200

What will this code print

x = 1
while x <= 3:
    print(x)
    x += 2

1

3


200

What is missing here?


if player_choice == "rock"

:

200

Why does this code never stop?

count = 1

while count < 5:
    print(count)

Because the count never changes, the condition stays true forever.


300

If a player types something invalid, what should the program do?

Ask again / show an error message / keep looping until valid input

300

What is wrong with this code?


Print("Hi")



print should be in lowercase
300

What will this code print?

count = 5
while count > 0:
    if count == 3:
        break
    print(count)
    count -= 1

5

4

300

What is the purpose of break in this code?

while True:
    choice = input("Enter rock, paper, scissors, or quit: ")
    if choice == "quit":
        break
    print("Game continues")

"break" stops the loop when the user types quit.

300

Why is this code wrong?

choice = input("Enter yes or no: ")

if choice == "yes" or "no":
    print("Valid")
else:
    print("Invalid")

The condition is wrong. It does not compare choice to "no" properly, so it will always act as true.

400

Which variable name is better for storing the player’s choice: x or player_choice?

player_choice

400

What will this code print?

a = 2
b = 3
a = b
b = 5
print(a)

3

400

What will this code print?

count = 0

while count < 3:
    count += 1
    print(count)

1

2

3


400

What is missing

options = ["rock", "paper", "scissors"]
computer_choice = random.choice(options)
print(computer_choice)

import random

400

What will this code print?

a = 3
b = 5
a = b
b = a + 2
print(a, b)

(5, 7)

500

Why is validating user input important?

To make sure the program only accepts valid choices and does not break

500

What is the difference between these two lines?

print("5" + "2")
print(5 + 2)

52 (combine string)

7 (add integer)

500

What is the final value of total?

total = 1

while total < 10:
    total = total + 3

print(total)

10

500

Find three mistakes in this code.

choice = input("Enter rock, paper, or scissors: ")

if choice = "rock":
    print("Rock")
elif choice == paper:
    print("Paper")
else
    print("Scissors")

  • choice = "rock" should be choice == "rock"
  • paper should be "paper"
  • else needs a colon :
500

What will happen when this code runs?

player_choice = input("Enter your choice: ")

if player_choice == "rock":
    print("You chose rock")
if player_choice == "paper":
    print("You chose paper")
else:
    print("Invalid")

If the user enters "rock", it will print:

  • You chose rock
  • Invalid
M
e
n
u