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

I\'ve been round and round with this thing. I know that it is supposed to be an

ID: 3625758 • Letter: I

Question

I've been round and round with this thing. I know that it is supposed to be an elementary problem but I'm not getting any help for the arrays portion of this class.
I am NOT studying to be a programmer, this was just one of the required courses to supplement my GIS courses.
I need to have this turned in by the end of this week. If someone could PLEASE help me I would appreciate it!

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

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:

nameOfGolfer=str.array(itemsize=20,shape=n)
scoreOfGolfer(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.
4.

Your sample output might look as follows:

Enter the number of golfers >>> 3

Enter the name of the golfer >>> Joe
Enter the score for Joe >>> 85
Enter the name of the golfer >>> Scott
Enter the score for Scott >>> 79
Enter the name of the golfer >>> Bob
Enter the score for Bob >>> 90

The rank for the golfer’s is:
Bob 90
Joe 85
Scott 79

Happy Golfing!




This is as far as I've gotten and this was taken from an answer on this website that another student got.
I can't get it to run past entering the number of golfers and the first golfer's name.


def main():

index = 0


SIZE=input("Enter the number of golfers: ")

while index < SIZE:

names[index] = raw_input("Enter the name of the golfer: ")

scores[index] = raw_input("Enter the score for golfer: ")

index=index+1

bubbleSort(scores,names,SIZE)

print "Your golf scores sorted highest to lowest are: "

for index in range(0,SIZE - 1):

print names[index],scores[index]



def bubbleSort(scores,names,SIZE):

for maxElement in range(arraySize - 1,0 - 1):

for index in range (0,maxElement - 1):

if scores[index] > scores[index+1]:

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

main()

Explanation / Answer

Please Rate: "array" contains golfer score.Rest of the code is pretty apparent.Still feel free to ask incase of any problem. CODE:- array=[]; golfers=[]; def bubble_sort(array,golfers): swap=True; number=input('Enter a Number Please:'); for i in range(1,int(number)+1): string=input("Enter Golfer Name:"); golfers.append(string); score=input('Enter Golfer score:'); array.append(score); while swap: swap=False; for j in range(0,len(array)-1): if(array[j]>array[j+1]): temp=array[j+1]; array[j+1]=array[j]; array[j]=temp; temp2= golfers[j+1]; golfers[j+1]=golfers[j]; golfers[j]=temp2; swap=True; print(array); print(golfers);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote