Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python conditionals Elidon Mema

Total questions: 30

Worksheet time: 18mins

Name
Class
Date
1.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
2.
What will the lines of code print?
a)
A
b)
B C
c)
A B C
d)
A C
3.
What will the following lines of code print?
a)
A
b)
B C
c)
A B C
d)
Nothing, it will return an error.
4.
What will the following lines of code print?
a)
A
b)
B C
c)
A C
d)
Nothing, it will return an error.
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.
What will be printed to the screen?
a)
Nothing
b)
Success
c)
Failure
d)
Success
 Failure
7.
What will be printed to the screen?
a)
Success
b)
Failure
c)
Part of the way there!
d)
Nothing
8.
What will be printed to the screen?
a)
Failure
b)
Part of the way there!
c)
Success
d)
Nothing
9.
What will be printed to the screen?
a)
Nothing
b)
Success
c)
Part of the way there!
d)
Failure
10.
Which of the following would lead to nothing being printed?
a)
age is 17 and birth_month is 8
b)
age is 16 and birth_month is 7
c)
age is 17 and birth_month is 10
d)
age is 12 and birth_month is 4
11.
Which of the following would lead to "You're almost an adult!" being printed?
a)
age is 17 and birth_month is 8
b)
age is 16 and birth_month is 7
c)
age is 17 and birth_month is 9
d)
age is 12 and birth_month is 4
12.

What will print to the screen when the following program is run?


number = 5

greater_than_zero = number > 0

print(type(number))

a)

5

b)

True

c)

<type ‘int’>

d)

<type ‘bool’>

13.

What will the following program print when run?


number_one = 5

number_two = 10


if number_one == 5:

print(1)

elif number_one > 5:

print(2)

elif number_two < 5:

print(3)

elif number_one < number_two:

print(4)

elif number_one != number_two:

print(5)

else:

print(6)

a)

1

b)

1

3

5

c)

1

4

d)

1

4

5

14.

What does this program print?


height = 65

gender = "female"


if height < 62:

print "You are below average height"

elif height > 69:

print "You are above average height"

else:

print "You are average height"

a)

You are below average height

b)

You are above average height

c)

You are average height

d)

You are below average height

You are above average height

15.

What does this program print?


height = 65

gender = "female"


if height < 62 or (height < 69 and gender == "male"):

print "You are below average height"

elif height > 69 or (height > 62 and gender == "female"):

print "You are above average height"

else:

print "You are average height"

a)

You are below average height

b)

You are above average height

c)

You are average height

d)

You are below average height

You are above average height

16.

What does this program print?


favorite_color = "blue"


if favorite_color != "green":

print "But green is the color of grass!"

if favorite_color == "red":

print "I like red, too!"

if favorite_color == "blue":

print "Blue is the best"

if favorite_color != "yellow":

print "But yellow is the color of school buses!"

a)

But green is the color of grass!

Blue is the best

But yellow is the color of school buses!

b)

But green is the color of grass!

c)

But green is the color of grass!

I like red, too!

Blue is the best

But yellow is the color of school buses!

d)

Blue is the best

17.

How would you round the number held in the variable pi to 3.14?


pi = 3.14159265

a)

round(pi)

b)

round(pi, 3)

c)

round(3, pi)

d)

round(pi, 2)

18.

How would you round the number held in the variable pi to 3.14?


pi = 3.14159265

a)

round(pi)

b)

round(pi, 3)

c)

round(3, pi)

d)

round(pi, 2)

19.

What will print to the screen?


age = 5

print(type<age>)

a)

<type 'float'>

b)

<type 'int'>

c)

<type 'bool'>

d)

<type 'string'>

20.

What will the result of this code be?


x=3.141534

round(x, 4)

a)

3.142

b)

3.1415

c)

3.14153

d)

3.1416

21.

What will the result of this code be?


var = True and True


print(var)

a)

True

b)

False

c)

var

d)

none of these

22.

What is the result of this code?

a)

8

b)

8

9

10

c)

8

9

10

11

d)

8

11

e)

8

10

23.

What is the result of this code?

a)

Issue Driver's License

b)

Almost eligible for Driver's License

c)

No requirements met.

d)

none of these

24.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
25.

If you want to test more than one condition (chained condition), what do you use after if statement?

a)

elif

b)

else

c)

ifif

d)

else if

26.

Data type mund të jetë vetëm true or false

a)

int

b)

string

c)

boolean

d)

float

e)

String

27.

Cili karakter duhet të jetë në fund të rreshtit nëse (if) ?

a)

:

b)

;

c)

.

d)

{

28.

Çfarë do të shtypet në ekran kur të ekzekutohet kodi i mëposhtëm?

name = "Bob"

if (name == "Bob"):

print ("Hello" + name)

else:

print ("I don't know you")

a)

nothing

b)

HelloBob

c)

Hello Bob

I don't know you

d)

Hello Bob

29.

Çfarë do të shtypet në ekran kur të ekzekutohet kodi i mëposhtëm?


secret = 50

if (secret == 100):

print("Excellent")

elif (secret < 75):

print("Awesome")

else:

print("Super")

a)

nothing

b)

Excellent

c)

Awesome

d)

Super

30.

Çfarë do të shtypet në ekran kur të ekzekutohet kodi i mëposhtëm?


favColor = "green"

if (favColor != "green"):

print("No green")

else:

print("Green")

a)

Green

b)

No green

c)

E pamundur të tregohet nga informacioni i dhënë

d)

favColor