Python Forum
I keep getting errors and I'm lost!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I keep getting errors and I'm lost!
#6
You have been awesome! Thank you again for the tips! I'm so close! The only thing that is happening now is that when I type in Quit it says "Bad Score".

Here is my new code:
def computegrade(score):
    return grade

while True:
# 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 = float(input("Enter score or type 'Quit' to exit: "))
  except:
    print("Bad score.")
    
    continue
# if "Quit" is entered by user, 
# "Thanks for using the grade calculation program!" will print and 
# end the program.  
  if float(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".    
  elif float(score) > 1.0:
      print("Bad score.")
      
      
# 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")
      

# 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")
      

# 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")
      
  
# 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")
      

# if number entered is less than 0.6 it will print "F"
  elif float(score) < 0.6:
      grade = ("F")
      print("F")
      
# 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))
Reply


Messages In This Thread
RE: I keep getting errors and I'm lost! - by samjonsnell - Oct-27-2018, 04:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I am completely lost on this homework assignment a36 1 1,841 Feb-21-2022, 06:01 AM
Last Post: buran
  Very Lost vollynez 3 1,953 Oct-02-2020, 09:09 PM
Last Post: Yoriz
  I got lost in the program Gadev 1 1,934 Nov-11-2018, 05:50 PM
Last Post: j.crater
  test..and I'm already lost sannixinc 1 2,572 Feb-22-2018, 09:09 PM
Last Post: glidecode
  Completly lost about to fail my class! crakacheezy 7 4,718 Dec-28-2017, 11:50 PM
Last Post: mepyyeti

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020