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

qution=input("how are you feeling today:" )

if qution == "good" or "ok"

    print("thast amzing")

else

    print ("i hope your day gets better")

In this code what is missing

The “:”  behind of the else and the if statement

With out the :  the code will not work because the : is what determines if its an if statement or not .


100

count = 0


while count < 5:

    if count % 2 == 0:

        print("Hello")

    count += 1

How many times will the code print hello


 3 times 

The loop runs five times and prints "Hello" only when count is even (0, 2, and 4), resulting in three prints.

100

number = 10


if number > 5:

    print("Big")

else:

    print("Small")


What will be printed when the following code runs?

 big 


Since the number is 10, which is greater than 5, the if condition is true, so the program prints "Big".

100

for i in range(1, 5):

    print(i)


The following code is supposed to print all numbers from 1 to 5, but it has a mistake. What is the error?

The range stops before 5, so it only prints 1 to 4.


 The range(1, 5) excludes the last number, so to include 5 it should be range(1, 6).


100

This programming term refers to a named place in a program where you store information, such as a number or a word.

a variable 


A variable is a named container in a program that stores data so it can be used or changed later.

200

for i in range (1,11):

    if i %2 == 0:

        print("even")

    else:

        print("odd")

for i in range (1,9):

    if i > 4 :

        print ("high")

    Else      

   print("done"

What is something you should swap out for something else

The done at the end of the question , can be swapped out for low 

The done at the end of the question isn't really practical especial because its an else statement so it should be the opposite of high , it doesn't have to be but it just doesn't need to have the same meaning as the if statement,

200

total = 0


for i in range(1, 6):

    if i % 2 == 0:

        total += i

    else:

        total += 1

What is the final value of total after the following code runs?

the answer is 9


The loop runs from 1 to 5; for odd numbers it adds 1 to total, and for even numbers it adds the number itself. This results in additions of 1 (for 1), 2 (for 2), 1 (for 3), 4 (for 4), and 1 (for 5), giving a final total of 9.

200

score = 75


if score >= 90:

    print("A")

elif score >= 70:

    print("B")

elif score >= 50:

    print("C")

else:

    print("F")


What will be printed when the following code runs?

A b will be printed 


Since score is 75, it doesn’t satisfy the first condition (score >= 90) but does satisfy the second (score >= 70), so the program prints "B".

200

for i in range(1, 6):

    print(i * i + 1)


The following code is supposed to print the squares of numbers from 1 to 5, but it doesn’t produce the correct output. What is wrong?

It incorrectly adds 1 to each square; it should be print(i * i) to print the squares.

200

This programming concept allows a program to repeat a set of instructions multiple times until a condition is met.

a loop


A loop is a programming structure that repeats a block of code while a condition is true or for a set number of times.

300

x = 3

y = 5


for i in range(2):

    x = x + y

    y = y - 1

    print(x, y)



8 4

12 3

The loop runs twice, and each time x increases by the current value of y while y decreases by 1 The printed values show how x grows and y shrinks on each iteration: first 8 4, then 12 3.

300

count = 0


for i in range(1, 6):

    for j in range(i):

        if (i + j) % 2 == 0:

            count += 1

        else:

            count -= 1


print(count)


What is the output of the following code?

out put is 3 

The nested loops adjust count up or down based on whether i + j is even or odd, and after all iterations complete, the final value printed is 3.

300

x = 8

y = 3

z = 5


if x > y and z < y:

    print("Alpha")

elif x > y or z < y:

    if x - z > y:

        print("Beta")

    else:

        print("Gamma")

else:

    print("Delta")


What will be printed when the following code runs?



gamma


The first if is false, the elif is true, but the inner if (x - z > y) is false, so the program prints "Gamma".

300

for i in range(1, 10):

    if i % 2 == 0:

        continue

    print(i)


The following code is intended to print all even numbers from 2 to 10, but it doesn’t work correctly. What is the bug?



The continue is skipping all even numbers, so it prints only odd numbers; it should print i when i % 2 == 0 instead.

300

This programming term refers to the information or result that a program shows or produces after it runs.

a out put 


An output is the result or information that a program produces and shows to the user.

M
e
n
u