# function of aspects of my daily routine with parameter step
def aspects_of_life(step):
activities = [
"Waking up",
"Brushing teeth",
"Taking a shower",
"Going to school",
"Coming back home",
"Eating dinner",
"Going to sleep"
]
# if step is 0, return nothing
if step == 0:
return
# whatever value step is when it is called as an argument, subtract 1
aspects_of_life(step - 1)
activity = activities[step - 1]
# if step is less than or equal to the length of the list, print activity
if step <= len(activities):
print(activity)
else:
print('Unknown activity')
# call function with parameter set equal to 6
aspects_of_life(6)
Waking up
Brushing teeth
Taking a shower
Going to school
Coming back home
Eating dinner
x = 3
def fibonacci(x):
if x==1:
return(0) # First terminating statement
if x == 2:
return(1) # Second terminating statement
else:
return(fibonacci(x-1)+ fibonacci(x-2))
for i in range(8):
print(fibonacci(i+1))
# you need two terminating statements because they are the base terms for the fibonacci sequence.
# without them, the sequence would continue forever, and result in a stack overflow error.
# the terms after the first two have no base numbers to sequence off of.
##