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

Another question on World Languages

question
World Languages, 24.06.2019 05:30
Which factors threaten the forests of north america?
Answers: 1
question
World Languages, 26.06.2019 04:50
Escoger select the item that does not belong. la tiza la pluma la papelera la geografía el libro la economía la materia la especialización la librería la residencia estudiantil la casa la tarea la pizarra la especialización el mapa el semestre la contabilidad el español diagnostics_number_6 en la clase fill in the blanks with the appropriate form of estar. ¿dónde (1) nosotros en la clase
Answers: 1
question
World Languages, 27.06.2019 06:00
Importance of language sensitivity in journalism
Answers: 1
question
World Languages, 29.06.2019 01:00
Adjectives should always use de 的 after the word, as in shūfu de 舒服的, regardless of how it's used.true or false
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
question
Social Studies, 04.11.2020 18:20
question
Spanish, 04.11.2020 18:20
question
Physics, 04.11.2020 18:20
question
Mathematics, 04.11.2020 18:20
question
Mathematics, 04.11.2020 18:20
Questions on the website: 13722359