subject
World Languages, 16.07.2021 19:40 princessa15266

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.

ansver
Answers: 2

Other questions on the subject: World Languages

image
World Languages, 26.06.2019 00:30, eduardavezdemel
Is this inappropriate language,”maybe i would have actually done my homework”?
Answers: 2
image
World Languages, 26.06.2019 01:00, niescarlosj
Lisha’s teacher usually includes lots of comments on student tests to them understand why their answers were incorrect.
Answers: 1
image
World Languages, 26.06.2019 06:00, gavincoscarat760
Why does my answers to questions keep getting deleted by the same person?
Answers: 2
image
World Languages, 27.06.2019 19:00, SMURFETTE86
Check if my essay is correct 15 points" i dont know much " my frist language is
Answers: 1
You know the right answer?
Def find_fib(n): if n <= 2:
return 1

fib_x, fib_next = 1, 1

i = 3<...

Questions in other subjects:

Konu
Social Studies, 25.12.2019 04:31
Konu
Mathematics, 25.12.2019 04:31
Konu
Mathematics, 25.12.2019 04:31