wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

LOOPS AND FLOW CONTROL STATEMENTS

Total questions: 10

Worksheet time: 9mins

Name
Class
Date
1.

Code for

Five is greater than two!

a)

if 5 > 2:

print("Five is greater than two!")

b)

if 5 = 2:

print("Five is greater than two!")

c)

if 5 > 2: Print("Five is greater than two!")

2.

Code for

257

Hello, World!

a)

x = 257

y = "Hello, World!"


print(y)

print(x)

b)

x = 257

y = "Hello, World!"


print(x)

print(y)

c)

x = 257

y = Hello, World!


print x

print y

3.
What will the output be from the following code?
print("Hello" + "world" + "today")
a)
Helloworldtoday
b)
Hello world today
c)
"Hello" "world" "today"
d)
SyntaxError
4.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday

5.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
6.

An empty/null statement in python is ____________

a)

go

b)

pass

c)

over

d)

;

7.

What is the output of the above program ?

a)

Am I here?

b)

Or here ?

c)

Am I here ? Or here ?

d)

Or here ? Or over here ?

8.

If the user inputs : 2<Enter> , what does the following code snippet print ?

a)

Yes

b)

No

c)

May be

d)

Nothing printed

e)

Error

9.

In for a in _________ : , the blank can be filled with

a)

an iterable sequence

b)

a range() function

c)

a single value

d)

an expression

10.

Consider the following loop given below :


for i in range(5):

print(i)


How many times will this loop run ?

a)

5

b)

0

c)

infinite

d)

Error