Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

List Operations Write a program (listoperations.py) that contains 10 numbers in

ID: 3595527 • Letter: L

Question

List Operations Write a program (listoperations.py) that contains 10 numbers in a list. You do not need user input for this part of the lab. The list must be defined and initialized in the main() function with the 10 numbers in the list. You cannot use any global variables. Show the user a menu that asks the user which of the following operations they would like to perform on the list. Perform input validation and based on the user choice, execute the appropriate function and display the result. Here are the function signatures along with a description of the expected behavior. def findLowest (listName) : This function takes in the list of numbers as input and returns the lowest number in the list. def computeAverage(listName) : This function takes in the list of numbers as input and returns the average of all the numbers in the list. def dropEveryNthElement (listName, N): This functions takes in the list of numbers and a value N and returns a list with every Nth element from the list dropped from the list. For example, with an input list of [1, 2, 3,4,5, 6, 7] and N -3, the returned list will be [2, 3, 5, 6] def eliminateDuplicates (listName): This function takes in the list of numbers and returns a list that does not contain any duplicate numbers in the list. For example, if the input list is [1, 2, 2, 3, 2], this function must return [1, 2, 3] def duplicateNtimes (listName, count): This function takes in the list of numbers and a count for duplication. It returns a list that is count times longer than the original list and contains count number of entries for each entry in the original list (listName). For example, if the input list is [1, 2, 3] and count is 3, then the function will return a list that looks like this - [1,1,1, 2, 2, 2, 3, 3, 3]. Make sure to test the function for various values of count. Extra credit (2 points) def rotateLeftN(listName, N): This function takes in the list of numbers and a value for rotation and returns the input list leftwards N times. For example, for an input list of [1, 2, 3, 4, 5, 6] and N-4, the function will return the following list [5, 6, 1, 2, 3,4]. Test the function for various values of N

Explanation / Answer

l = [1,2,3,4,5,4,5,7]
def findLowest(l):
min = l[0]
for i in range(1,len(l)-1):
if(min > l[i]):
min = l[i]
return min
  
def computeAverage(l):
return sum(l)/float(len(l))
  
def dropEveryNthElement(l,n):
nl =[]
for i in range(len(l)):
if(i%n!=0):
nl.append(l[i])
return nl

def eliminateDuplicates(l):
nl = []
for i in range(len(l)):
if(l[i] not in nl):
nl.append(l[i])
return nl

def duplicateNtimes(l,n):
nl = []
for i in l:
for j in range(3):
nl.append(i)
return nl
  
print findLowest(l)
print computeAverage(l)
print dropEveryNthElement([1,2,3,4,5,6,7],3)
print eliminateDuplicates([1,2,3,4,5,2,3,2])
print duplicateNtimes([1,2,3,4],3)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote