Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IT 280 Lab #6: Package Creation Lab Instructions To submit this Program : Submit the package and a Python program that uses the package as

IT 280 Lab #6: Package Creation Lab

Instructions

To submit this Program:

Submit the package and a Python program that uses the package as an extension of the List Manipulation Lab (Lab 3.1).

Package:

Create a package that has three functions:

sortLow (list) sorts from a to z.

sortHigh (list) sorts from z to a.

removeDup (list) removes duplicates from the list.

Program Inputs:

As an extension to Lab 3.1, follow the instructions for that lab. With the following modification, instead of using a local program function, you use a function in the package to sort and remove the duplicate values.

Program Processing (same as Lab 3.1):

If the list is empty, return a message that this list is empty. An empty list would be created if when a list is inputted, only a carriage return is entered. Using the + operator, print the specified output.

If this list is non-empty,

The list is sent to a function to be sorted.

The list is sent to a function to remove duplicates.

Program Output (same as Lab 3.1):

The sorted list will be printed to the screen.

Here is the code used in List Manipulation Lab (Lab 3.1) discussed above:

# function to sort the list

def sort_elements(L):

return sorted(L)

#function to remove the duplicates from the sorted list

def Remove_duplicate(L):

Sorted_L=[]

[Sorted_L.append(i) for i in L if i not in Sorted_L]

return Sorted_L

#User input

n=int(input("Enter the number of elements you want to sort: "))

#Condition to check if the list is empty

if n==0:

l1=[]

print("This is empty list: "+ str(l1))

# if the list is not empty

else:

#To store the elements in a list

l1=list(map(int,input("Enter the numbers: ").strip().split()))[:n]

#function call to sort elements

l2 = sort_elements(l1)

#function call to remove duplicates

l3 = Remove_duplicate(l2)

#sorted list

print("Sorted list: ",l3)

Here is the code Im trying to use for the modification, as mentioned in the Package discussed above (this is saved as a separate python file by itself to be used by the main Program):

# list_manipulation/__init__.py

def sortLow(lst):

return sorted(lst)

def sortHigh(lst):

return sorted(lst, reverse=True)

def removeDup(lst):

return list(set(lst))

And here is the code for the main program that Im trying to use to execute the modified Program as mentioned in the Program Inputs this lab discussed above:

from list_manipulation import sortLow, sortHigh, removeDup

def main():

lst = input("Enter a list of comma-separated values: ").split(",")

lst = [i.strip() for i in lst]

if not lst:

print("This list is empty.")

return

sorted_low = sortLow(lst)

print("Sorted list (low to high):", sorted_low)

sorted_high = sortHigh(lst)

print("Sorted list (high to low):", sorted_high)

no_duplicates = removeDup(lst)

print("List with duplicates removed:", no_duplicates)

if __name__ == "__main__":

main()

Please correct/fix my coding to perform the task mentioned above in light of the above information, then send a screenshot of the code in python.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions

Question

Under what circumstances is polygraph testing of employees legal?

Answered: 1 week ago