Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

PYTHON PROGRAMMING ONLY PLEASE (Need Help with my User Inputs section only rest of code is fine)

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 algorithm from scratch or use one of the sort codes we used in class.

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----')

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education