MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / pay

Function pay

financial/time_and_half_pay.py:6–33  ·  view source on GitHub ↗

hours_worked = The total hours worked pay_rate = Amount of money per hour hours = Number of hours that must be worked before you receive time and a half >>> pay(41, 1) 41.5 >>> pay(65, 19) 1472.5 >>> pay(10, 1) 10.0

(hours_worked: float, pay_rate: float, hours: float = 40)

Source from the content-addressed store, hash-verified

4
5
6def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float:
7 """
8 hours_worked = The total hours worked
9 pay_rate = Amount of money per hour
10 hours = Number of hours that must be worked before you receive time and a half
11
12 >>> pay(41, 1)
13 41.5
14 >>> pay(65, 19)
15 1472.5
16 >>> pay(10, 1)
17 10.0
18 """
19 # Check that all input parameters are float or integer
20 assert isinstance(hours_worked, (float, int)), (
21 "Parameter 'hours_worked' must be of type 'int' or 'float'"
22 )
23 assert isinstance(pay_rate, (float, int)), (
24 "Parameter 'pay_rate' must be of type 'int' or 'float'"
25 )
26 assert isinstance(hours, (float, int)), (
27 "Parameter 'hours' must be of type 'int' or 'float'"
28 )
29
30 normal_pay = hours_worked * pay_rate
31 over_time = max(0, hours_worked - hours)
32 over_time_pay = over_time * pay_rate / 2
33 return normal_pay + over_time_pay
34
35
36if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected