Skip to content

Commit f820218

Browse files
authored
Update time&half-pay.py
1 parent 23685d6 commit f820218

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: financial/time&half-pay.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
Calculate time and a half pay
33
44
"""
5-
def pay(hours_worked, pay_rate, hours = 40):
5+
def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float:
66
"""
77
hours_worked = The total hours worked
88
pay_rate = Ammount of money per hour
99
hours = Number of hours that must be worked before you recieve time and a half
1010
"""
11+
12+
# Check that all input parameters are float or integer
13+
assert (type(hours_worked) == float or type(hours_worked) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'"
14+
assert (type(pay_rate) == float or type(pay_rate) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'"
15+
assert (type(hours) == float or type(hours) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'"
16+
1117
normal_pay = hours_worked * pay_rate
1218
over_time = hours_worked - hours
1319
# Another way

0 commit comments

Comments
 (0)