Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Exercise 3.1 / 3.2
- # Asking for input to calculate weekly pay and to calculate overtime when
- # working more than 40 hours.
- try:
- hrs = float(raw_input('How many hours did you work this week? \n'))
- rate = float(raw_input('What is your rate? \n'))
- otrate = 1.5
- othrs = hrs - 40
- ot = float(rate * 40 + rate * otrate * (othrs))
- except:
- print 'Please enter a number.'
- quit()
- if hrs <= 40 :
- wpay = float(hrs*rate)
- print 'Pay: ', wpay
- else:
- otpay = float(rate * otrate * othrs)
- print 'Pay: ', ot
- print 'Included overtime pay: ', otpay , '\n'
- # Exercise 3.3
- # Grade scores based on input. Write errors of input if out of range.
- try:
- scr = float(raw_input('Please enter a number between 0.0 and 1.0. \n'))
- if (scr > 1.0 or scr < 0.0):
- print 'Please enter a valid number'
- quit()
- except:
- print 'Please enter a number.'
- quit()
- if scr >= 0.9 :
- print 'Grade: A'
- elif scr >= 0.8 :
- print 'Grade: B'
- elif scr >= 0.7 :
- print 'Grade: C'
- elif scr >= 0.6 :
- print 'Grade: D'
- else:
- print 'Grade: F'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement