From 69667a1964aff6f82d6a108e1cf7099b112a2575 Mon Sep 17 00:00:00 2001 From: Zethu Sanelisiwe Msomi Date: Wed, 5 Nov 2025 12:59:14 +0200 Subject: [PATCH] tried test --- __pycache__/main.cpython-310.pyc | Bin 1339 -> 1894 bytes __pycache__/test_main.cpython-310.pyc | Bin 2502 -> 2495 bytes main.py | 89 ++++++++++++++++++-------- 3 files changed, 61 insertions(+), 28 deletions(-) diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc index e1eec8c12f9815c0a7ab2608bdbbed033e132050..d0ff50d8e4c201e9d3b04b5f9c2753a79f35c397 100644 GIT binary patch literal 1894 zcmah}S&JJ-5bo|dH9D+pyqAgNj*SyfvIl!O4RxlpYX@mRO?%7d{^ssye-Z2G4pw@ye5y4(D)y$!<5TTjeoXPKk+(P+l zmQ#FzoB$MkyQQFU$rLsztZ&pX%BL3c=J#nj@L6F1z6yNn0Y5|W}_9@nKihgtje5QRC&a5S`#~*dlBv?toTT z!aW95l~NF6>JSy*-7UeGEjx?1DMQ1ck}OU?Q0~ z$8aLerkE`psFYjSFJLgFNns{oEDIytmtAb4`9dB`_Y8K1B^}c-3E=kz3J&(l-~qQ! zK&Ku7@r}aFWWRSVxt356L`jqf!3i40ux;qT(XBF)jk)#`Xb2IuyN&}977)izjG|a6qch zkgOp&ud?QF-YBfxFR(Kkh)Wh|&D65OY=?0;#rA6X^}-1Pk#>VXk3T($^sifbz~7-T z`w_Uj53KH$(g=I8r3b`~{tNfZGJz)ucZOk_mg{&XGiS8nHkjRTU63@K+Bt1_PLuu% DKeSp9 literal 1339 zcma)5OK;Oa5Z<+&_|YUy%liQG0U;u_ji4YQgsMt_I8jyfmdncVZc>YQH>}s{oBa$4`Gv-1a>3XKE;tBI282`Y zT#x|`33s^%ngd#cH$ihj^MyBZc)-I8Z_ofc5>2qzcnfU5w%fb|b`X+Jgs=1N1>xNv z&LHF)N2IrTK8(HyQ)*en=2*l_pMW(waN;qc=*YlTK z@oq2P-iu%V=h}X;6~C%{yHV=EbC!fU1%40w+XKPL5t-408JRhjCYBC0mZ1`Vp7xJb zF8U`X?dL)orTd>%`gMDHW{#EY=Se1are}8TQci7z#TXvd0eo(atuYCWC+G1nm4A`7 z52o!F<ovSl*K3}2ILd}fCTW_zsgXONS%1;DRnccuuit5elSwYDn~X(@ zHCqzux3sS3TCWh3k-iIO^gR^UsvR(v$;>du(TTHhzCI7Pv-GT5nI6^mZ-~$sYaz_I zhHow4tKSDb-$DxbFve`eSgv?ELA}M;w=$V5JZ@pMbu(%70|a__HBR*=9C>{QL<(Fq zK?G!zw%qF9K`*jCJW{2MRf|<^fUYL?FLCl3RZ`)!Mk~$dsz44 U2?(zd_|BX=PNM^Q%^k1v7vsR^C;$Ke diff --git a/__pycache__/test_main.cpython-310.pyc b/__pycache__/test_main.cpython-310.pyc index f1e95ec998bcad818b2d7f84a71838bb6f02e699..69cde65a6f3209cdec88815c324929d69219520c 100644 GIT binary patch delta 36 qcmX>mykD3*pO=@50SGD-xi@kvGjS>DXXNLm>X(-!Z?X(-!>*uECmE;#~wqR;!2LRu53y1&! diff --git a/main.py b/main.py index 2719019..91e5d86 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,10 @@ add_numbers(-1, 4) -> 3 """ def add_numbers(a, b): - pass + answer = a + b + print(answer) + +add_numbers(3,7) # Exercise 2: Subtract Numbers @@ -23,7 +26,10 @@ def add_numbers(a, b): subtract_numbers(3, 5) -> -2 """ def subtract_numbers(a, b): - pass + answer = a - b + print(answer) + +subtract_numbers(10, 3) # Exercise 3: FruitLoop @@ -42,19 +48,38 @@ def subtract_numbers(a, b): Loop """ def fruitloop(n): - pass + for i in n: + if int(i) % 3 == 0: + print("Fruit") + if int(i) % 5 == 0: + print("Loop") + else: + print(i) + +# if i % 3 == 0: +# i.replace(i, "Fruit") +# else: +# print(i) + +fruitloop("123456") + + # Exercise 4: Fibonacci """ Returns the nth Fibonacci number (0-indexed: 0,1,1,2,3,5...). + Example: fibonacci(5) -> 5 fibonacci(7) -> 13 """ def fibonacci(n: int): - pass + numbers = [0,1,1,2,3,5,8,13,21] + print(numbers[n]) + +fibonacci(7) # Exercise 5: Find Maximum @@ -66,7 +91,10 @@ def fibonacci(n: int): find_max([-1,-5,-3]) -> -1 """ def find_max(numbers: list): - pass + for i in numbers: + if i : + print(i) +find_max([1,2,3,4,5]) # Exercise 6: Find Minimum @@ -78,7 +106,10 @@ def find_max(numbers: list): find_min([-1,-5,-3]) -> -5 """ def find_min(numbers: list): - pass + for i in numbers: + if i : + print(i) +find_min([1,2,3,4,5]) # Exercise 7: Person Class @@ -98,27 +129,29 @@ def find_min(numbers: list): """ class Person: def __init__(self, name: str, age: int): - pass + self.name = name + self.age = age def greet(self): - pass - - - - - -# Example usage (can be removed or commented out during testing) -# This part is just for demonstration and won't be executed during tests. -# Remove docstrings to see how the functions and class work. -""" -if __name__ == "__main__": - # Example usage (can be removed or commented out during testing) - print(add_numbers(2, 3)) # Should print 5 - print(subtract_numbers(5, 3)) # Should print 2 - fruitloop(15) # Should print numbers and words as per the rules - print(fibonacci(10)) # Should print 55 - print(find_max([1, 2, 3, 4, 5])) # Should print 5 - print(find_min([1, 2, 3, 4, 5])) # Should print 1 - p = Person("Alice", 25) - print(p.greet()) # Should print greeting message -""" + f"Hello, my name is {self.name} and I am {self.age} years old." +P1 = Person("Zama", 25) +print(P1.greet()) + + + + +# # Example usage (can be removed or commented out during testing) +# # This part is just for demonstration and won't be executed during tests. +# # Remove docstrings to see how the functions and class work. +# """ +# if __name__ == "__main__": +# # Example usage (can be removed or commented out during testing) +# print(add_numbers(2, 3)) # Should print 5 +# print(subtract_numbers(5, 3)) # Should print 2 +# fruitloop(15) # Should print numbers and words as per the rules +# print(fibonacci(10)) # Should print 55 +# print(find_max([1, 2, 3, 4, 5])) # Should print 5 +# print(find_min([1, 2, 3, 4, 5])) # Should print 1 +# p = Person("Alice", 25) +# print(p.greet()) # Should print greeting message +# """