Lesson 4: Grades using if ... elif ...

posted Oct 27, 2017, 7:59 AM by Attila Lengyel
total = input("How many questions total?:")
answered = input("Correct answers:")

score = (int(answered) / int(total))  * 100
print (score, "%")

grade = "F"

if score == 100:
  grade = "A+"
elif score >= 94:
  grade = "A"
elif score >= 90:
  grade = "A-"
elif score >= 87:
  grade = "B+"
elif score >= 84:
  grade = "B"
elif score >= 80:
  grade = "B-"
elif score >= 77:
  grade = "C+"
elif score >= 74:
  grade = "C"
elif score >= 70:
  grade = "C-"
elif score >= 67:
  grade = "D+"
elif score >= 64:
  grade = "D"
elif score >= 60:
  grade = "D-"

print("Your grade is:",grade)


Comments