viking_the_red

Untitled

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