Question: Question 1a - Increasing Numbers in List - First Occurence(3 points) Write a function numIncreasing1(L) that takes as input a list of numbers and returns

 Question 1a - Increasing Numbers in List - First Occurence(3 points)Write a function numIncreasing1(L) that takes as input a list of numbers

Question 1a - Increasing Numbers in List - First Occurence(3 points) Write a function numIncreasing1(L) that takes as input a list of numbers and returns a list of the first sequence within that is increasing order, and has a length of at least 2. If no increasing sequential numbers are found, (ie. the input list is in descending order) then naturally a list of just the first value is returned. Increasing sequence means for a number to be valid it has to be greater than the previous. . [5, 2, 1, 3, 4] returns [1, 3, 4], because only the last 3 are in increasing order [-1, 1, 4, 2, 6) returns [-1, 1, 4] . [5, 1, 8, 9, 10, 100) returns [1, 8, 9, 10, 100] . [4, 1, 2, 3, 4, 2, 4, 6, 8] returns [1, 2, 3, 4] Hint: the break keyword may prove useful to exit a loop def numIncreasing1(L): result = [] for i in range(len(L)): if i == len(L) - 1: result.append(L[i]) else: if L[i] >= L(i + 1]: if result: result.append(L[i]) break else: result.append(L[i]) return result print("Are my sample test cases correct?") print(numIncreasing1([5, 2, 1, 3, 4]) == (1,3,4]) print(numIncreasingl ([2, 1, 4, 5, 6]) == (1,4,5,6]) print(numIncreasingl ([1,2,3,4,4,3,4,5,6,7,7]) == [1,2,3,4]) Are my sample test cases correct? True True True Question 1b: Increasing Numbers in List - Longest Streak (3 points) Now write a function numIncreasing2(L) which applies similar constraints from Question 1a except returns the longest running sequence of increasing numbers L. : def numIncreasing2(s): # your code here! return x print("Are my sample test cases correct?") print("#1", numIncreasing2([5,4,3,2,1]) == [5]) print("#2", numIncreasing2([1,2,3,4,5]) == [1,2,3,4,5) print("#3", numIncreasing2([1,2,3,4,4,3,4,5,6,7,7]) == [ 3, 4, 5, 6, 7]) Question 1c: Increasing Numbers in List - Default Arguments (2 points) Now that you have defined the behavior for both numIncreasingl and numIncreasing2, create a "wrapper function" numIncreasing which takes a list L of numbers and a boolean longest which by default is equal to False and will trigger whether numIncreasingl or numIncreasing2 is executed. : # Your Code here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!