aspect=['My age is 15','I like to play basketball','I am 7 foot 2 inches tall', 'I like to eat food']
def recursion(index):
if(index==4):
return
else:
print(aspect[index])
recursion(index+1)
recursion(0)
#2
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))
# We need 2 terminating statements in this case since the first 2 numbers are suppose to be the base numbers and cannot be based on previous terms as normally in the fibbonacci sequence since there aren't enough numbers before it.
0
1
1
2
3
5
8
13
Notes
- Iteration is repetetion of a step in an algorithim
- Looping is an important concept of Iteration which is repeating a different step with for/while loops
-Functions
- Parameters in different functions
- Recursion is calling a function on itself