def main(): SIZE = 10 [0] * SIZE scores = getScores (scores, SIZE) insertionSort(scores,SIZE) displayScores (scores,SIZE) def getScores(scores, SIZE): 4 8- index = 0 for index in range(SIZE - 1): print("Enter the golf score number ",index + 1, ":") input (scores[index]) 10 - 11 12 13 return scores def insertionSort (array, SIZE): index = 0 14 - 15 16 scan = 0 unsorted_value for index in range(SIZE - 1): unsorted_value 17 18 - 19 array[index] %3D 20 scan = index while (scan > e and array[scan - 1] < array[scan]): swap (array[scan 21- 1], array[scan]) 22 23 scan = scan-1 array[scan] return unsorted_value def swap(a,b): temp = a 24 unsorted_value %3D 25 26- 27 28 29 b = temp 30 return(a,b) def displayScores(scores, SIZE): index = 0 31 - 32 print("Here are the scores: ") for index in range(SIZE - 1): print (scores[index]) 33 34 - 35 36 return scores 37 main()
def main(): SIZE = 10 [0] * SIZE scores = getScores (scores, SIZE) insertionSort(scores,SIZE) displayScores (scores,SIZE) def getScores(scores, SIZE): 4 8- index = 0 for index in range(SIZE - 1): print("Enter the golf score number ",index + 1, ":") input (scores[index]) 10 - 11 12 13 return scores def insertionSort (array, SIZE): index = 0 14 - 15 16 scan = 0 unsorted_value for index in range(SIZE - 1): unsorted_value 17 18 - 19 array[index] %3D 20 scan = index while (scan > e and array[scan - 1] < array[scan]): swap (array[scan 21- 1], array[scan]) 22 23 scan = scan-1 array[scan] return unsorted_value def swap(a,b): temp = a 24 unsorted_value %3D 25 26- 27 28 29 b = temp 30 return(a,b) def displayScores(scores, SIZE): index = 0 31 - 32 print("Here are the scores: ") for index in range(SIZE - 1): print (scores[index]) 33 34 - 35 36 return scores 37 main()
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 5RQ
Related questions
Question
100%
The original problem is:
"Design a
This is python code, I just have one problem. When you run this program it gives an output of 9 zeros when you finish typing the golf scores. The question is how do I get it to print all of the values entered where it says "Here are the scores"? As stated in the homework problem, the final results should be sorted in ascending order.
My code is attatched as an image file.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage