Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python- if -ifelse-elif

Total questions: 30

Worksheet time: 15mins

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)

False

c)

condition1

d)

condition2

4.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

5.

What is the output?

a)

250.0

b)

200.0

c)

300.0

d)

350.0

6.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

7.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

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 is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
12.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
13.

If else statement

a)

Outputs a message on the screen

b)

Gets data from the user

c)

A decision

d)

A loop controlled by a decision

14.
This operator means that one value is not equal to another value
a)
==
b)
<=
c)
>=
d)
!=
15.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
16.

It is possible to execute both the (block of) statements under if and the else clauses at the same time.

a)

Yes

b)

No

17.

To execute a Python program, you need a Python interpreter.

a)

True

b)

False

18.

What would be the result of 3 ** 3

(a)  

19.

What would be the result of 9 // 7

(a)  

20.

What would be the reult of 9 % 7

(a)  

21.

Text to be output to the screen should be enclosed by " "

a)

True

b)

False

22.

What is the output of this code?


click = True

Like = 0

if click:

Like = Like + 1

print(Like)

a)

0

b)

1

c)

2

d)

3

23.

What is the output of the following code?


What is the output of following code

Temperature = 20

Thermo = 15

if Temperature < 15:

Thermo = Thermo + 5

print(Thermo)

a)

20

b)

15

c)

25

d)

10

24.

What is the output of the following code?


Time = "Day"

Sleepy = False

Pajamas = "Off"

if Time == "Night" and Sleepy == True:

Pajamas = "On"

print(Pajamas)

a)

off

b)

on

c)

False

d)

Day

25.

What will be the output of the following code?


def max(a, b):

if a > b:

print('a is the max')

else:

print('b is the max')


max(1,2)

a)

1 is the max

b)

a is the max

c)

2 is the max

d)

b is the max

26.

Which of the following statements are correct?

(Select 2 Answers)

a)

If is a conditional statement

b)

If is used for looping

c)

If is used for comparing and decision making

d)

If is used for error handling

27.

What will the be the output of the following code?


if (10<0) and (0 <-10):

print(“A”)

else:

print(“B”)

a)

A

b)

B

c)

AB

d)

BA

28.

Is the following statement True of False?

Boolean variables can be used as conditions in an IF statement.

a)

True

b)

False

29.

What is the output of the following code?


a = "b"

if True or True:

a = "a"

print(a * 2)

a)

bb

b)

aa

c)

ab

d)

ba

30.

Is the following statement true or false?


More than one condition cannot be used with an IF statement.

a)

True

b)

False