Advertisement
Guest User

Untitled

a guest
Sep 27th, 2011
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. # Exercise 4.7
  2.  
  3. def computescore(scr):
  4.     if scr >= 0.9 :
  5.         print 'Grade: A'
  6.     elif scr >= 0.8 :
  7.         print 'Grade: B'
  8.     elif scr >= 0.7 :
  9.         print 'Grade: C'
  10.     elif scr >= 0.6 :
  11.         print 'Grade: D'
  12.     else:
  13.         print 'Grade: F'
  14.  
  15. try:
  16.     scr = float(raw_input('Please enter a number between 0.0 and 1.0. \n'))
  17.     if (scr > 1.0 or scr < 0.0):
  18.         print 'Please enter a valid number.'
  19.         quit()
  20. except:
  21.     print 'Please enter a number.'
  22.     quit()
  23.  
  24. grade = computescore(scr)
  25.  
  26. print grade
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement