In Rock Paper Scissors, what function lets the player type their choice?
input()
What do we call something that stores a value?
variable
True or False: A loop can repeat the same code many times.
True
What is wrong here?
If player_choice == "rock":
If should be lowercase: if
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
Why do we often use .lower() or .capitalize() on user input?
To make the input match the expected format / avoid mistakes with capital letters
What is wrong with this variable name?
2name = "Tom"
Variable names cannot start with a number
What will this code print
x = 1
while x <= 3:
print(x)
x += 2
1
3
What is missing here?
if player_choice == "rock"
:
Why does this code never stop?
count = 1
while count < 5:
print(count)
Because the count never changes, the condition stays true forever.
If a player types something invalid, what should the program do?
Ask again / show an error message / keep looping until valid input
What is wrong with this code?
What will this code print?
count = 5
while count > 0:
if count == 3:
break
print(count)
count -= 1
5
4
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.
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.
Which variable name is better for storing the player’s choice: x or player_choice?
player_choice
What will this code print?
a = 2
b = 3
a = b
b = 5
print(a)
3
What will this code print?
count = 0
while count < 3:
count += 1
print(count)
1
2
3
What is missing
options = ["rock", "paper", "scissors"]
computer_choice = random.choice(options)
print(computer_choice)
import random
What will this code print?
a = 3
b = 5
a = b
b = a + 2
print(a, b)
(5, 7)
Why is validating user input important?
To make sure the program only accepts valid choices and does not break
What is the difference between these two lines?
print("5" + "2")
print(5 + 2)
52 (combine string)
7 (add integer)
What is the final value of total?
total = 1
while total < 10:
total = total + 3
print(total)
10
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")
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: