Skip to Main Content
Blog

Calculate Student Grade in Python

Calculate Student Grade in Python

def main():
	"""
	Finds the grade of a student from their score.
	"""

	score = int(input("Enter score: "))

	grade: str
	if score >= 90:
		grade = "A"
	elif score >= 80:
		grade = "B"
	elif score >= 70:
		grade = "C"
	elif score >= 60:
		grade = "D"
	else:
		grade = "F"

	print(f"Grade: {grade}")


if __name__ == "__main__":
	main()