From fcc10ffb6c724dbd301f26e6b12a46483d339cfe Mon Sep 17 00:00:00 2001 From: Hubert Date: Wed, 15 Oct 2025 08:58:06 +0200 Subject: [PATCH 1/9] Addition change to float --- src/hello_world_project/example_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hello_world_project/example_module.py b/src/hello_world_project/example_module.py index b389af8..8b7150f 100644 --- a/src/hello_world_project/example_module.py +++ b/src/hello_world_project/example_module.py @@ -1,2 +1,2 @@ -def add_numbers(a: int, b: int) -> int: +def add_numbers(a: float, b: float) -> float: return a + b From 70a8d714e3e547e24a0c9c37e16b8edf0ac1edb3 Mon Sep 17 00:00:00 2001 From: Kuba Date: Wed, 22 Oct 2025 08:14:02 +0200 Subject: [PATCH 2/9] Substraction added --- src/hello_world_project/example_module.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hello_world_project/example_module.py b/src/hello_world_project/example_module.py index 8b7150f..1896fbc 100644 --- a/src/hello_world_project/example_module.py +++ b/src/hello_world_project/example_module.py @@ -1,2 +1,6 @@ def add_numbers(a: float, b: float) -> float: return a + b + +def sub_numbers(a: float, b:float) -> float: + return a - b + From 65b415d39e76443a8b6da0fccfcb78dc2996a901 Mon Sep 17 00:00:00 2001 From: Hubert Date: Wed, 22 Oct 2025 08:15:21 +0200 Subject: [PATCH 3/9] Multiplication added --- src/hello_world_project/example_module.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hello_world_project/example_module.py b/src/hello_world_project/example_module.py index 1896fbc..f9e69e9 100644 --- a/src/hello_world_project/example_module.py +++ b/src/hello_world_project/example_module.py @@ -4,3 +4,5 @@ def add_numbers(a: float, b: float) -> float: def sub_numbers(a: float, b:float) -> float: return a - b +def multiply_numbers(a: float, b: float) -> float: + return a * b \ No newline at end of file From b26a04263abb795cc8acf94624de560fceb3e0f4 Mon Sep 17 00:00:00 2001 From: Kuba Date: Wed, 22 Oct 2025 08:19:05 +0200 Subject: [PATCH 4/9] Division added --- src/hello_world_project/example_module.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hello_world_project/example_module.py b/src/hello_world_project/example_module.py index f9e69e9..d2c540c 100644 --- a/src/hello_world_project/example_module.py +++ b/src/hello_world_project/example_module.py @@ -5,4 +5,10 @@ def sub_numbers(a: float, b:float) -> float: return a - b def multiply_numbers(a: float, b: float) -> float: - return a * b \ No newline at end of file + return a * b + +def div_numbers(a: float, b: float) -> float: + if(abs(b)<0.0001): + return a / b + else: + raise Exception From 30f7f253462fba0206c5cca85b8040c185822d48 Mon Sep 17 00:00:00 2001 From: Hubert Date: Wed, 22 Oct 2025 08:41:24 +0200 Subject: [PATCH 5/9] KH SimpleCalculator Added --- src/hello_world_project/example_module.py | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/hello_world_project/example_module.py b/src/hello_world_project/example_module.py index d2c540c..ae6360a 100644 --- a/src/hello_world_project/example_module.py +++ b/src/hello_world_project/example_module.py @@ -1,14 +1,16 @@ -def add_numbers(a: float, b: float) -> float: - return a + b +class SimpleCalculator: + def add_numbers(self, a: float, b: float) -> float: + return a + b -def sub_numbers(a: float, b:float) -> float: - return a - b + def sub_numbers(self, a: float, b:float) -> float: + return a - b -def multiply_numbers(a: float, b: float) -> float: - return a * b + def multiply_numbers(self, a: float, b: float) -> float: + return a * b + + def div_numbers(self, a: float, b: float) -> float: + if(abs(b)<0.0001): + return a / b + else: + raise Exception -def div_numbers(a: float, b: float) -> float: - if(abs(b)<0.0001): - return a / b - else: - raise Exception From abdf90d5b508835d6821638e69ae401aaedd3b98 Mon Sep 17 00:00:00 2001 From: Kuba Date: Wed, 22 Oct 2025 09:23:00 +0200 Subject: [PATCH 6/9] dodano sceientific calc --- src/hello_world_project/example_module.py | 7 +++++++ src/hello_world_project/main.py | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/hello_world_project/main.py diff --git a/src/hello_world_project/example_module.py b/src/hello_world_project/example_module.py index ae6360a..ff7c7f0 100644 --- a/src/hello_world_project/example_module.py +++ b/src/hello_world_project/example_module.py @@ -13,4 +13,11 @@ def div_numbers(self, a: float, b: float) -> float: return a / b else: raise Exception + + +class ScientificCalc(SimpleCalculator): + def power_numbers(self, base, exp): + return base ** exp + def sqr_number(self, base): + return base ** 1/2 diff --git a/src/hello_world_project/main.py b/src/hello_world_project/main.py old mode 100644 new mode 100755 index c0f4cd6..0fecb22 --- a/src/hello_world_project/main.py +++ b/src/hello_world_project/main.py @@ -1,5 +1,6 @@ +#! usr/bin/python3 from hello_world_project.utils import greet_user -from hello_world_project.example_module import add_numbers +import hello_world_project.example_module def main(): print("=== Hello World Project ===") @@ -8,8 +9,9 @@ def main(): greeting = greet_user(name) print(greeting) - result = add_numbers(10, 5) + result = hello_world_project.example_module.SimpleCalculator().add_numbers(10, 5) print(f"The result of adding 10 and 5 is {result}.") +smpcal= if __name__ == "__main__": main() From 973daa25851b9069f635e060658cd37ef3625eaf Mon Sep 17 00:00:00 2001 From: Hubert Date: Wed, 22 Oct 2025 09:31:38 +0200 Subject: [PATCH 7/9] Factory Calculator added --- src/hello_world_project/example_module.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hello_world_project/example_module.py b/src/hello_world_project/example_module.py index ff7c7f0..a8a40bd 100644 --- a/src/hello_world_project/example_module.py +++ b/src/hello_world_project/example_module.py @@ -13,11 +13,13 @@ def div_numbers(self, a: float, b: float) -> float: return a / b else: raise Exception - - + class ScientificCalc(SimpleCalculator): def power_numbers(self, base, exp): return base ** exp def sqr_number(self, base): return base ** 1/2 +def FactoryCalculator(type: str): + factory = {"Simple": SimpleCalculator, "Science":ScientificCalc } + return factory[type]() \ No newline at end of file From b2844056e8e08a14a7f1decf82644d986515bad9 Mon Sep 17 00:00:00 2001 From: Kuba Date: Tue, 28 Oct 2025 20:38:08 +0100 Subject: [PATCH 8/9] main changed --- src/hello_world_project/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hello_world_project/main.py b/src/hello_world_project/main.py index 0fecb22..77d35ee 100755 --- a/src/hello_world_project/main.py +++ b/src/hello_world_project/main.py @@ -1,6 +1,6 @@ #! usr/bin/python3 -from hello_world_project.utils import greet_user -import hello_world_project.example_module +from utils import greet_user +import example_module def main(): print("=== Hello World Project ===") @@ -9,9 +9,9 @@ def main(): greeting = greet_user(name) print(greeting) - result = hello_world_project.example_module.SimpleCalculator().add_numbers(10, 5) + result = example_module.SimpleCalculator().add_numbers(10, 5) print(f"The result of adding 10 and 5 is {result}.") -smpcal= + if __name__ == "__main__": main() From 8ca8270013a939c9421b12fc2170fa7b3735d98d Mon Sep 17 00:00:00 2001 From: Kuba Date: Tue, 28 Oct 2025 21:24:13 +0100 Subject: [PATCH 9/9] Added calculator control, financial calculator, decorator and some little fixes --- src/hello_world_project/example_module.py | 37 +++++++++++++++++++---- src/hello_world_project/main.py | 20 ++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/hello_world_project/example_module.py b/src/hello_world_project/example_module.py index a8a40bd..57d8388 100644 --- a/src/hello_world_project/example_module.py +++ b/src/hello_world_project/example_module.py @@ -1,3 +1,10 @@ +from datetime import datetime +def godz_dek(func): + def wrapper(*args, **kwargs): + print(f"[{datetime.now().strftime('%H:%M:%S')}]") + return func(*args, **kwargs) + return wrapper + class SimpleCalculator: def add_numbers(self, a: float, b: float) -> float: return a + b @@ -9,17 +16,35 @@ def multiply_numbers(self, a: float, b: float) -> float: return a * b def div_numbers(self, a: float, b: float) -> float: - if(abs(b)<0.0001): + if(abs(b)>0.0001): return a / b else: raise Exception - + class ScientificCalc(SimpleCalculator): def power_numbers(self, base, exp): return base ** exp - def sqr_number(self, base): + def sqr_numbers(self, base): return base ** 1/2 -def FactoryCalculator(type: str): - factory = {"Simple": SimpleCalculator, "Science":ScientificCalc } - return factory[type]() \ No newline at end of file +class FinancialCalc(SimpleCalculator): + @godz_dek + def add_numbers(self, a: float, b: float) -> float: + return a + b + @godz_dek + def sub_numbers(self, a: float, b:float) -> float: + return a - b + @godz_dek + def multiply_numbers(self, a: float, b: float) -> float: + return a * b + @godz_dek + def div_numbers(self, a: float, b: float) -> float: + if(abs(b)>0.0001): + return a / b + else: + raise Exception + + +# def FactoryCalculator(type: str): +# factory = {"Simple": SimpleCalculator, "Science":ScientificCalc } +# return factory[type]() \ No newline at end of file diff --git a/src/hello_world_project/main.py b/src/hello_world_project/main.py index 77d35ee..ed63a77 100755 --- a/src/hello_world_project/main.py +++ b/src/hello_world_project/main.py @@ -9,6 +9,26 @@ def main(): greeting = greet_user(name) print(greeting) + calc_dict={"b":example_module.SimpleCalculator, "s":example_module.ScientificCalc, "f":example_module.FinancialCalc} + calc_s= input("Enter b for basic\n, s for scientific\n and f for financial calculator:") + calc=calc_dict[calc_s]() + while True: + if calc_s == "b": + fun_dict_1={"a":example_module.SimpleCalculator.add_numbers,"s":example_module.SimpleCalculator.sub_numbers,"m":example_module.SimpleCalculator.multiply_numbers,"d":example_module.SimpleCalculator.div_numbers} + fun_s= input("Enter a for addition, \n s for subtraction, \nm for multiplication, \nd for division") + fun=fun_dict_1[fun_s] + elif calc_s == "s": + fun_dict_2={"a":example_module.ScientificCalc.add_numbers,"s":example_module.ScientificCalc.sub_numbers,"m":example_module.ScientificCalc.multiply_numbers,"d":example_module.ScientificCalc.div_numbers,"p":example_module.ScientificCalc.power_numbers,"q":example_module.ScientificCalc.sqr_numbers} + fun_s= input("Enter a for addition, \n s for subtraction, \nm for multiplication, \nd for division, \np for power, \nq for square_root ") + fun=fun_dict_2[fun_s] + else: + fun_dict_3={"a":example_module.FinancialCalc.add_numbers,"s":example_module.FinancialCalc.sub_numbers,"m":example_module.FinancialCalc.multiply_numbers,"d":example_module.FinancialCalc.div_numbers} + fun_s= input("Enter a for addition, \n s for subtraction, \nm for multiplication, \nd for division") + fun=fun_dict_3[fun_s] + a = float(input("Enter a: ")) + b = float(input("Enter b: ")) + print(fun(calc,a,b)) + result = example_module.SimpleCalculator().add_numbers(10, 5) print(f"The result of adding 10 and 5 is {result}.")