Trace the code
Loop logic
If/else reasoning
Debug the idea
Vocab and concepts
100

What is printed when this code runs? 

python

x = 5

x = x + 2

print(x)

7, The variable x starts at 5, then 2 is added, making the new value 7

100

How many times does this loop run?

python

for i in range(3):

       print("Hi")

3 times,

Explanation: range(3) produces 0, 1, and 2, so the loop runs three times


100

What prints if x = 4?

python

if x > 5:

      print(“Big”)

else: 

    print(“Small”)


Small

Explanation: The condition is false, so the else block runs.

100

Why doesn’t this code print anything?

python

x = 2

if x > 5:

      print(“Yes”)


The condition is false. Explanation: Since x is not greater than 5, the code inside the if statement does not run


100

What is a loop?

A structure that repeats code.

200

What is the output of this code?

python

x = 10

y = x - 3

x = y + 4

print(x)


11, y becomes 7, then x is reassigned to 11


200

What is printed?

python

total = 0

for i in range(1, 4):

    total = total + i

print(total)


6

Explanation: The loop adds 1, 2, and 3 to total

200

What prints if age = 16?

python

if age >= 18:

      print(“Adult”)

else:

      print(“Minor”)


Minor

Explanation: Since 16 is less than 18, the condition is false.


200

What is the error in this code?

python

for i in range(4)

     print(i)


Missing a colon.

Explanation: Loops require a colon to show where the code block starts.

200

What does an if statement do?

Checks a condition and runs code if its true.

300

What does this code print?

python

x = 2

y = x * 3

x = y - x

print(x)


4, y is 6, then x becomes 6-2

300

What is the final value of count?

python

count = 0

for i in range (5):

      count += 1


5

Explanation: The loop runs five times, adding 1 to count each time.

300

What prints if num = 0?

python 

if num > 0: 

      print(“Positive”)

elif num == 0:

     print(“Zero”)

else: 

     print(“Negative”)


Zero

Explanation: The first condition fails, but the equality check succeeds.


300

What needs to be added to fix this loop?

python 

x = 0

while x < 3:

       print(x)

Increase x inside the loop.

Explanation: Without changing x, the condition stays true forever.

300

What is debugging?

Finding and fixing errors in code.

M
e
n
u