Coding basics · 3 of 20
Score to letter grade
Turn a score from 0 to 100 into a grade: 90 and above is "A", 80–89 "B", 70–79 "C", 60–69 "D", below 60 "F".
Jump to the editor ↓What you need
elif ("else if") is checked only when everything above it was false, and else catches whatever's left. Exactly one branch runs.
if temp >= 30:
return "hot"
elif temp >= 15:
return "mild"
else:
return "cold"Examples
Input score = 95
Output "A"
Input score = 72
Output "C"
Input score = 59
Output "F"
Just under the D band.