Advertisement
Guest User

Final Grade Calculator Python

a guest
Feb 7th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.80 KB | None | 0 0
  1. constant = 1
  2. firstrun = True
  3. def intro():
  4.     print ""
  5.     print "this program will tell you what grade you can"
  6.     print "get on the final and still keep a certian letter grade."
  7.     print ""
  8.  
  9. def inter():
  10.     print ""
  11.     print "Do you want to calculate your grade again. (y,n)"
  12.  
  13. def start():
  14.     print ""
  15.     print "What grade do you have in the class"
  16.        
  17.     grade = input( ">" ) # Getting the input of the grade
  18.     grade2 = grade*0.8   # The final is worth 20% of your grade, thus the .8
  19.  
  20.     # The if else function here will tell you what score you can get on the final and
  21.     # keep an A in the class. If the result is zero,
  22.     # then you will get AT LEAST that grade
  23.     print "For an A"       
  24.     if (89.55-grade2)/20<0:
  25.         print ( "0" )
  26.     else: print (((89.55-grade2)/20)*100)
  27.  
  28.     print "for a B"
  29.     if (79.55-grade2)/20<0:
  30.         print ( "0" )
  31.     else: print (((79.55-grade2)/20)*100)
  32.        
  33.     print "for a C"
  34.     if (69.55-grade2)/20<0:
  35.         print ( "0" )
  36.     else: print (((69.55-grade2)/20)*100)
  37.        
  38.     print "for a D"
  39.     if (59.55-grade2)/20<0:
  40.         print ( "0" )
  41.     else: print (((59.55-grade2)/20)*100)
  42.     print "NOTE- if there is a 0 or a number over 100 displayed on the grade,"
  43.     print "that means that you can not get that grade"
  44.  
  45.  
  46.  
  47.  
  48. while constant == 1:
  49.     if firstrun == True:
  50.         intro()
  51.         start()
  52.         firstrun = False # sets the variable to false so it will go to the else on the next run
  53.         inter()
  54.         # I was having some trouble with the repeting scrips not asking if you wanted
  55.         # to calculate the grade again and would just give you a promp for it. so I added
  56.         # another function that did ask
  57.        
  58.     else:
  59.         answer = raw_input ( ">" ) # dont forget to add a raw_input, it can be very frusterating when you dont.
  60.         if answer == "y":
  61.             start()
  62.             print ""
  63.             print "Do you want to calculate your grade again.(y,n)"
  64.            
  65.         else:
  66.             exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement