wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Uso de IF, ELIF. ELSE en python

Total questions: 6

Worksheet time: 3mins

Name
Class
Date
1.

What is the output of the following snippet?

x = 5

y = 10

z = 8


print(x > y)

print(y > z)

a)

False, False

b)

False, True

c)

True, False

d)

True, True

2.

What is the output of the following snippet?

x, y, z = 5, 10, 8


print(x > z)

print((y - 5) == x)

a)

False, True

b)

True, True

c)

True, False

d)

False, False

3.

What is the output of the following snippet?

x, y, z = 5, 10, 8

x, y, z = z, y, x


print(x > z)

print((y - 5) == x)

a)

True, True

b)

False, False

c)

True, False

d)

False, True

4.

What is the output of the following snippet?

x = 10


if x == 10:

print(x == 10)

if x > 5:

print(x > 5)

if x < 10:

print(x < 10)

else:

print("else")

a)

False, False

b)

True, False, else

c)

True, True

d)

True, True, else

5.

What is the output of the following snippet?

x = "1"


if x == 1:

print("one")

elif x == "1":

if int(x) > 1:

print("two")

elif int(x) < 1:

print("three")

else:

print("four")

if int(x) == 1:

print("five")

else:

print("six")

a)

six

b)

four, five

c)

one

d)

two, five

6.

What is the output of the following snippet?

x = 1

y = 1.0

z = "1"


if x == y:

print("one")

if y == int(z):

print("two")

elif x == y:

print("three")

else:

print("four")

a)

one, two, three, four

b)

four

c)

one, two

d)

two