
PYTHON
Create a program to sort a list of given numbers in ascending order.
For example, if given 2,7,2,4,5,6 the output would be 2, 2, 4, 5, 6, 7
Do not use any libraries for the sort you must create the sort
At the very least your program should:
- Ask the user if they would like to enter numbers into a list or create a random list.
- If they choose to enter numbers into a list ask them to enter numbers for the list. (Make sure to tell them how to stop entering numbers ie enter q to stop.)
- If they choose to create a random list ask them how many numbers they would like in their list.
- Print the unsorted list to the user.
- Then print the sorted list to the user.
- Make sure to use exception handling to save your program from crashing.
from TimerFile import Timer
from RandListFile import RandList
from SortFile import Sort
from SearchesFile import Search
'''
Describe instances of the classes
'''
#instances of classes
timerInst = Timer()
sortInst = Sort()
searchInst = Search()
randomInst = RandList()
#Original Random List to use
randomInst.createRandomList(10)
randomListToSort = randomInst.getRandList()
'''
User Inputs
'''
# Python Program to Sort List in Ascending Order
randomList = randomInst.getRandList()
questionOne = int(input("Would you like to create a list or have a random list ?"))
if questionOne == 1:
print('You have choose Create A List')
else:
if questionOne == 2:
print('You have choose Random List')
print('Your random is list is:',randomList)
NumList = []
Number = int(input("How many numbers would you like in the list : "))
for i in range(1, Number + 1):
value = int(input("Please enter the number you would like in the list : "))
NumList.append(value)
print("Unsorted Array")
print(NumList)
print('Sorted Array in Ascending Order:')
print(NumList)
'''
Search using some type of Sort
'''
#quickSort
print('--- Quick Sort----')
quickRandomInst = randomListToSort.copy()
quickSortList = randomInst.getRandList()
randomInst.showFirtTenOfList()
timerInst.startTimer()
sortListQuick = sortInst.quick_sort(quickSortList,0,len(quickSortList)-1)
randomInst.showFirtTenOfList()
timerInst.stopTimer()
timerInst.results()
timerInst.resetTimer()
print('--- End Quick Sort----')

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images

- C Programming Language Note: Input and Output Must be the same Write in C Languagearrow_forwardPYTHON Problem Statement Given a list of numbers (nums), for each element in nums, calculate how many numbers in the list are smaller than it. Write a function that does the calculation and returns the result (as a list). For example, if you are given [6,5,4,8], your function should return [2, 1, 0, 3] because there are two numbers less than 6, one number less than 5, zero numbers less than 4, and three numbers less than 8. Sample Input smaller_than_current([6,5,4,8]) Sample Output [2, 1, 0, 3]arrow_forwardWrite a C++ program that reads a list of numbers from a file into an array, then uses that array to find the average of all the numbers, the average of the positive and negative numbers (0 is neither positive nor negative!), and the largest number. The point is to be able to store data in an array and do things with it Your program must contain at least the following four functions... read_list() This function will take as input parameters an array of integers and a string filename. It will open that file and read in numbers, storing them in the array, stopping at the end of the file. Remember that there are tricky issues with extra whitespace at the end of the file. You can assume the file contains only integers. The function will return the number of numbers that were read in.Note: In versions of Visual C++ pre-2010, when using the open function with a string argument, you must call the c_str() function on the string variable, such as:my_input_stream.open( filename.c_str() ) 2.…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





