Saturday, June 22, 2024

📑 Global Variables in Lambda Functions

📑 Task

1) What object does this specific function modify and
what will the code print when the mini program runs?
2) Change this code snippet so that: a) the function can be used to generate Fibonacci sequences
independently, without relying on a global state
b) it returns only the n-st number of the sequence

📑 Answer

1) The function changes the global variable with
the initial value "empty list" by iterative appending
The result of the launch is a printout of a list
(the first ten numbers of the Fibonacci series)
2)

No comments:

Post a Comment