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
5 changes: 5 additions & 0 deletions conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@


# - Prompts a user to enter their age.
age = int(input("How old are you? "))
# - Uses a conditional statement to check if the age is greater than or equal to 18.
if age >= 18:
# - Prints "You are eligible to vote" if true, otherwise "You are not eligible to vote."
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
16 changes: 8 additions & 8 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ def fibonacci(n):
A list containing the Fibonacci sequence up to n terms.
"""
if n <= 1:
# Complete here
return [0, 1]
else:
a, b = # complete here
for _ in range(2, n + 1):
fibonacci_list = [0,1]
a, b = 0, 1
for _ in range(2, n):
c = a + b
# Complete here
return # add the variable to be returned
fibonacci_list.append(c)
a, b = b, c
return fibonacci_list

# Get the number of terms from the user
num_terms = int(input("Enter the number of terms: "))

# Generate the Fibonacci sequence
fibonacci_sequence = []
for i in range(num_terms):
fibonacci_sequence.append(fibonacci(i))
fibonacci_sequence = fibonacci(num_terms)

# Print the Fibonacci sequence
print(fibonacci_sequence)
Expand Down