Write a function called sequence_ab which takes 3 input parameters a, b and N and returns...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function called sequence_ab which takes 3 input parameters a, b and N and returns a Python list [x0, x1,...,xN] of length N + 1 representing the recursive sequence хо 1, x 1 1, Xn+2 = axn+1 + bxn For example, if a = b = 1 and N = 5 then the function returns the partial Fibonacci sequence [1,1,2,3,5,8]. [ ]: # YOUR CODE HERE = []: "Check function returns correct datatype. (1 mark)" assert type (sequence_ab (1,1,5)) == list "Return value should be a list." print("Problem 2 Test 1: Success!") [ ]: "Check function returns a list of the correct length. (1 mark)" assert len(sequence_ab(1,-1,23)) == 24, "Return value should be a list of length 24." print("Problem 2 Test 2: Success!") []: "Check function returns correct values. (1 mark)" assert sequence_ab(1,1,5) == [1,1,2,3,5,8], "Return value should be [1,1,2,3,5,8] when a=b=1 and N=5." print("Problem 2 Test 3: Success!") []: "Check function returns correct values. This cell contains hidden tests. (2 marks)" assert sequence_ab (1,-1,5): == [1,1,0,-1,-1,0], "Return value should be [1,1,0,-1,-1,0] when a=1, b=-1 and N=5.' print("Problem 2 Test 4: Success!") 11 Write a function called sequence_ab which takes 3 input parameters a, b and N and returns a Python list [x0, x1,...,xN] of length N + 1 representing the recursive sequence хо 1, x 1 1, Xn+2 = axn+1 + bxn For example, if a = b = 1 and N = 5 then the function returns the partial Fibonacci sequence [1,1,2,3,5,8]. [ ]: # YOUR CODE HERE = []: "Check function returns correct datatype. (1 mark)" assert type (sequence_ab (1,1,5)) == list "Return value should be a list." print("Problem 2 Test 1: Success!") [ ]: "Check function returns a list of the correct length. (1 mark)" assert len(sequence_ab(1,-1,23)) == 24, "Return value should be a list of length 24." print("Problem 2 Test 2: Success!") []: "Check function returns correct values. (1 mark)" assert sequence_ab(1,1,5) == [1,1,2,3,5,8], "Return value should be [1,1,2,3,5,8] when a=b=1 and N=5." print("Problem 2 Test 3: Success!") []: "Check function returns correct values. This cell contains hidden tests. (2 marks)" assert sequence_ab (1,-1,5): == [1,1,0,-1,-1,0], "Return value should be [1,1,0,-1,-1,0] when a=1, b=-1 and N=5.' print("Problem 2 Test 4: Success!") 11
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
write an essay about four seasons hotels answer below questions: (2000 words needed) - Critically discuss the key important factors and forces in the general and industry environments that affect the...
-
They are planning to take on Canada again - they will have to play better. What do we call this type of growth?
-
A particular mathematics textbook measures 8.5 inches by 11 inches by 1.5 inches. How many of these textbooks can be placed into a shipping box that measures 12 inches by 12 inches by 6 inches? How...
-
On average, which group of borrowers would have to pay a higher effective rate for its short-term loans, those who are required to put up collateral or those who are not? Explain.
-
All electron with initial kinetic energy 5.0eV encounters a barrier with height U0 and width .060 nm. What is the transmission coefficient if (a) U0 = 7.0eV; (b) U0 = 9.0eV; (c) U0 = 13.0eV?
-
An educator believes that new reading activities in the classroom will help elementary school pupils improve their reading ability. She recruits 44 third-grade students and randomly assigns them into...
-
Consider the property valuation data found in Table B.4. a. Use the all-possible-regressions method to find the "best" set of regressors. b. Use stepwise regression to select a subset regression...
-
Assume the following facts for Munoz Company in 2016. Munoz reported pretax financial income of $ 800,000. In addition, Munoz reported the following differences between its pretax financial income...
-
(a) Identify and describe current trends or socio-economic situations in the marketing an environment that will influence consumers to adopt or not adopt this product in the near future, in the next...
-
1) You are using a 2252 thermistor, = 3940, and you measure a resistance of 672.5 ohms. What is the temperature in C that you are measuring? 2)Suppose we include the lead resistance in the...
-
Ursula owns a strata lot in a residential development. The square footage of her lot is 1,250 sq. ft. and the total square footage of the other 22 strata lots is 27,550 sq. ft. The common property...
-
How is a correction made to an electronic health record? Multiple Choice A second entry is made under the original incorrect entry and both are viewable at the same time. The incorrect entry is...
-
In 2022, Keith rode in a vanpool to work. Keith's employer paid Keith $5,000 for Keith's participation in the vanpool. The vanpool was a qualified transportation fringe benefit provided by Keith's...
-
7 Installment sales and accrued revenues are subtracted from pretax accounting income (GAAP income) when figuring taxable income because 1 point We must reverse the revenue amounts that are part of...
-
A marketing database contains: Group of answer choices transactions and interactions individuals have with a firm. information about current customers and customers of the competition. customer...
-
Contribution Margin is the difference between sales and variable expenses. Net income is the difference between contribution margin and fixed expenses. Since in both the cases that is continue and...
-
How many types of colling system it transformers?
-
Compare and contrast licensing and subcontracting.
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
Carl and Jenny adopt a Russian orphan. The adoption takes 2 years and two trips to Russia and is final in 2012. They pay $6,000 in 2011 and $7,500 in 2012 of qualified adoption expenses, and have AGI...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-7. Ivan sold the following securities during the year and received a Form 1099-B that...
-
(a) Among 880 smart phones sold by a retailer, 72 required repairs under the warranty. Estimate the probability that a new phone, which has just been sold, will require repairs under the warranty....
-
A car rental agency has 19 compact cars and 12 intermediate-size cars. If four of the cars are randomly selected for a safety check, what is the probability of getting two of each kind?
-
With reference to Exercise 3.34, suppose that the questionnaire filled in by one of the 150 persons is to be double-checked. If it is chosen in such a way that each questionnaire has a probability of...
Study smarter with the SolutionInn App