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



# Create a Python program that:
def main():
# Prompts the user to enter their age
age = int(input("Enter your age: "))

# Checks if the age is greater than or equal to 18
if age >= 18:
print("You are eligible to vote")
else:
print("You are not eligible to vote.")


# - Prompts a user to enter their age.
# - Uses a conditional statement to check if the age is greater than or equal to 18.
# - Prints "You are eligible to vote" if true, otherwise "You are not eligible to vote."
if __name__ == "__main__":
main()
15 changes: 10 additions & 5 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ def fibonacci(n):
Returns:
A list containing the Fibonacci sequence up to n terms.
"""
if n <= 1:
# Complete here
if n <= 0:
return fibonacci_sequence
elif n == 1:
fibonacci_sequence.append(0)
else:
a, b = # complete here
fibonacci_sequence.extend([0, 1])
a, b = 0, 1
for _ in range(2, n + 1):
c = a + b
# Complete here
return # add the variable to be returned
fibonacci_sequence.append(c)
a,b = b, c
return fibonacci_sequence

# Get the number of terms from the user
num_terms = int(input("Enter the number of terms: "))
Expand All @@ -33,6 +37,7 @@ def fibonacci(n):
print(fibonacci_sequence)



# Your program should:

# Ask the user to input the value of n.
Expand Down