Back to questions
JuniorTheoryCommon
What does the program print?
score = 85
if score > 50:
print("C")
elif score > 80:
print("A")C
- Expecting
A, as if Python picked the closest condition: it checks them top to bottom, andscore > 50is true first, so onlyCprints. - Expecting both
CandA: once one branch of anif/elifchain runs, the rest are skipped, even when their conditions are also true.
- How would you reorder the conditions so that
85printsA? - What would print if
elifwere replaced with a secondif?