Skip to content
Open
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
33 changes: 26 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
return [0, 1, 1]
"""
def fibonacci(n: int) -> list[int]:

return []
if n <= 0:
return [] #negative or zero return empty list
fib = [0,1] # starting with the first two numbers
while len(fib) < n: # generating a sequence until n terms
fib.append(fib[-1] + fib[-2])
return fib[:n] #slice in case n is equal to 1 so we only return [0]


"""
Expand All @@ -25,7 +29,11 @@ def fibonacci(n: int) -> list[int]:
return [2, 4, 8, 22, 50, 98]
"""
def even(nums: list[int]) -> list[int]:
return []
evens = []
for num in nums:
if num % 2 == 0:
evens.append(num)
return sorted(even)


"""
Expand All @@ -37,8 +45,11 @@ def even(nums: list[int]) -> list[int]:
return [27, 17, 3, 1]
"""
def odd(nums: list[int]) -> list[int]:

return []
odds =[]
for num in nums:
if num % 2 != 0:
odds.append(num)
return sorted(odds, reverse = True)


"""
Expand All @@ -54,6 +65,11 @@ def odd(nums: list[int]) -> list[int]:
sum(odd) = 4, sum(even) = 2 → returns 'Odd'
"""
def even_vs_odd(nums: list[int]) -> str:
# I think I’ll need to loop through the list and separate even and odd numbers.
# Then I can find the sum of all even numbers and the sum of all odd numbers.
# After that, I can use conditionals to compare which sum is greater.
# If both sums are the same, I should return "Tie".
# Still trying to figure out the best way to handle empty lists and edge cases.
return ""


Expand All @@ -71,7 +87,7 @@ def even_vs_odd(nums: list[int]) -> str:
"""
def is_prime(n):
return False

#I'm still learning about ValueError and hot to handle it and check prime numbers

"""
This function takes in a fullname, short year,
Expand All @@ -86,4 +102,7 @@ def is_prime(n):
- Look at the pattern of the example carefully.
"""
def generate_email(fullname: str, year: str, campus: str) -> str:
return ""
# I think this one will require string slicing and using parts of the first
# and last name. I noticed the examples take some letters from both names.
# Still figuring out how to pattern-match it correctly.
return ""