Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Coding in Python to find the median of golf scores. YOU CANNOT USE SORT OR MEDIAN COMMANDS. Problem: In professional golf tournaments, a tournament typically

Coding in Python to find the median of golf scores. YOU CANNOT USE SORT OR MEDIAN COMMANDS.

Problem:

In professional golf tournaments, a tournament typically lasts four rounds. A players score is the sum of the scores in the rounds (the lower the better). It is common for all players to play the first two rounds of golf. However, only a fraction of the players are allowed to continue on to the third and fourth rounds. The way this is done is that a cut score is determined, and those whose scores are better (i.e. lower) than the cut are allowed to play the remainder of the tournament (they made the cut) while the rest do not.

In this case, the cut will be the median score among the golfers. You are to print out the names of golfers who made the cut (whose score was below the median), and those who did not make the cut (score above the median). Thus, about half the golfers should make the cut. Here are some details:

  • You are to write a program that reads in golfers names, and their first and second round scores. Specifically, they should enter the first round score on one line, then the second round score on another line, then the players name on a third line. This should continue for an arbitrary number of players. The user should indicate that they are done entering players by giving a negative score for the first round at this point, the reading-in of data should stop (without reading a second round or player name).
  • In practice, a common way to find the median is typically to sort the numbers from smallest to largest, and then to find the median from there directly (either the middle element if an odd number of elements., or the average of the two middle elements if an even number of elements). There is a simple sort routine built in to Python, but you are not to use it (the built-in sort command) for this problem.
  • There are many ways to find a median. A major part of this problem is to figure out a method for finding the median, yourselves. There are solutions involving just multiple loops, there are solutions that will use more than one list, and so on. Also, you do not technically have to find a median you could just find a way to report both those above and those below the median.
  • Youll be outputting two sets of names. Be sure it is clear which is which.
I have the first part of the code, I am lost as to what to do from this point on. score1 = 1 score2 = 1 player = '' total_list = [] while score1 >= 0: score1=int(input("Enter score for round 1 (enter negative value to stop):")) if score1 >= 0: score2=int(input("Enter score for round 2:")) player=str(input("Enter player name:")) total = score1+score2 total_list.append(total) print(total_list) # list of score totals

OUTPUT EXAMPLE:

Enter score for round 1 (enter negative value to stop): 2 Enter score for round 2: 5 Enter player name: Joe Enter score for round 1 (enter negative value to stop): 4 Enter score for round 2: 2 Enter player name: Bob Enter score for round 1 (enter negative value to stop): -1 [7, 6]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago