Question: written in python thank you Part 1- In Lab Assignments (Due end of this lab session) (20 Points) The following code produces the first 10
written in python thank you
Part 1- In Lab Assignments (Due end of this lab session) (20 Points) The following code produces the first 10 integers in the Fibonacci sequence a=b=1 fib-numbers a,b=b, a + b 1 [a] = 4 fib_numbers.append (a) 6 fib_numbers.append (a) s fib_numbers. append(a) a,b=b, a + b a,b=b, a + b a,b=b, a + b o fib_numbers.append(a) 11 a,b=b, a + b 12 fib_numbers.append(a,) 13 a,b=b, a + b 14 fib_numbers.append (a) 15 a,b=b, a + b 16 fib_numbers. append(a,) 17 a,b=b, a + b 18 fib_ ) 19 a,b=b, a + b 20 fib_numbers.append(a,) numbers.append(a 21 22 print fib_numbers Output: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] Write a generator called Fib that produces Fibonacci numbers. Your generator should accept a parameter named end that specifies how many numbers will be produced before throwing a StopIteration exception. Use your generator with a for-loop to print the first 20 numbers in the Fibonacci sequence to the reen. For example: for i in Fib(20): print
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
