Skip to content

python grading system #8896

@fawwazwasique

Description

@fawwazwasique

What would you like to share?

def calculate_grade(score):
if score >= 90:
return 'A+'
elif score >= 80:
return 'A'
elif score >= 70:
return 'B'
elif score >= 60:
return 'C'
elif score>=50:
return 'D'
else:
return 'Fail'

Test the grading system

try:
score = float(input("Enter the numeric score: "))
if 0 <= score <= 100:
grade = calculate_grade(score)
print(f"The letter grade for the score {score} is: {grade}")
else:
print("Invalid score. Please enter a number between 0 and 100.")
except ValueError:
print("Invalid input. Please enter a valid numeric score.")

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting triageAwaiting triage from a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions