
Linda M.
asked 12/05/20PYTHON QUESTION
Write a python program using a function to prompt the user for a score between 1 and 100. If the score is out of range, print an error message and exit. If the score is between 0 and 100, print a grade using the table below. Create a function called gradecalculation that takes a score as its parameter and returns a grade as a string.
Score | Grade |
>= 90 | A |
>= 80 | B |
>= 70 | C |
>= 60 | D |
< 60 | F |
1 Expert Answer

Patrick B. answered 12/05/20
Math and computer tutor/teacher
# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
print("Hello world")
def input_Grade():
grade=-1
while int(grade)<0 or int(grade)>100:
grade=input("Input grade :>")
return(grade)
def gradeCalculation(grade):
letterGrade="?"
if int(grade)<60: letterGrade="F"
elif int(grade)<70: letterGrade="D"
elif int(grade)<80: letterGrade="C"
elif int(grade)<90: letterGrade="B"
else: letterGrade="A"
return(letterGrade)
grade = input_Grade()
print(gradeCalculation(grade))

Hoan T.
If you are making sure that the grade is within range of 0-100, might as well make sure the input is not malformed (chars, etc) using try except.12/07/20
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
source code uploaded to RESOURCES section12/05/20