Oct-27-2018, 03:46 AM
Wow! Thank you guys for your help! Unfortunately, I am running into another problem. When I type in letters other than "Quit" it is suppose to say "Bad Score" but I am getting this error:
Traceback (most recent call last):
File "/tmp/sessions/375e0408eaad1508/main.py", line 23, in <module>
if float(score) > 1.0:
ValueError: could not convert string to float: 'perfect'
I thought the try and except was suppose to take care of that...
Here is my new code so far:
Traceback (most recent call last):
File "/tmp/sessions/375e0408eaad1508/main.py", line 23, in <module>
if float(score) > 1.0:
ValueError: could not convert string to float: 'perfect'
I thought the try and except was suppose to take care of that...
Here is my new code so far:
# if letters are entered instead of numbers, #program will send "Bad Score" to user and # ask user to "Enter score or type 'Quit' to exit". try: score = input("Enter score or type 'Quit' to exit: ") except: print("Bad score.") def computegrade(score): return grade while True: # if "Quit" is entered by user, # "Thanks for using the grade calculation program!" will print and # end the program. if score == "Quit": print("Thanks for using the grade calculation program!") quit() # if a number is entered that is larger than 1.0, program will # send "Bad Score" to user and ask the user "Enter score or type # 'Quit' to end program". if float(score) > 1.0: print("Bad score.") score = input("Enter score or type 'Quit' to exit: ") # if number entered is equal to 1.0 or in between 1.0 and 0.9 it # will print "A" elif float(score) == 1.0 or float(score) >= 0.9: grade = ("A") print("A") score = input("Enter score or type 'Quit' to exit: ") # if number entered is equal to 0.89 or in between 0.89 and 0.8 it # will print "B" elif float(score) == 0.89 or float(score) >= 0.8: grade = ("B") print("B") score = input("Enter score or type 'Quit' to exit: ") # if number entered is equal to 0.79 or in between 0.79 and 0.7 it # will print "C" elif float(score) == 0.79 or float(score) >= 0.7 : grade = ("C") print("C") score = input("Enter score or type 'Quit' to exit: ") # if number entered is equal to 0.69 or in between 0.69 and 0.6 it # will print "D" elif float(score) == 0.69 or float(score) >= 0.6: grade = ("D") print("D") score = input("Enter score or type 'Quit' to exit: ") # if number entered is less than 0.6 it will print "F" elif float(score) < 0.6: grade = ("F") print("F") score = input("Enter score or type 'Quit' to exit: ") # if "Quit" is entered by user, # "Thanks for using the grade calculation program!" will print and # end the program. if score == "Quit": print("Thanks for using the grade calculation program!") quit() print(computegrade(score))