-
Notifications
You must be signed in to change notification settings - Fork 2
/
ex04-06.py
31 lines (28 loc) · 775 Bytes
/
ex04-06.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# https://www.py4e.com/html3/04-functions
#
# Exercise 6: Rewrite your pay computation with time-and-a-half for overtime and
# create a function called computepay which takes two parameters (hours and rate)
#
# Enter Hours: 45
# Enter Rate: 10
# Pay: 475.0
# ===============================================================================
def computepay(hours, rate):
otrate = rate * 1.5
if hours <= 40:
pay = hours * rate
else:
pay = (40*rate)+(hours-40)*otrate
return pay
try:
hours = input("Enter Hours:")
hours = float(hours)
hours >= 0
rate = input("Enter Rate:")
rate = float(rate)
rate >= 0
except:
print("Error, please enter numeric input")
quit()
wages = computepay(hours, rate)
print("Pay:",wages)