From 23685d69a9f4b55236e8724143150fd8eee2476a Mon Sep 17 00:00:00 2001 From: Samuel Willis <109305646+konsoleSam@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:07:07 -0600 Subject: [PATCH 01/12] Create time&half-pay.py --- financial/time&half-pay.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 financial/time&half-pay.py diff --git a/financial/time&half-pay.py b/financial/time&half-pay.py new file mode 100644 index 000000000000..5811d4a755b4 --- /dev/null +++ b/financial/time&half-pay.py @@ -0,0 +1,24 @@ +""" +Calculate time and a half pay + +""" +def pay(hours_worked, pay_rate, hours = 40): + """ + hours_worked = The total hours worked + pay_rate = Ammount of money per hour + hours = Number of hours that must be worked before you recieve time and a half + """ + normal_pay = hours_worked * pay_rate + over_time = hours_worked - hours + # Another way + # over_time_pay = ((over_time * ((over_time + (over_time ** 2) ** 0.5) / (2 * over_time))) / 2) * pay_rate + over_time_pay = (max(0, over_time) / 2) * pay_rate + total_pay = normal_pay + over_time_pay + return total_pay + + +if __name__ == "__main__": + # Test + print(pay(41, 1)) + print(pay(65, 19)) + print(pay(10, 1)) From f82021810321f4c18304df9c0de73dd5ebdbbd11 Mon Sep 17 00:00:00 2001 From: Samuel Willis <109305646+konsoleSam@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:23:42 -0600 Subject: [PATCH 02/12] Update time&half-pay.py --- financial/time&half-pay.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/financial/time&half-pay.py b/financial/time&half-pay.py index 5811d4a755b4..c4ea8810cddf 100644 --- a/financial/time&half-pay.py +++ b/financial/time&half-pay.py @@ -2,12 +2,18 @@ Calculate time and a half pay """ -def pay(hours_worked, pay_rate, hours = 40): +def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: """ hours_worked = The total hours worked pay_rate = Ammount of money per hour hours = Number of hours that must be worked before you recieve time and a half """ + + # Check that all input parameters are float or integer + assert (type(hours_worked) == float or type(hours_worked) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'" + assert (type(pay_rate) == float or type(pay_rate) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'" + assert (type(hours) == float or type(hours) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'" + normal_pay = hours_worked * pay_rate over_time = hours_worked - hours # Another way From 0e3d294c2fd5f786fee6710a872de9222073b036 Mon Sep 17 00:00:00 2001 From: Samuel Willis <109305646+konsoleSam@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:35:03 -0600 Subject: [PATCH 03/12] Update time&half-pay.py --- financial/time&half-pay.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/financial/time&half-pay.py b/financial/time&half-pay.py index c4ea8810cddf..8c5a3f59065e 100644 --- a/financial/time&half-pay.py +++ b/financial/time&half-pay.py @@ -7,8 +7,13 @@ def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: hours_worked = The total hours worked pay_rate = Ammount of money per hour hours = Number of hours that must be worked before you recieve time and a half + >>> pay(41, 1) + 41.5 + >>> pay(65, 19) + 1472.5 + >>> pay(10, 1) + 10.0 """ - # Check that all input parameters are float or integer assert (type(hours_worked) == float or type(hours_worked) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'" assert (type(pay_rate) == float or type(pay_rate) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'" @@ -25,6 +30,5 @@ def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: if __name__ == "__main__": # Test - print(pay(41, 1)) - print(pay(65, 19)) - print(pay(10, 1)) + import doctest + doctest.testmod() From 4bed076d6f60e19aa9a6ab385773bd2376de1386 Mon Sep 17 00:00:00 2001 From: Samuel Willis <109305646+konsoleSam@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:37:12 -0600 Subject: [PATCH 04/12] Rename time&half-pay.py to time_and_half_pay.py --- financial/{time&half-pay.py => time_and_half_pay.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename financial/{time&half-pay.py => time_and_half_pay.py} (100%) diff --git a/financial/time&half-pay.py b/financial/time_and_half_pay.py similarity index 100% rename from financial/time&half-pay.py rename to financial/time_and_half_pay.py From 38f1ad5bbcd59d837b2fb5d47a41288202afb789 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 02:40:34 +0000 Subject: [PATCH 05/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- financial/time_and_half_pay.py | 59 ++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/financial/time_and_half_pay.py b/financial/time_and_half_pay.py index 8c5a3f59065e..6cfc83b598ce 100644 --- a/financial/time_and_half_pay.py +++ b/financial/time_and_half_pay.py @@ -2,33 +2,42 @@ Calculate time and a half pay """ + + def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: - """ - hours_worked = The total hours worked - pay_rate = Ammount of money per hour - hours = Number of hours that must be worked before you recieve time and a half - >>> pay(41, 1) - 41.5 - >>> pay(65, 19) - 1472.5 - >>> pay(10, 1) - 10.0 - """ - # Check that all input parameters are float or integer - assert (type(hours_worked) == float or type(hours_worked) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'" - assert (type(pay_rate) == float or type(pay_rate) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'" - assert (type(hours) == float or type(hours) == int), "Parameter 'hours_worked' must be of type 'int' or 'float'" + """ + hours_worked = The total hours worked + pay_rate = Ammount of money per hour + hours = Number of hours that must be worked before you recieve time and a half + >>> pay(41, 1) + 41.5 + >>> pay(65, 19) + 1472.5 + >>> pay(10, 1) + 10.0 + """ + # Check that all input parameters are float or integer + assert type(hours_worked) == float or type(hours_worked) == int, ( + "Parameter 'hours_worked' must be of type 'int' or 'float'" + ) + assert type(pay_rate) == float or type(pay_rate) == int, ( + "Parameter 'hours_worked' must be of type 'int' or 'float'" + ) + assert type(hours) == float or type(hours) == int, ( + "Parameter 'hours_worked' must be of type 'int' or 'float'" + ) - normal_pay = hours_worked * pay_rate - over_time = hours_worked - hours - # Another way - # over_time_pay = ((over_time * ((over_time + (over_time ** 2) ** 0.5) / (2 * over_time))) / 2) * pay_rate - over_time_pay = (max(0, over_time) / 2) * pay_rate - total_pay = normal_pay + over_time_pay - return total_pay + normal_pay = hours_worked * pay_rate + over_time = hours_worked - hours + # Another way + # over_time_pay = ((over_time * ((over_time + (over_time ** 2) ** 0.5) / (2 * over_time))) / 2) * pay_rate + over_time_pay = (max(0, over_time) / 2) * pay_rate + total_pay = normal_pay + over_time_pay + return total_pay if __name__ == "__main__": - # Test - import doctest - doctest.testmod() + # Test + import doctest + + doctest.testmod() From a811d58a5cbd99ceaaa6ed428bc23f13cc4795ce Mon Sep 17 00:00:00 2001 From: Samuel Willis <109305646+konsoleSam@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:47:34 -0600 Subject: [PATCH 06/12] Update time_and_half_pay.py --- financial/time_and_half_pay.py | 59 ++++++++++++++-------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/financial/time_and_half_pay.py b/financial/time_and_half_pay.py index 6cfc83b598ce..06b34fe718f8 100644 --- a/financial/time_and_half_pay.py +++ b/financial/time_and_half_pay.py @@ -2,42 +2,33 @@ Calculate time and a half pay """ - - def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: - """ - hours_worked = The total hours worked - pay_rate = Ammount of money per hour - hours = Number of hours that must be worked before you recieve time and a half - >>> pay(41, 1) - 41.5 - >>> pay(65, 19) - 1472.5 - >>> pay(10, 1) - 10.0 - """ - # Check that all input parameters are float or integer - assert type(hours_worked) == float or type(hours_worked) == int, ( - "Parameter 'hours_worked' must be of type 'int' or 'float'" - ) - assert type(pay_rate) == float or type(pay_rate) == int, ( - "Parameter 'hours_worked' must be of type 'int' or 'float'" - ) - assert type(hours) == float or type(hours) == int, ( - "Parameter 'hours_worked' must be of type 'int' or 'float'" - ) + """ + hours_worked = The total hours worked + pay_rate = Ammount of money per hour + hours = Number of hours that must be worked before you recieve time and a half + >>> pay(41, 1) + 41.5 + >>> pay(65, 19) + 1472.5 + >>> pay(10, 1) + 10.0 + """ + # Check that all input parameters are float or integer + assert (type(hours_worked) is float or type(hours_worked) is int), "Parameter 'hours_worked' must be of type 'int' or 'float'" + assert (type(pay_rate) is float or type(pay_rate) is int), "Parameter 'hours_worked' must be of type 'int' or 'float'" + assert (type(hours) is float or type(hours) is int), "Parameter 'hours_worked' must be of type 'int' or 'float'" - normal_pay = hours_worked * pay_rate - over_time = hours_worked - hours - # Another way - # over_time_pay = ((over_time * ((over_time + (over_time ** 2) ** 0.5) / (2 * over_time))) / 2) * pay_rate - over_time_pay = (max(0, over_time) / 2) * pay_rate - total_pay = normal_pay + over_time_pay - return total_pay + normal_pay = hours_worked * pay_rate + over_time = hours_worked - hours + # Another way + """over_time_pay = ((over_time * ((over_time + (over_time ** 2) ** 0.5) / (2 * over_time))) / 2) * pay_rate""" + over_time_pay = (max(0, over_time) / 2) * pay_rate + total_pay = normal_pay + over_time_pay + return total_pay if __name__ == "__main__": - # Test - import doctest - - doctest.testmod() + # Test + import doctest + doctest.testmod() From c4be33ee44ee204f93af9468d9d26f556f5f175d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 02:47:57 +0000 Subject: [PATCH 07/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- financial/time_and_half_pay.py | 59 ++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/financial/time_and_half_pay.py b/financial/time_and_half_pay.py index 06b34fe718f8..8b6c78599767 100644 --- a/financial/time_and_half_pay.py +++ b/financial/time_and_half_pay.py @@ -2,33 +2,42 @@ Calculate time and a half pay """ + + def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: - """ - hours_worked = The total hours worked - pay_rate = Ammount of money per hour - hours = Number of hours that must be worked before you recieve time and a half - >>> pay(41, 1) - 41.5 - >>> pay(65, 19) - 1472.5 - >>> pay(10, 1) - 10.0 - """ - # Check that all input parameters are float or integer - assert (type(hours_worked) is float or type(hours_worked) is int), "Parameter 'hours_worked' must be of type 'int' or 'float'" - assert (type(pay_rate) is float or type(pay_rate) is int), "Parameter 'hours_worked' must be of type 'int' or 'float'" - assert (type(hours) is float or type(hours) is int), "Parameter 'hours_worked' must be of type 'int' or 'float'" + """ + hours_worked = The total hours worked + pay_rate = Ammount of money per hour + hours = Number of hours that must be worked before you recieve time and a half + >>> pay(41, 1) + 41.5 + >>> pay(65, 19) + 1472.5 + >>> pay(10, 1) + 10.0 + """ + # Check that all input parameters are float or integer + assert type(hours_worked) is float or type(hours_worked) is int, ( + "Parameter 'hours_worked' must be of type 'int' or 'float'" + ) + assert type(pay_rate) is float or type(pay_rate) is int, ( + "Parameter 'hours_worked' must be of type 'int' or 'float'" + ) + assert type(hours) is float or type(hours) is int, ( + "Parameter 'hours_worked' must be of type 'int' or 'float'" + ) - normal_pay = hours_worked * pay_rate - over_time = hours_worked - hours - # Another way - """over_time_pay = ((over_time * ((over_time + (over_time ** 2) ** 0.5) / (2 * over_time))) / 2) * pay_rate""" - over_time_pay = (max(0, over_time) / 2) * pay_rate - total_pay = normal_pay + over_time_pay - return total_pay + normal_pay = hours_worked * pay_rate + over_time = hours_worked - hours + # Another way + """over_time_pay = ((over_time * ((over_time + (over_time ** 2) ** 0.5) / (2 * over_time))) / 2) * pay_rate""" + over_time_pay = (max(0, over_time) / 2) * pay_rate + total_pay = normal_pay + over_time_pay + return total_pay if __name__ == "__main__": - # Test - import doctest - doctest.testmod() + # Test + import doctest + + doctest.testmod() From 2d56591107cf30015350d6d3cf3e66e6f517cc74 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Fri, 18 Apr 2025 02:26:56 +0300 Subject: [PATCH 08/12] Update time_and_half_pay.py --- financial/time_and_half_pay.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/financial/time_and_half_pay.py b/financial/time_and_half_pay.py index 8b6c78599767..6b715a598faa 100644 --- a/financial/time_and_half_pay.py +++ b/financial/time_and_half_pay.py @@ -1,6 +1,5 @@ """ Calculate time and a half pay - """ @@ -9,6 +8,7 @@ def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: hours_worked = The total hours worked pay_rate = Ammount of money per hour hours = Number of hours that must be worked before you recieve time and a half + >>> pay(41, 1) 41.5 >>> pay(65, 19) @@ -17,23 +17,20 @@ def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: 10.0 """ # Check that all input parameters are float or integer - assert type(hours_worked) is float or type(hours_worked) is int, ( + assert isinstance(hours_worked, float) or isinstance(hours_worked, int) ( "Parameter 'hours_worked' must be of type 'int' or 'float'" ) - assert type(pay_rate) is float or type(pay_rate) is int, ( - "Parameter 'hours_worked' must be of type 'int' or 'float'" + assert isinstance(pay_rate, float) or isinstance(pay_rate, int) ( + "Parameter 'pay_rate' must be of type 'int' or 'float'" ) - assert type(hours) is float or type(hours) is int, ( - "Parameter 'hours_worked' must be of type 'int' or 'float'" + assert isinstance(hours, float) or isinstance(hours, int) ( + "Parameter 'hours' must be of type 'int' or 'float'" ) normal_pay = hours_worked * pay_rate - over_time = hours_worked - hours - # Another way - """over_time_pay = ((over_time * ((over_time + (over_time ** 2) ** 0.5) / (2 * over_time))) / 2) * pay_rate""" - over_time_pay = (max(0, over_time) / 2) * pay_rate - total_pay = normal_pay + over_time_pay - return total_pay + over_time = max(0, hours_worked - hours) + over_time_pay = over_time * pay_rate / 2 + return normal_pay + over_time_pay if __name__ == "__main__": From 3be7257f6c3e742f898e1fcb1a8fe05cd3cbce2d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 23:27:19 +0000 Subject: [PATCH 09/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- financial/time_and_half_pay.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/financial/time_and_half_pay.py b/financial/time_and_half_pay.py index 6b715a598faa..db409b5ce29a 100644 --- a/financial/time_and_half_pay.py +++ b/financial/time_and_half_pay.py @@ -17,13 +17,13 @@ def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: 10.0 """ # Check that all input parameters are float or integer - assert isinstance(hours_worked, float) or isinstance(hours_worked, int) ( + assert isinstance(hours_worked, float) or isinstance(hours_worked, int)( "Parameter 'hours_worked' must be of type 'int' or 'float'" ) - assert isinstance(pay_rate, float) or isinstance(pay_rate, int) ( + assert isinstance(pay_rate, float) or isinstance(pay_rate, int)( "Parameter 'pay_rate' must be of type 'int' or 'float'" ) - assert isinstance(hours, float) or isinstance(hours, int) ( + assert isinstance(hours, float) or isinstance(hours, int)( "Parameter 'hours' must be of type 'int' or 'float'" ) From b8bc5828bd193b95fe8ca5a3ef81089261d80fb7 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Fri, 18 Apr 2025 02:27:59 +0300 Subject: [PATCH 10/12] Update time_and_half_pay.py --- financial/time_and_half_pay.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/financial/time_and_half_pay.py b/financial/time_and_half_pay.py index db409b5ce29a..707e1d15994e 100644 --- a/financial/time_and_half_pay.py +++ b/financial/time_and_half_pay.py @@ -17,13 +17,13 @@ def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: 10.0 """ # Check that all input parameters are float or integer - assert isinstance(hours_worked, float) or isinstance(hours_worked, int)( + assert isinstance(hours_worked, float) or isinstance(hours_worked, int), ( "Parameter 'hours_worked' must be of type 'int' or 'float'" ) - assert isinstance(pay_rate, float) or isinstance(pay_rate, int)( + assert isinstance(pay_rate, float) or isinstance(pay_rate, int), ( "Parameter 'pay_rate' must be of type 'int' or 'float'" ) - assert isinstance(hours, float) or isinstance(hours, int)( + assert isinstance(hours, float) or isinstance(hours, int), ( "Parameter 'hours' must be of type 'int' or 'float'" ) From 339052ea6b74819e2c0ac19323d8d6e0d596431f Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Fri, 18 Apr 2025 02:30:31 +0300 Subject: [PATCH 11/12] Update time_and_half_pay.py --- financial/time_and_half_pay.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/financial/time_and_half_pay.py b/financial/time_and_half_pay.py index 707e1d15994e..2b726e3c8512 100644 --- a/financial/time_and_half_pay.py +++ b/financial/time_and_half_pay.py @@ -17,13 +17,13 @@ def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: 10.0 """ # Check that all input parameters are float or integer - assert isinstance(hours_worked, float) or isinstance(hours_worked, int), ( + assert isinstance(hours_worked, (float, int)), ( "Parameter 'hours_worked' must be of type 'int' or 'float'" ) - assert isinstance(pay_rate, float) or isinstance(pay_rate, int), ( + assert isinstance(pay_rate, (float, int)), ( "Parameter 'pay_rate' must be of type 'int' or 'float'" ) - assert isinstance(hours, float) or isinstance(hours, int), ( + assert isinstance(hours, (float, int)), ( "Parameter 'hours' must be of type 'int' or 'float'" ) From c71a5aea5f04c6f2baedfd9c8ae9ce0d7c77e76a Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Fri, 18 Apr 2025 02:31:39 +0300 Subject: [PATCH 12/12] Update time_and_half_pay.py --- financial/time_and_half_pay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/financial/time_and_half_pay.py b/financial/time_and_half_pay.py index 2b726e3c8512..c5dff1bc1ce1 100644 --- a/financial/time_and_half_pay.py +++ b/financial/time_and_half_pay.py @@ -6,8 +6,8 @@ def pay(hours_worked: float, pay_rate: float, hours: float = 40) -> float: """ hours_worked = The total hours worked - pay_rate = Ammount of money per hour - hours = Number of hours that must be worked before you recieve time and a half + 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