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, 22.06.2019 04:30, lilybear1700
Pronunciation /”r\i: s@nt/ audio (us) adjective 1. having happened a short while ago. 2. up-to-date, not old-fashioned or dated. derived terms recently recent memory anagrams center, centre, centre, tenrec
Answers: 1
image
World Languages, 24.06.2019 11:30, markrandsdenn
What was a problem faced by many newly independent african countries
Answers: 2
image
World Languages, 25.06.2019 02:00, ceciliaxo
Read the sentences. i absolutely detest when people interrupt others who are speaking. it shows a lack of good manners and consideration for the thoughts and words of others. many people need to listen more and talk less. why did the author most likely choose to use the word detest as opposed to the word "dislike"? to more strongly convey his feelings about those who interrupt to more strongly illustrate his solution to stop those who interrupt to more accurately describe how he wants the reader to react to more accurately create a visual of those who interrupt others
Answers: 1
image
World Languages, 26.06.2019 00:30, angelearlyp9ynm9
How i can have a strong character in the drama class , people me
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, 04.10.2021 07:50
Konu
Business, 04.10.2021 07:50