Write the Python code of a program that reads a student’s mark for a single subject, and prints out the corresponding grade for that mark. The mark ranges and corresponding grades are shown in the table below. You need to make sure that the mark is valid. For example, a student cannot receive -5 or 110 marks. So, the valid marks range is 0 to 100.
mark = int(input())
if mark < 0 or mark > 100:
print("mark is invalid")
else:
if mark < 60:
print("F")
elif mark < 70:
print("D")
elif mark < 80:
print("C")
elif mark < 90:
print("B")
else:
print("A")
Comments
Leave a comment