wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CP M4 Repetition & Loops

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

A (a)   is a collection of commands that are given a name.

2.

True or False. Every WHILE loop can be replaced with FOR loop.

a)

True

b)

False

3.

Variable used to end the loop

a)

Loop control variable

b)

count variable

4.

While loops should always be:

a)

output

b)

indented

c)

calculated

d)

input

5.

For a loop to stop, the loop control variable must ________________.

a)

change

b)

be input from the keyboard

c)

be true

d)

change inside the loop

6.

What is wrong with:

x = 1

while (x < 20):

print (x)

a)

There is no x = 0 before the loop

b)

The loop will not stop since the condition is wrong

c)

x should be c

d)

The loop will not stop since x never changes

7.

Why do we use loops?

a)

Because computers can do calculations humans can't.

b)

Because programming is an important skill

c)

Because of efficiency.

d)

Because programs need to make decisions.

8.

Consider the following code:

x = 9

sum = 0

while (x < 19):

x = x + 1

num = int(input("Enter a number: "))

sum = sum + num

print (str(x) + ": " + str(num) + " Total: " + str(sum))


Which of the following is the loop-control variable?

a)

num

b)

sum

c)

x

d)

int

9.

Which of the following is NOT true about while loops?

a)

A way of repeating a code

b)

Use conditions like if statements

c)

Used to create functions

d)

Give us more control over how the program runs

10.

Which of the following is NOT a rule for algorithms?

a)

They produce a result.

b)

They have an order.

c)

They repeat indefinitely.

d)

They have clear instructions.

11.

Information sent to a function is a?

a)

Sum

b)

Loop Control Variable

c)

Range

d)

Parameter

12.

We trace code in order to identify errors and to predict output.

a)

True

b)

False

13.

The process of using random numbers made by computers to test computer models.

a)

Monte Carlo Method

b)

Simulation

c)

Modeling

d)

Algorithm

14.

The process of reading through code to find errors and predict results.

a)

Monte Carlo Method

b)

Tracing Code

c)

Modeling

d)

Simulation

15.

A precise rule (or set of rules) specifying how to solve some problem

a)

Algorithm

b)

Sum

c)

Function

d)

Parameter