0
grade = 0.0
grade = input("Please enter your gpa")
    def grade_give(grade):
        if grade > 0.9:
            print("A")  
        elif grade > 0.8 and grade < 0.9 :
            print("B")
        elif grade >0.7 and grade < 0.8:
            print ("C")
        elif grade >0.6 and grade <0.7:
            print ("D")
        elif grade >0.5 and grade <0.6:
            print ("E")
        elif grade >0.4 and grade <0.3:
           print ("F")
        else:
           print("Bad score")

grade_give(grade)

The error which appears is File "/Users/pradyu/Desktop/py.py/function.py", line 4, in grade_give if grade > 0.9: TypeError: '>' not supported between instances of 'str' and 'float'

1 Answer 1

1

The input from input is a string . Convert it to float.

grade = input("Please enter your gpa")
grade = float(grade)
#carry on

or do this in the function

def func(grade):
    grade = float(grade)
    .
    .
    .
Sign up to request clarification or add additional context in comments.

2 Comments

raw_input is not used at all in the code in the question. input in Python 3.x returns a string.
sorry, python-2.7 you know :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.