Write a function called insert_name_here that takes as argument a list of integers (we'll call this...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function called insert_name_here¹ that takes as argument a list of integers (we'll call this list vals) and returns a list containing each integer in vals that is greater than the integers immediately before and after it. In the case of the first element of vals, it only needs to be greater than the element after it to be included. In the case of the last element of vals, it only needs to be greater than the element before it to be included. If vals is empty or only contains one element, then insert_name_here () should return an empty list. Below are examples of how your function should behave. >>> insert _name_here ([2,5,8,3]) [8] >>> insert_name_here ([-1,1,0,5]) [1, 5] >>> insert_name_here ([3,2,2,4]) [3, 4] >>> insert _name_here ([3,2,2,3]) [3, 3] >>> insert_name_here ([10,8, -3,70,15,22,20,19,-5]) [10, 70, 22] >>> insert _name_here ([200, 100, 300, 450, 570, 100, 120]) [200, 570, 120] Write a function called insert_name_here¹ that takes as argument a list of integers (we'll call this list vals) and returns a list containing each integer in vals that is greater than the integers immediately before and after it. In the case of the first element of vals, it only needs to be greater than the element after it to be included. In the case of the last element of vals, it only needs to be greater than the element before it to be included. If vals is empty or only contains one element, then insert_name_here () should return an empty list. Below are examples of how your function should behave. >>> insert _name_here ([2,5,8,3]) [8] >>> insert_name_here ([-1,1,0,5]) [1, 5] >>> insert_name_here ([3,2,2,4]) [3, 4] >>> insert _name_here ([3,2,2,3]) [3, 3] >>> insert_name_here ([10,8, -3,70,15,22,20,19,-5]) [10, 70, 22] >>> insert _name_here ([200, 100, 300, 450, 570, 100, 120]) [200, 570, 120]
Expert Answer:
Answer rating: 100% (QA)
python def findpeaksvals peaks for i in rangelenvals if i 0 or i 0 and valsi valsi 1 and i lenvals 1 ... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
Name three guidelines to follow when choosing or designing a slide template. What are verbal tics? Provide two examples. What three things should you do when answering a question in a presentation?...
-
Consider the following information on put and call options for Citigroup. Strike Price Put Price Call Price $32.50 $2.85 $1.65 Calculate the net value of a protective put position at a stock price at...
-
The Economic Stimulus Act of 2008 and the American Economic Recovery and Reinvestment Act of 2009 where the latest big experiments the U.S. has undertaken with large-scale fiscal stimulus. Recall...
-
The following appliances are connected to a single 120 V, 15 A circuit in a kitchen: a 330 W blender, a 1000 W coffeepot, a 150 W coffee grinder, and a 750 W microwave oven. If these are all turned...
-
Pride Parts Co. has a fiscal year ending December 31. The company completed the following selected transactions: 2013 July 2 Paid $640,000 plus $20,000 in legal fees (pertaining to all assets...
-
In each pair of molecules that follows, indicate the member of the pair that would be better suited in its indicated function for an SN2 reaction. (a) Nucleophile: NH3, PH3 (b) (c) (d) Leaving group:...
-
What format requirements must be met?
-
As part of a major renovation at the beginning of the year, Mullins Pharmacy, Inc., sold shelving units (store fixtures) that were 10 years old for $3,000 cash. The original cost of the shelves was...
-
In a catering SOR, a key performance indicator was defined as below. The SLA states "speed to serve" should be minimum 75% of the expected service level. Metric: speed to serve at the food counter...
-
There is an array A made of N integers. Your task is to choose as many integers from A as possible so that, when they are put in ascending order, all of the differences between all pairs of...
-
Provide an analysis regarding financial accounting issues about the property, plant and equipment section. ABC follows IFRS. ABC invested excess cash in raw land in 2014. ABC constructed its...
-
Your Client, a real estate agent named John Snow, has asked you to assess the tax implications of a proposed real estate transaction. Part A: Alternative I : John Snow is looking to sell real...
-
What strategic planning process does research suggest to be the best for multidivisional corporations operating in a relatively stable environment? Discuss
-
Mr. Johan owned a laundry shop, Dollah Laundry, started business on 1 March 2020. During the first month of the operation, the following events and transactions occurred. Mar 1 Started business with...
-
Assume that a no - load, open - end mutual fund holds securities with a total market value of $ 1 2 million, has no liability and has 5 0 0 , 0 0 0 shares outstanding. Calculate the net asset value...
-
The inventory records of Cushing Inc. reflected the foil owing information for the year ended December 3 1 , 2 0 1 9 : Date Transaction #of Units Unit Cost Total Cost 1 / 1 Beginning inventory. . . 2...
-
Consider a Java program that creates multiple threads and accesses shared variables. Which of the following statements about the memory model of the Java Virtual Machine (JVM) is true? a) The JVM...
-
The Adjusted Trial Balance columns of a 10-column work sheet for Webber Co. follow. Complete the work sheet by extending the account balances into the appropriate financial statement columns and by...
-
Consider the nonlinear ordinary differential equation with y(0) = 1. Estimate y(1) (a) Using the explicit Eulers method with h = 0.2 (b) Using the fourth-order RungeKutta method with h = 1. dy dx ||...
-
What are the criteria for the number of iterations such that Jacobis method is faster than Gauss elimination for solving a linear problem that is not banded?
-
What ODE is solved by the following MATLAB code and what method is used? Include the initial condition in your answer. 1 function problem4_23 2 3 4 nsteps = 100; y = 1; t = 0; h = 0.01; 5 6 g=figure;...
-
In tax year 2023-24, a landlord receives a premium of 36,000 when granting a 25-year lease to a tenant. How much of this premium is chargeable to income tax?
-
Ryan owns a dwelling house which he lets to a tenant. Rent is payable monthly in advance on the first day of each month. The rent was 600 per month until 1 January 2024, when it was increased to 650....
-
Edward has the following income in 2023-24: He makes a total of 800 of Gift Aid donations during 2023-24. Compute the amount of income tax payable for the year.
Study smarter with the SolutionInn App