Akansha Yadav builds a Python function that generates the first n Fibonacci numbers using a while loop. She initializes a=0 and b=1, appends each value to a list, then updates both variables each iteration. Running it with n=10 produces the first ten Fibonacci numbers.
Chapters
Let's create a Python program to generate a Fibonacci series. So here I am creating a function Fibonacci series, and then I am creating empty list fib series, and then we set a and b variable, initializing a as a 0 and b as 1, then creating a while loop that continues until the length of fib series becomes equal to n. Then I'm— for the each iteration of the loop, we are appending the value of a into the fib series list. Then we are updating a and b value to prepare for the next iteration. The new value of a becomes the previous value of b, and the new value of b becomes the previous value of a and b. Then from the list, I am returning it as a Fibonacci series, then printing it out. With the value 10, we are getting the Fibonacci series of