diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc index e1eec8c..d0ff50d 100644 Binary files a/__pycache__/main.cpython-310.pyc and b/__pycache__/main.cpython-310.pyc differ diff --git a/__pycache__/test_main.cpython-310.pyc b/__pycache__/test_main.cpython-310.pyc index f1e95ec..69cde65 100644 Binary files a/__pycache__/test_main.cpython-310.pyc and b/__pycache__/test_main.cpython-310.pyc differ 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 +# """