WorksheetsPython conditionals Elidon Mema
Total questions: 30
Worksheet time: 18mins
Failure
What will print to the screen when the following program is run?
number = 5
greater_than_zero = number > 0
print(type(number))
5
True
<type ‘int’>
<type ‘bool’>
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)
1
1
3
5
1
4
1
4
5
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"
You are below average height
You are above average height
You are average height
You are below average height
You are above average height
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"
You are below average height
You are above average height
You are average height
You are below average height
You are above average height
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!"
But green is the color of grass!
Blue is the best
But yellow is the color of school buses!
But green is the color of grass!
But green is the color of grass!
I like red, too!
Blue is the best
But yellow is the color of school buses!
Blue is the best
How would you round the number held in the variable pi to 3.14?
pi = 3.14159265
round(pi)
round(pi, 3)
round(3, pi)
round(pi, 2)
How would you round the number held in the variable pi to 3.14?
pi = 3.14159265
round(pi)
round(pi, 3)
round(3, pi)
round(pi, 2)
What will print to the screen?
age = 5
print(type<age>)
<type 'float'>
<type 'int'>
<type 'bool'>
<type 'string'>
What will the result of this code be?
x=3.141534
round(x, 4)
3.142
3.1415
3.14153
3.1416
What will the result of this code be?
var = True and True
print(var)
True
False
var
none of these
What is the result of this code?
8
8
9
10
8
9
10
11
8
11
8
10
What is the result of this code?
Issue Driver's License
Almost eligible for Driver's License
No requirements met.
none of these
If you want to test more than one condition (chained condition), what do you use after if statement?
elif
else
ifif
else if
Data type mund të jetë vetëm true or false
int
string
boolean
float
String
Cili karakter duhet të jetë në fund të rreshtit nëse (if) ?
:
;
.
{
Ç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")
nothing
HelloBob
Hello Bob
I don't know you
Hello Bob
Ç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")
nothing
Excellent
Awesome
Super
Ç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")
Green
No green
E pamundur të tregohet nga informacioni i dhënë
favColor
