World Languages
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.

answer
Answers: 2

Other questions on the subject: World Languages

image
World Languages, 24.06.2019 18:00, zmeister
Write tow things you think must be difficult about being an actor and two things you think must be enjoyable?
Answers: 1
image
World Languages, 25.06.2019 04:00, 1969976289
What's jordan? is jordan a nice country?
Answers: 1
image
World Languages, 25.06.2019 17:30, nickonicyetlan
It’s ok to use materials without referencing them as long as they’re paraphrased in your own words. a. false b. true c. sometimes d. depends
Answers: 1
image
World Languages, 26.06.2019 07:00, cbkhm
After swimming for hours he was tired what is the personal pronoun in the sentence below
Answers: 1
Do you know the correct answer?
Def find_fib(n): if n <= 2:
return 1

fib_x, fib_next = 1, 1

i = 3<...

Questions in other subjects:

Konu
Mathematics, 10.11.2019 05:31