Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified __pycache__/main.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/test_main.cpython-310.pyc
Binary file not shown.
58 changes: 38 additions & 20 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
add_numbers(-1, 4) -> 3
"""
def add_numbers(a, b):
pass
return a + b


# Exercise 2: Subtract Numbers
Expand All @@ -23,7 +23,7 @@ def add_numbers(a, b):
subtract_numbers(3, 5) -> -2
"""
def subtract_numbers(a, b):
pass
return a - b


# Exercise 3: FruitLoop
Expand All @@ -42,7 +42,15 @@ def subtract_numbers(a, b):
Loop
"""
def fruitloop(n):
pass
for i in range(1, n+1):
if i % 3 == 0 and i % 5 != 0:
print("Fruit")
elif i % 5 == 0 and i % 3 != 0:
print("Loop")
elif i % 3 == 0 and i % 5 == 0:
print("FruitLoop")
else:
print(i)


# Exercise 4: Fibonacci
Expand All @@ -54,7 +62,11 @@ def fruitloop(n):
fibonacci(7) -> 13
"""
def fibonacci(n: int):
pass
if n <= 0:
return 0
if n == 1:
return 1
return fibonacci(n-1) + fibonacci(n-2)


# Exercise 5: Find Maximum
Expand All @@ -66,7 +78,11 @@ def fibonacci(n: int):
find_max([-1,-5,-3]) -> -1
"""
def find_max(numbers: list):
pass
# ordered = sorted(numbers)
# max = ordered[-1]
if len(numbers) < 1:
return None
return max(numbers)


# Exercise 6: Find Minimum
Expand All @@ -78,7 +94,9 @@ def find_max(numbers: list):
find_min([-1,-5,-3]) -> -5
"""
def find_min(numbers: list):
pass
if len(numbers) < 1:
return None
return min(numbers)


# Exercise 7: Person Class
Expand All @@ -98,10 +116,11 @@ 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
return f"Hello, my name is {self.name} and I am {self.age} years old."



Expand All @@ -110,15 +129,14 @@ def greet(self):
# 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
"""

# 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