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
icon
Related questions
Question
100%

The original problem is: 

"Design a program that asks the user to enter 10 golf scores. The scores should be stored in an Integer array. Sort the array in ascending order and display its contents."

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.

 

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()
Transcribed Image Text: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()
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage