Vocab
Debug
Logic
Alghoritm
Console & Operators
100

A reusable block of code that performs a specific task, which you can call by name to teach Karel a new word.

What is a function?

100

Identify the syntax error:

def turn_right()

    turn_left()

    turn_left()

    turn_left()


There is supposed to be a ":" after defining a function, example: def musical_play():.

100

This conditional statement allows a program to execute a block of code only if a specific boolean condition evaluates to true.

What is an if statement?

100

The name given to a step-by-step set of instructions used by a program to solve a problem or complete a task.

What is an algorithm?

100

This function is used to gather information from a user via the console, and it always stores the captured data as a string data type.

What is input()?

200

A programming structure that allows Karel to repeat a block of code a specific, fixed number of times.

What is a For-Loop?

200

Identify the syntax error:

turnLeft()

It must be turn_left() (all lowercase with an underscore). CodeHS Python uses snake_case, not camelCase.

200

This structural block is used to choose between exactly two paths of execution, running one set of code if a condition is true and a different set if it is false.

What is an if/else statement?

200

This type of control flow block allows an algorithm to make a decision and execute code only if a certain logical condition is met.

 What is an if statement? (Accept: conditional)

200

This mathematical operator divides two numbers and returns only the remainder, which is frequently used to check if a number is even or odd.

What is the modulus operator (or %)?

300

The process of breaking down a complex problem into smaller, simpler, and more manageable functions.

What is Top-Down-Design?

300

What specific error will Python generate when trying to run this function, and how do you fix it?

def turn_around():
turn_left()
turn_left()

An Indentation Error. The statements inside the function body must be indented (usually by 4 spaces).

300

In CodeHS Python Karel, this specific built-in logical condition returns true if there is a wall or edge directly blocking Karel from stepping forward.

What is front_is_blocked? (or not front_is_clear).

300

Clue: Look closely at the following algorithm segment:

total = 0

for i in range(1, 11, 3):

    total += i

What is the final value of total after the loop finishes executing?

What is 22? (Explanation: range(1, 11, 3) generates the values 1, 4, 7, and 10. Adding them together: 1 + 4 + 7 + 10 = 22).

300

This is the exact string output produced when evaluating the combined concatenation and repetition expression: str(5 * 2) + "5" * 2.

What is "1055"?
(Explanation: 5 * 2 is 10, which casts to "10". "5" * 2 repeats to become "55". Joining them results in "1055").

400

The specific naming convention that must be used for multi-word Karel functions in Python.

What is snake_case?

400

Question: What logical bug will occur if Karel executes this code loop?

while front_is_clear():
    put_ball()

An infinite loop. Because Karel never moves forward, front_is_clear() will stay true forever, causing Karel to place balls on the same spot endlessly.

400

Consider the following CodeHS code block:

x = 15

if x % 3 == 0 and x % 5 == 0:

    print("FizzBuzz")

elif x % 3 == 0:

    print("Fizz")

else:

    print("Buzz")

If the first line is modified to x = 20, this is the exact message that outputs to the console.

What is Buzz?

400

To prevent a while loop from turning into an infinite loop, this specific action must occur to the variable being evaluated in the condition during every single iteration.

What is updating (or incrementing/decrementing) the loop control variable?

400

If a user enters 15 at a prompt for the variable x, this is the exact float value generated by evaluating the expression: float(x) / 2 + 10 % 4.

What is 9.5?
(Explanation: float("15") is 15.0. Then 15.0 / 2 is 7.5. Next, 10 % 4 leaves a remainder of 2. Finally, 7.5 + 2 equals 9.5).

500

The programming terms for what assumptions must be true before a function runs, and what must be true after it finishes.

What is a precondition and post condition?

500

Karel needs to clear all balls along a straight line. A student writes the code below, but it consistently leaves behind a ball if it's on the very last spot (against the wall). Why?

while front_is_clear():

    if balls_present():

        take_ball()

    move()

The loop stops as soon as front_is_clear() becomes false (when Karel faces the wall). Because move() is at the end of the loop, Karel steps onto the final square but the loop terminates before checking if balls_present() on that last tile. To fix it, an additional conditional check must be added after the loop.

500

Evaluate the final value of the variable result after this complex Python short-circuit evaluation runs:

a = True

b = False

c = True

result = (b or c) and not (a and b) or (not c)

What is True?
(Breakdown: (False or True) evaluates to True. not (True and False) evaluates to not False, which is True. True and True becomes True. Finally, True or False evaluates to True).

500

This structural arrangement consists of an outer loop executing an inner loop, where the total number of times the innermost instructions run is equal to the product of both loop iterations.

 What is a nested loop? (Accept: nested control structure).

500

Given the assignments a = "3" and b = 4, evaluating this complex combination of sequence multiplication, type conversion, and division results in this single integer value: int(a * b) % 100 // b.

What is 8?
(Explanation: a * b multiplies the string "3" four times, resulting in "3333". Casting it gives the integer 3333. Then, 3333 % 100 leaves the remainder 33. Finally, integer division 33 // 4 truncates to 8).

M
e
n
u