diff --git a/conditions.py b/conditions.py index 1499e63..00b6157 100644 --- a/conditions.py +++ b/conditions.py @@ -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() \ No newline at end of file diff --git a/functions.py b/functions.py index 0d458e4..cf730ab 100644 --- a/functions.py +++ b/functions.py @@ -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: ")) @@ -33,6 +37,7 @@ def fibonacci(n): print(fibonacci_sequence) + # Your program should: # Ask the user to input the value of n.