Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please develop this program in Python and please run it to make sure it works. T

ID: 3624732 • Letter: P

Question

Please develop this program in Python and please run it to make sure it works. Thank you SO much in advance :)

Write the Python code for the following programming problem below. You do not have to use modular design.

Combine Exercise 1 and 2 of Chapter 9. Write a program that will allow the user to enter the name and golf score for any number (n) of golfers. Next, sort the data in descending order by golf score using the Bubble Sort. Then display the golfers name and golf score.

Hints:
1. Create two parallel arrays of size n each. n, the number of golfers, will be entered by the user at the beginning of the program logic. One string array will store the golfer’s name, the second numeric integer array will store the golfer’s score. These variables might be defined as follows:

golferName=str.array(itemsize=20,shape=n)
golferScore(n,Int)


2. Don’t forget these two arrays are parallel and elements from both arrays have to be swapped correspondingly using the Bubble Sort for parallel arrays.
3. Don’t forget the imports needed for arrays in Python.

Your sample output might look as follows:

Enter the number of golfers >>> 5

Enter the name of the golfer >>> Hoyle
Enter the score for Hoyle >>> 85
Enter the name of the golfer >>> Lee
Enter the score for Lee >>> 79
Enter the name of the golfer >>> Blalock
Enter the score for Blalock >>> 90

The rank for the golfer’s is:
Blalock 90
Hoyle 85
Lee 79

Happy Golfing!

Explanation / Answer

//main module

def Main()

int index=0

//global variables

SIZE=Input("Enter the number of golfers >>>")

while index < SIZE

   Names[index]=Input("Enter the name of the golfer >>>")

   scores[index]=Input("Enter the score for Hoyle >>>")

   index=index+1

   bubbleSort(scores,Names SIZE)

   Display "Your golf scores sorted ascendedly are: "

   For index = 0 to SIZE - 1

     print Names[index]

     print scores[index]

  

def bubbleSort( scores, SIZE)

//performs the bubble sort algorithm, body of the module

     For maxElement = arraySize - 1 to 0 step -1

     For index = 0 to maxElement - 1

          If scores[index] > scores[index+1] then

            swap(scores[index], scores[index+1])

                  swap(Names[index], Names[index+1])

def swap(a,b)

    

    

     //swap the values in a and b

      temp = a

      a = b

      b = temp