From fccbc74c7b522d5f05d230928dd14fb63b2cbec1 Mon Sep 17 00:00:00 2001 From: Kelvin Mwanyumba Date: Tue, 19 Mar 2024 10:34:27 +0300 Subject: [PATCH] initial commit --- conditions.py | 8 +++++++- functions.py | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/conditions.py b/conditions.py index 1499e63..f0e89d7 100644 --- a/conditions.py +++ b/conditions.py @@ -2,8 +2,14 @@ #example is https://plpacademy.powerlearnproject.org/course-module/62fbec9d28ac4762bc524f92/week/62fe1efd28ac4762bc524f9c/lesson/62fe1fbd28ac4762bc524f9f - +age = int (input("Please Enter your age: ")) +if age > 18: + print("You are eligible to vote") +elif age == 18: + print("You just turned 18, you can vote") # Create a Python program that: +else: + print("You are not eligible") # - Prompts a user to enter their age. diff --git a/functions.py b/functions.py index 0d458e4..9de20ba 100644 --- a/functions.py +++ b/functions.py @@ -13,21 +13,22 @@ def fibonacci(n): A list containing the Fibonacci sequence up to n terms. """ if n <= 1: - # Complete here - else: - a, b = # complete here + return n # Complete here + else: + a,b = 0,1 +# complete here for _ in range(2, n + 1): - c = a + b - # Complete here - return # add the variable to be returned + a, b = b, a + b +# Complete here + return b # add the variable to be returned # Get the number of terms from the user -num_terms = int(input("Enter the number of terms: ")) +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(i) for i in range(num_terms)] + + # Print the Fibonacci sequence print(fibonacci_sequence)