vendredi 18 octobre 2019

How to fix a problem when user-defining goes wrong

I am completely new to programming, now im struggling on a little program where the "grade" wont get defined. Thank you

I tried return grade but it wont work anyway

def computegrade(score,grade):
     try:
        if score >1.0001:
            grade= print("invalid score")
        elif score < -0.0001:
            grade= print("invalid score")
        elif score >= 0.9:
            grade= print("A")
        elif score >= 0.8:
            grade= print("B")
        elif score >= 0.7:
            grade= print("C")
        elif score >= 0.6:
            grade= print("D")
        elif score < 0.6:
            grade= print("F")
    except:
        print("Invalid")
    return grade

score=input("Enter your Score(between 0.0-1.0)\n")
grade=computegrade(score,grade)

Please fix the problem that "grade" gets defined correctly.Thanks :)

Aucun commentaire:

Enregistrer un commentaire