Advertisement
Guest User

Untitled

a guest
Sep 18th, 2011
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. # Exercise 3.1 / 3.2
  2. # Asking for input to calculate weekly pay and to calculate overtime when
  3. # working more than 40 hours.
  4.  
  5. try:
  6.     hrs = float(raw_input('How many hours did you work this week? \n'))
  7.     rate = float(raw_input('What is your rate? \n'))
  8.     otrate = 1.5
  9.     othrs = hrs - 40
  10.     ot = float(rate * 40 + rate * otrate * (othrs))
  11.  
  12. except:
  13.     print 'Please enter a number.'
  14.     quit()
  15.    
  16. if hrs <= 40 :
  17.     wpay = float(hrs*rate)
  18.     print 'Pay: ', wpay
  19.  
  20. else:
  21.     otpay = float(rate * otrate * othrs)
  22.     print 'Pay: ', ot
  23.     print 'Included overtime pay: ', otpay , '\n'
  24.  
  25. # Exercise 3.3
  26. # Grade scores based on input. Write errors of input if out of range.
  27.  
  28. try:
  29.     scr = float(raw_input('Please enter a number between 0.0 and 1.0. \n'))
  30.     if (scr > 1.0 or scr < 0.0):
  31.         print 'Please enter a valid number'
  32.         quit()
  33. except:
  34.     print 'Please enter a number.'
  35.     quit()
  36.  
  37. if scr >= 0.9 :
  38.     print 'Grade: A'
  39. elif scr >= 0.8 :
  40.     print 'Grade: B'
  41. elif scr >= 0.7 :
  42.     print 'Grade: C'
  43. elif scr >= 0.6 :
  44.     print 'Grade: D'
  45. else:
  46.     print 'Grade: F'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement