wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

grade 7&8 week 15

Total questions: 50

Worksheet time: 38mins

Name
Class
Date
1.

What is selection in programming?

a)

Repeating a process

b)

Choosing actions based on a condition

c)

Declaring variables

d)

Ending a loop

2.

What is iteration in programming?

a)

A. A one-time decision

b)

B. Repeating a set of instructions

c)

C. A variable declaration

d)

D. Data storage

3.

Which keyword is used for selection in Python?

a)

for

b)

while

c)

if

d)

repeat

4.

Which of the following uses iteration?

a)

if x > 5:

b)

while x < 10:

c)

print(x)

d)

input(x)

5.

Why do we combine selection and iteration?

a)

To run code once

b)

To test conditions multiple times inside a loop

6.

What is the output? for i in range(3): if i == 1: print("Yes")

a)

Yes Yes Yes

b)

Yes

c)

1 2 3

d)

None

7.

Which of these loops runs exactly 5 times?

a)

for i in range(6):

b)

for i in range(5):

c)

while i < 6:

d)

for i in range(1,6,2):

8.

What happens when a loop has a false condition?

a)

It restarts

b)

It stops

c)

It prints False

d)

It skips the code

9.

for i in range(4): if i % 2 == 0: print(i)

a)

1 3

b)

0 2

c)

0 1 2 3

d)

None

10.

Which statement ends a loop early?

a)

continue

b)

exit

c)

break

d)

return

11.

Which statement skips the current iteration?

a)

skip

b)

continue

c)

pass

d)

break

12.

What will this print? for i in range(5): if i == 2: continue print(i)

a)

A. 0 1 2 3 4

b)

B. 0 1 3 4

c)

C. 2 3 4

d)

D. 1 2 3

13.

What is the output? for x in range(3): if x != 1: print(x)

a)

A. 1

b)

B. 0 1 2

c)

C. 0 2

d)

D. 2

14.

Which loop repeats while a condition remains True?

a)

for

b)

repeat

c)

while

d)

until

15.

How many times will this loop run?

a)

5

b)

10

c)

2

d)

Infinite

16.

What does if-else do inside a loop?

a)

It allows different actions to be taken based on conditions during each iteration.

b)

It ends the loop immediately when a condition is met.

c)

It skips the current iteration and moves to the next one.

d)

It prevents the loop from running at all.

17.

What is printed? count = 0 for i in range(4): if i % 2 == 0: count += 1 print(count)

a)

4

b)

2

c)

3

d)

1

18.

If you forget to increment in a while loop, what happens?

a)

Error

b)

Infinite loop

c)

Skipped condition

d)

Program closes

19.

What keyword is used to define an infinite loop intentionally?

a)

for i in range(∞)

b)

while True:

c)

loop forever:

d)

repeat()

20.

In a for loop, what does range(3) mean?

a)

0 to 3

b)

0, 1, 2

c)

1 to 3

d)

1, 2, 3

21.

Which line demonstrates combining selection and iteration?

a)

if score > 50:

b)

while True:

c)

for x in range(5): if x > 2: print(x)

d)

print("Done")

22.

Which of these prints only even numbers from 1–10?

a)

A. if i % 2 == 1:

b)

B. for i in range(10): if i % 2 == 0: print(i)

c)

C. for i in range(10): print(i)

d)

D. while i == 10:

23.

What is the output? for i in range(5): if i == 3: break print(i)

a)

A. 0 1 2 3

b)

B. 0 1 2

c)

C. 3

d)

D. None

24.

Which of these is NOT an example of iteration?

a)

for

b)

while

c)

if

d)

repeat

25.

What happens when you put if inside a loop?

a)

The loop runs once

b)

The decision runs each time the loop iterates

c)

The loop stops immediately

d)

Syntax error

26.

What is the result of this code? for i in range(3): if i == 1: continue print(i)

a)

0 2

b)

0 1

c)

1 2

d)

2

27.

When does the else in a loop execute?

a)

Always

b)

Only if the loop finishes without a break

c)

When a continue is used

28.

What is the output? for i in range(3): if i == 2: print('End') print('Done')

a)

End Done

b)

Done

c)

End

d)

Error

29.

Which will print “Odd”?

a)

1

b)

0 2

c)

0 1 2

d)

None

30.

What is the output? x = 1 while x < 4: if x == 2: print('Middle') x += 1

a)

Middle

b)

None

c)

Error

d)

1 2 3

31.

What does continue do inside a loop?

a)

Stops the program

b)

Skips to the next iteration

c)

Ends the loop

d)

Restarts the loop

32.

What is the function of break in a nested loop?

a)

Ends the entire program

b)

Stops only the innermost loop

c)

Restarts the outer loop

d)

Skips an iteration

33.

What is printed? for i in range(2): for j in range(2): if i == j: print("Equal")

a)

4 times

b)

2 times

c)

1 time

d)

None

34.

Which code snippet prints all multiples of 3 from 1 to 9?

4 lines
35.

Which code counts even numbers in a list?

4 lines
36.

If the loop condition is always True, and no break is used:

a)

Loop runs once

b)

Loop runs infinitely

c)

Loop doesn’t start

d)

Error

37.

What will happen? for i in range(3): if i > 5: print(i)

a)

Prints 0 1 2

b)

No output

c)

Error

38.

What does nested iteration mean?

a)

A. A loop inside a loop

b)

B. Two if statements

c)

C. Multiple variables

d)

D. None

39.

Which is true about selection statements?

a)

They cannot be nested

b)

They can exist inside loops

c)

They must end with break

d)

They repeat indefinitely

40.

What’s the output? for i in range(4): if i < 2: print("Low") else: print("High")

4 lines
41.

What does this code print?

4 lines
42.

What is the output? for i in range(2): for j in range(3): print(i, j)

4 lines
43.

What is selection sometimes called?

a)

Decision making

b)

Looping

c)

Storage

d)

Repetition

44.

What is the output of the following code? break print(i) i += 1

(a)  

45.

Which example uses both for loop and if-else?

(a)  

46.

What is printed? for i in range(4): if i == 2: print("Two")

(a)  

47.

What is output if condition is always false in a loop?

a)

No iteration happens

b)

One iteration happens

c)

Infinite loop

d)

Error

48.

When combining selection and iteration, where can if appear?

a)

Only outside loop

b)

Inside or outside loop

c)

Only once

d)

Not allowed

49.

How many times is this executed? for i in range(2): for j in range(3): print("Run")

a)

6 times

b)

2 times

c)

3 times

d)

5 times

50.

Why is combining selection and iteration powerful?

a)

Allows complex, condition-based repetition

b)

Shortens code

c)

Prevents syntax errors

d)

Stops loops