viking_the_red

Untitled

Oct 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. #I start by putting my if/else statements inside my function
  2. def computegrade(Grade):
  3.   if Grade>=0.9 and Grade<=1.0:
  4.     print("A")
  5.   elif Grade>=0.8 and Grade<=0.89:
  6.     print("B")
  7.   elif Grade>=0.7 and Grade<=0.79:
  8.     print("C")
  9.   elif Grade>=0.6 and Grade<=0.69:
  10.     print("D")
  11.   elif Grade>=0.0 and Grade<=0.6:
  12.     print("F")
  13.   else:
  14.     print ("Bad Score")
  15.   return Grade
  16. # I then set up my loop, which has the function near the top
  17. # I also define the value "Score"
  18. while True:
  19.   Score=int
  20.   if Score=='quit':
  21.     print("Thanks for using the grade calculation program!")
  22.     quit()
  23.   computegrade(Score)
  24.   try:
  25.     Score=float(input("Enter score or type 'quit' to exit: "))
  26.   except:
  27.     print("Bad grade")
Advertisement
Add Comment
Please, Sign In to add comment