Trace the Code
Loop Logic
If/Else Reasoning
Debug the Idea
Vocabulary & Concepts
100

x = 2

y = 9

print(x + y)

The variables x and y are added together. This results in the answer becoming 11.

100

for i in range(3):

    print(i)

Answer: 

0

1

2

Reason: The loop will run 3 times, this allows the values to print staring with the number 0 up to but not including the number 3

100

num = 3

if num == 5:

    print”yes")

else:

    print("no”)


The condition is false. This is ecause num is NOT equal to 5.

100

print("hello)


The string is missing a closing quotation mark which is why it won’t run, causing a syntax error.

100

What is a string?

A string is a sequenced closed with quotations, it is used to store text.

200

num = 3

if num % 2 == 0:

     print(“even”)

else:

     print(“odd”)

The number 7 is not divisible by the number 2. This means the elae will block the run.

200

x = 10

while x > 5:

    x -= 2

print(x)

The loop will decrease by 1 until the sum is smaller than 5

200

score = 85

if score >= 90:

    print("a")

elif score >= 80:

    print("b")

else:

    print("c")


The score is 85 which is less than 90. This means that the second condition is true because it is still a passing grade.

200

x = 3

if x > 5:

    print("big")

if x > 2:

    print("medium")

else:

    print("small")

There is a missing elif for the if else statements. The else is only pared with the second if and not the first. 

200

= vs. ==

= is used to assign a value to a variable

== is used to compare if to values are equal

300

def add(num):

    num += 5

    return num

x = 3

x = add(x)

print(x)


The function adds the number 5 to then return a new value that will infinite to chn he.

300

count = 0

for i in range(1, 10):

    if i % 3 == 0:

        count += 1

print(count)

In the loo the numbers may range from 1-10 but when ran it is excluded. The loop will count how many numbers are between 1 and 9 that are divisible by 3

300

x = 5

y = 10

if x > 3 or y < 5:

    print("yes")

else:

    print("no")

Yes, the condition is the because x is greater than 3 even when y isn’t less than 5.

300

for i in range(5):

print(i)

The print statement is not indented which is causing this indentation error.

300

Difference between for and while loop

For Loop: A For Loop is used to run a specific number of iterates over sequence


While Loop: A While Loop can run as long as its condition remains true