Homework
# HW 1: Print Interests
interests = ["Volleyball", "Coding", "Reading", "Sleeping", "Eating"]
def print_interests(interests, index=0):
if index < len(interests):
print(interests[index])
print_interests(interests, index + 1)
print_interests(interests)
# HW 2: Fibonacci Sequence
def fibonacci(x):
if x == 1:
return 0 # First terminating statement: F(1) = 0
if x == 2:
return 1 # Second terminating statement: F(2) = 1
else:
# Recursive case: F(x) = F(x-1) + F(x-2)
return fibonacci(x - 1) + fibonacci(x - 2)
# Print Fibonacci numbers for the first 8 values (F(1) to F(8))
for i in range(8):
print(fibonacci(i + 1))
# HW 3 - Grading System
# Get user input for marks
marks = float(input("Enter your marks: "))
# Determine the grade based on the grading system
if marks < 25:
grade = "F"
elif 25 <= marks < 45:
grade = "E"
elif 45 <= marks < 50:
grade = "D"
elif 50 <= marks < 60:
grade = "C"
elif 60 <= marks < 80:
grade = "B"
else:
grade = "A"
# Print the corresponding grade
print(f"Your grade is: {grade}")