check score >= 90? print(\grade a\)\ncheck score >= 80? \naction taken \nscore: 92\ncheck score >= 90…

check score >= 90? print(\grade a\)\ncheck score >= 80? \naction taken \nscore: 92\ncheck score >= 90? print(\grade a\)\naction taken: (note stops here!)\nscore: 58\ncheck score >= 90? \ncheck score >= 80? \ncheck score >= 70? \ncheck score >= 60? \naction taken: \ncomplete this table:\nscore final grade explanation\n95 \n85 \n73 \n67 \n42 \npractice exercise 6: traffic light logic\nwrite an elif chain for a traffic light system:\nif light is \red\ print \stop\\nif light is \yellow\ print \slow down\\nif light is \green\ print \go\\nif light is anything else print \light malfunction\\npython\nlight_color = partner provides: \red\, \yellow\, \green\, or \blue\
Answer
Explanation:
Step1: Determine grades based on score ranges
For scores ≥ 90, grade is 'A'; for 80 ≤ score < 90, grade is 'B'; for 70 ≤ score < 80, grade is 'C'; for 60 ≤ score < 70, grade is 'D'; for score < 60, grade is 'F'.
Step2: Evaluate scores one - by - one
For score = 95, since 95 ≥ 90, grade is 'A'. For score = 85, since 80 ≤ 85 < 90, grade is 'B'. For score = 73, since 70 ≤ 73 < 80, grade is 'C'. For score = 67, since 60 ≤ 67 < 70, grade is 'D'. For score = 42, since 42 < 60, grade is 'F'.
Step3: Write Python code for traffic light logic
light_color = input("Enter the traffic light color (red, yellow, green, or blue): ")
if light_color == "red":
print("Stop")
elif light_color == "yellow":
print("Slow down")
elif light_color == "green":
print("Go")
else:
print("Light malfunction")
Answer:
| Score | Final Grade | Explanation |
|---|---|---|
| 95 | A | Score is ≥ 90 |
| 85 | B | 80 ≤ Score < 90 |
| 73 | C | 70 ≤ Score < 80 |
| 67 | D | 60 ≤ Score < 70 |
| 42 | F | Score < 60 |
light_color = input("Enter the traffic light color (red, yellow, green, or blue): ")
if light_color == "red":
print("Stop")
elif light_color == "yellow":
print("Slow down")
elif light_color == "green":
print("Go")
else:
print("Light malfunction")