What is the syntax for a while loop?
while condition:
print(xyz)
break
What are for loops commonly used for?
What is repeating something a set number of times?
This symbol is used to create a list in Python.
What are square brackets [] ?
This keyword is used to define a function.
What is def?
This keyword is used to check an alternative condition.
What is elif?
This keyword is used inside a while loop to immediately stop it.
What is break?
The condition “for i in range(3)” will print how many numbers?
What is 3 (0, 1, 2)?
The index of the first element in a Python list.
What is 0?
This keyword sends a value back from a function?
What is return?
This condition will run if no previous condition were True.
What is else?
This logic error happens when a while loop’s condition never becomes false.
What is an infinite loop?
What is the output of this code?:
for i in range(1, 5):
print(i * 2)
What is 2, 4, 6, 8?
What does the .append method do to a list?
What is adds numbers or characters to the end of a list?
In def greet(name):, name is called this.
What is a parameter?
What is == used for in an if statement?
What is comparing two values for equality?
In “while x < 10” this must happen inside the loop to avoid an infinite loop.
What is updating (incrementing) the variable x?
What is the value of sum after this code runs?:
sum = 0
for i in range(1,4):
sum +=1
What is 6?
(1 + 2 + 3 = 6)
What does the len(my_list) method return?
What is the output of this code?:
def mystery(x):
return x * 2
print(mystery(3) + mystery(4))
What is 14?
What is printed?
x = 7
y = 3
if x > 5 and y < 5:
print(“Yes”)
else:
print(“No”)
What is “Yes”?
What is the outcome of this code and count’s value after running?:
count = 0
while count <= 5:
if count < 0:
print(“Negative number”)
else
print(“ “)
count+=1
6 blank lines are printed, and count = 6
How many times does this code run?
total = 0
for i in range(3):
for j in range(2):
total += 1
print(total)
What is 6?
What is x? (PseudoCode):
list = [1, 0, 4, 2]
x = -1
for EACH item IN list:
if item > x:
x = item
DISPLAY x
What is x = 2?
What is printed when this code runs?
def change(num):
num +=5
return num
x = 10
change(x)
print(x)
What is 10?
The function changes a copy of x, not the original variable.
What is printed?
score = 85
if score >= 90:
print(“A”)
elif score >= 80:
print(“B”)
elif score >= 70:
print(“C”)
else:
print(“F”)
What is “B”?