Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python conditionals, and loops |Part 3

Total questions: 36

Worksheet time: 54mins

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)

more than 7

b)

more than 23

c)

spam

d)

7

3.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

4.

What is the output?

a)

250.0

b)

200.0

c)

300.0

d)

350.0

5.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

6.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

7.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

8.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

9.

What is the output?

a)

level 3

b)

level 3

level 1

c)

level 3

level 1

NIL

d)

level 3

level 2

level 1

NIL

10.

What is the output?

a)

40

b)

15.0

c)

30

d)

25.0

11.

What will be the output

a)

four

b)

4

c)

one , two

d)

three

12.

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

13.

What will be the output?

a)

nested: x == 10

b)

nested: else

c)

nested: x == 6

d)

else

14.

The % symbol in Python is used to.

a)

Get the reminder of a division problem.

b)

Divide the number

c)

Calculate the percentage

d)

Print the output

15.

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

16.
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
17.

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
18.
Which type of loop iterates until instructed otherwise?
a)
FOR loop
b)
A count-controlled loop
c)
Repeat-once loop
d)
WHILE loop
19.
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
20.
Which of the following symbols is used in Python to mean "Equal to"?
a)
=
b)
!=
c)
==
d)
>=
21.
Which of the following symbols is used in Python to mean "Not equal to"?
a)
==
b)
!=
c)
<>
d)
><
22.
Which of the following symbols is used in Python to mean "Greater than or equal to"?
a)
<=
b)
>>
c)
>=
d)
=>
23.
Which of the following symbols is used in Python to mean "Less than or equal to"?
a)
<<
b)
=<
c)
<=
d)
!=
24.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
25.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
26.
a)
Hello world!
b)
Hello world
c)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
d)
Error
27.
a)
Welcome
b)
Try again!
c)
Error
d)
Enter your password
28.
a)
Hello world!
b)
Error
c)
Hello world!
False
d)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
29.

Which of these codes is correct for creating a list of numbers?

a)

num = ('10','29','37','109')

b)

num = ['10','29','37','109']

c)

num == ('10','29','37','109')

d)

num = ['10 29 37 109']

30.

What does the '#' allow you to do?

a)

Repeat code

b)

Comment on code

c)

Print code

d)

End code

31.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

32.

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

33.

if you wished a loop to repeat 3 types what should you use?

a)

For counter in range(0,5):

b)

For counter in range(0.3):

c)

For counter in range(1.3):

34.

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

a)

counter

b)

print

c)

for

d)

#example

35.

What type of loop is used when you know how many times you want to repeat something?

a)

A WHILE Loop

b)

An IF function

c)

A FOR Loop

d)

A Variable

36.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 2-10

c)

Print Numbers 1-10

d)

Print Error