Cast of Characters
If only…
Bug Off!
Slice, Slice Baby
Out of the Loop
100

This Python function displays text or variable values to the console or output.

What is print()?

100

This comparison operator, often used in conditional statements and while loops, checks if two values are equal.

What is ==?
100

The bug in this code prevents it from running:

score = 95

if score > 90

        print(“A”)

What is syntax error (missing colon at end of if statement)?

100

This method adds a new element to the very end of an existing list.

What is .append()?

100

This loop type is best used when you want to repeat code an unknown number of times until a condition becomes False (or for as long as a condition is True).

What is a while loop?

200

This data type is used to represent decimal numbers like 98.6 or -0.5.

What is a float?

200

This keyword runs its code only when every if and elif condition before it evaluates to False.

What is else?

200

Trying to run int("hello") triggers this kind of error because "hello" cannot be converted into a number.

What is a runtime error?
200

Calling len("Code") and len(“Python”) both return this.

What is the length of the string?

200

Using range(4) in a for loop goes over these four integers.

What is 0, 1, 2, 3?

300

To do math with a whole number collected from input(), you must cast it using this function.

What is int()?

300

This logical operator flips True to False and False to True.

What is not?

300

The following code suffers from this error type when trying to calculate the average of 10 and 20: 

average = 10 + 20 / 2


What is a logical error (put the 10 + 20 inside parentheses)?

300

Given nums = [10, 30, 40], calling nums.insert(1, 20) changes nums to this list.

What is [10, 20, 30, 40]?

300

Calling range(3, 8) starts at 3 and stops at this final integer.

What is 7?

400

Printing the following statement automatically separates the two Strings with this character by default: print("Hello", "World")

What is a space?

400

Given age = 16 and has_permit = True, the expression (age >= 16 and has_permit) evaluates to this.

What is True?

400

The while loop below needs to do this to stop it from running forever:

count = 1

while count <= 5:

        print(count)

What is update count inside the loop (count += 1)?

400

Given str1 = "abcdef", str1[1:4] evaluates to this substring.

What is “bcd”?

400

The following code steps backwards on the number line by returning the numbers 5, 4, 3, 2, 1 using range() with this step value: range(5, 0, ___).

What is -1?

500

Integer division, which always rounds down or truncates the result to an integer, cutting off any decimal values, is represented by this many /s in Python.

What is 2 /s?

500

In Python, you can rewrite the expression 5 < x < 10 as these two expressions separated by a logical operator.

What is x > 5 and x < 10?

500

A student wants to check if the user input is either "y" or "Y", so they write if userInput == "y" or "Y":

But when they run it, no matter what they enter, their conditional is always True. The student must change their conditional to this to correct their code.

What is if userInput == “y” or userInput == “Y”: (other answers may be accepted)?

500

Given fruits = ["apple", "banana", "cherry", “date”, “elderberry”], the expression fruits[-2].upper() returns this string.

What is “DATE”?

500

This is the final value of total after this loop finishes:

total  = 0

for n in “A short word”:

        total += n

What is 12?

M
e
n
u