wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python conditional execution, loops. Rev 3

Total questions: 24

Worksheet time: 48mins

Name
Class
Date
1.

What part of an if statement should be indented?

a)

All of it

b)

The statements within it

c)

the first line

d)

the lines within the brackets

2.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

3.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

4.

What will be the output

a)

four

b)

4

c)

one , two

d)

three

5.

What will be the output?

a)

x is greater than 5

x is equal to 10

b)

x is greater than 5

c)

x is greater than 10

d)

x is equal to 10

6.

What will be the output?

a)

a and b is 7

a or b is 4

not a is True

b)

a and b is 4

a or b is 7

not a is False

c)

Syntax error

d)

a and b is False

a or b is True

not a is True

7.
In programming, what is iteration?
a)
The repetition of steps within a program
b)
The order in which instructions are carried out
c)
A decision point in a program
d)
Testing a program to make sure it works
8.

Which two statements are used to implement iteration/Repetition)?

a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
9.
Which type of loop iterates until instructed otherwise?
a)
FOR loop
b)
A count-controlled loop
c)
Repeat-once loop
d)
WHILE loop
10.
The condition for a while loop to continue could include which of the following?
a)
While something equals something
b)
While something is greater than something
c)
While something is True
d)
All of these
11.

What does the following program display?

a)

1,2,3,4

b)

counter,counter,counter,counter,counter

c)

1,2,3,4,5

d)

0,1,2,3,4,5

12.

what is the name of the variable used in the following code?

a)

counter

b)

print

c)

for

d)

#example

13.

What will this code do?

a)

0,1, 2, 3, 4, 5, 6, 7, 8, 9,

b)

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,

c)

1, 2, 3, 4, 5, 6, 7, 8, 9, 10,

d)

Print Error

14.

‘If’ is a decision making statement

a)

TRUE

b)

FALSE

15.

Which character must be at the end of the line for if?

a)

:

b)

;

c)

.

d)

{

16.
What will be printed to the screen?
a)
Nothing
b)
Success
c)
Failure
d)
Success
 Failure
17.
What will be printed to the screen?
a)
Success
b)
Failure
c)
Part of the way there!
d)
Nothing
18.

What is an algorithm?

a)

A set of steps for performing a task, like a recipe.

b)

To add something to the end; for example, adding letters onto the end of a string or adding elements to the end of a list or array.

c)

A value passed to a function.

d)

A rhythm designed for people named "Al."

19.

A set of instructions that is repeated until a condition is reached is

a)

a loop

b)

code

c)

a function

d)

an expression

20.

What is a variable?

a)

a type of graphics

b)

A box(memory location) where you store values

c)

Data type

d)

a type of memory

21.

A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly

a)

True

b)

False

22.

Loop that runs till the condition is true

a)

list

b)

while

c)

for

d)

if

23.

In Python, the two types of loops are _____ and _______

a)

while

b)

for

c)

list

d)

if

24.

FOR loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming