def find_fib(n):
if n <= 2:
return 1
fib_x, fib_next = 1, 1
i = 3
while i <= n:
i += 1
fib_x, fib_next = fib_next, fib_x + fib_next
return fib_next
def list_fib(n):
fib_list = [1, 1]
if n <= 2:
return fib_list[:n]
fib_x, fib_next = 1, 1
i = 3
while i <= n:
i += 1
fib_x, fib_next = fib_next, fib_x + fib_next
fib_list.append(fib_next)
return fib_list
for x in range(1, 11):
print(find_fib(x))
print(list_fib(1))
print(list_fib(2))
print(list_fib(10))
The python file needs to be modified in such a way that when the file is imported as a module, it does not show the prints at the end of the file, but when the file is run directly, it shows the prints.