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(9)” will print how many numbers?
What is 9 (0, 1, 2, 3, 4, 5, 6, 7, 8)?
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, 10):
print(i * 2)
What is
2
4
6
8
10
12
14
16
18?
What does the .insert method do to a list?
What is inserts a value at the specified index?
How would you call a method named:
def greet(name):
What is " greet("John") " ?
What is == used for in an if statement?
What is comparing two values for equality?
In “while x > 90” this must happen inside the loop to avoid an infinite loop.
What is updating (decrementing) the variable x?
What is the value of sum after this code runs?:
sum = 0
for i in range(0,4):
sum +=1
What is 4?
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 1?
What is printed?
x = 6
y = 4
if x > 3 and y < 2:
print(“Yes”)
else:
print(“No”)
What is “No”?
What is the outcome of this code and count’s value after running?:
count = 0
while count <= 3:
if count < 0:
print(“Negative number”)
else
print(“One“)
count+=1
What is
One
One
One
One
count = 4 ?
How many times does this code run?
total = 0
for i in range(28):
for j in range(3):
total += 1
print(total)
What is 84?
What is x? (PseudoCode):
list = [1, 0, -6, 4, -1, 5, 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*2/1)
return num
x = 10
change(x)
print(x)
What is 10?
The function changes a copy of x, not the original variable. While x's value changes inside the function, the returned value is not stored anywhere, hence print(x) prints the original value of x.
The Output:
x = 7
if x > 10:
print("A")
elif x > 5:
if x < 8:
print("B")
else:
print("C")
else:
print("D")
What is “B”?