Question: PYTHON a) (25 points) Check if a list consists of consecutive integers. Implement the function consecutive(L), which given a list L, checks whether or not

PYTHON

PYTHON a) (25 points) Check if a list consists of consecutive integers.

Implement the function consecutive(L), which given a list L, checks whether or

a) (25 points) Check if a list consists of consecutive integers. Implement the function consecutive(L), which given a list L, checks whether or not L consists of consists of consecu- tive integers. If so, your function should return True. Otherwise, it should return False. See the below test program. If L is not a list, your program should stop with an error message "L must be a list". If L is a list but not all objects in L are integers, your program should stop with an error message "All objects in L must be integers". Any correct solution is worth full credit. Test program/output: 3 print (consecutive ([1,2,3])) print (consecutive ([5,6,7])) print(consecutive ([5,6,7,8])) print(consecutive ([5,6,7,8,9,10])) print(consecutive((-2,-1])) print(consecutive ([3])) print(consecutive ([])) print(consecutive([2,1,3])) print(consecutive ([3,2,1])) print (consecutive([5,6,8])) print (consecutive ([5,5,6,7])) print(consecutive ((-2,0])) True True True True True True True False False False False False b) (35 points) Smallest slice cut to make list consecutive. First, review the slicing operator as defined in Programming Assignment 3. In this part, given a list L, we are interested in finding a slice of L of minimal length whose removal from L makes the elements of L consecutive. In particular, implement the function minSliceCut(L), which takes L as input argument and does the following: If I consists of consecutive elements, your function should return the empty list [] (no need to remove anything from L) Else, your function should return a slice L[i:j+1] whose removal from L makes the elements of L consecutive, for some indices i and j such that 0

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!