Ifs Work Sheet
By Mickey Arnold
starstarstarstarstarstarstarstarstarstar
Last updated 10 months ago
5 Questions
1 point
1
Question 1
1.
What is the output?
fred = 80if fred < 0: fred = 500else: fred = fred – 10print(fred)
What is the output?
fred = 80
if fred < 0:
fred = 500
else:
fred = fred – 10
print(fred)
1 point
1
Question 2
2.
If the left arrow key is pressed, what is the output?
alice= 250if event.key == K_RIGHT: alice= alice+ 25elif event.key == K_LEFT: alice= alice- 25print(alice)
If the left arrow key is pressed, what is the output?
alice= 250
if event.key == K_RIGHT:
alice= alice+ 25
elif event.key == K_LEFT:
alice= alice- 25
print(alice)
1 point
1
Question 3
3.
What is the output?
bob= 100if bob> 400 and bob< 600: print("Center")elif bob<= 400: print("Left")else: print("Right")
What is the output?
bob= 100
if bob> 400 and bob< 600:
print("Center")
elif bob<= 400:
print("Left")
else:
print("Right")
1 point
1
Question 4
4.
What is the output?grade = 85if grade >= 70: print("Pass")else: print("Fail")
What is the output?
grade = 85
if grade >= 70:
print("Pass")
else:
print("Fail")
1 point
1
Question 5
5.
What is the output?
speed = 70speedLimit = 60if speed > speedLimit: print("Speeding")else: if speed > 40: print("Driving")else: print("Driving slowly")
What is the output?
speed = 70
speedLimit = 60
if speed > speedLimit:
print("Speeding")
else:
if speed > 40:
print("Driving")
else:
print("Driving slowly")