Question

The sport of amateur boxing requires opponents to be in the same weight category to compete....

The sport of amateur boxing requires opponents to be in the same weight category to compete. For this exercise, we will consider the following categories for weights of women and men:

Class Name Weight in kg
Welterweight 61-64
Lightweight 58-60
Featherweight 55-57
Bantamweight 51-54

Write a Python program that prompts for the weights of boxing competitors. Weights for this competition are between 51 and 64 kg. Accept the weights of all competitors until a zero or a negative number is entered. When all entries have been entered, determine how many competitors are in each category. If there are zero competitors in a category, do not list it. If there is only one competitor in a category, add one to the next higher category if there is one. If there is a single welterweight, do not move this competitor from the category. If a competitor weight is below 51 or above 64, add them to one of two new categories: TooLow, TooHigh. Calculate and print the average weight of all competitors in the competition. Your output must be self-explanatory.

Include a flowchart with your program.

Use the following data to check your work: 51, 59, 62, 63, 49, 54, 53, 52, 55, 66, 55, 50, 57, 0

Homework Answers

Answer #1

Note: The code is for Python 3. Please indent the code as shown in the screenshots.

Programs screenshots:

Sample output:

Code to copy:

# Define the main() function.

def main():

    # Create a dictionary to store the categories.

    className = {"Welterweight": 0, "Lightweight": 0, "Featherweight": 0, "Bantamweight": 0, "TooLow": 0, "TooHigh": 0}

    # Declare the required variables.

    competitors = 0

    total = 0

    # Prompt the user to enter the weights.

    print("Enter the weights terminated by 0 or a negative value:")

    # Start the while loop.

    while(True):

        

        # Store the weight entered by the user.

        weight = int(input())

        # Break the loop if the input is 0 or negative.

        if weight <= 0:

            break

        # Increment the total and number of competitors

        # if the weight is valid.

        if weight <=64 and weight >= 51:

            total += weight

            competitors += 1

        # Increase the count of too high if the weight

        # is greater than 64.

        if weight > 64:

            className["TooHigh"] += 1

        

        # Increase the count of too low if the weight

        # is less than 51.

        elif weight < 51:

            className["TooLow"] += 1

        # Increase the count of Bantamweight if the weight

        # is greater than 51 and less than 54.

        elif weight >=51 and weight <= 54:

            className["Bantamweight"] += 1

        

        # Increase the count of Featherweight if the weight

        # is greater than 55 and less than 57.

        elif weight >=55 and weight <= 57:

            className["Featherweight"] += 1

        # Increase the count of Lightweight if the weight

        # is greater than 58 and less than 60.

        elif weight >=58 and weight <= 60:

            className["Lightweight"] += 1

        # Increase the count of Welterweight if the weight

        # is greater than 60 and less than 64.

        elif weight >=60 and weight <= 64:

            className["Welterweight"] += 1

    

    # Increase the count of Featherweight if the there

    # is only 1 entry in Bantamweight.

    if className["Bantamweight"] == 1:

        className["Featherweight"] += 1

        className["Bantamweight"] = 0

    # Increase the count of Lightweight if the there

    # is only 1 entry in Featherweight.

    if className["Featherweight"] == 1:

        className["Lightweight"] += 1

        className["Featherweight"] = 0

    

    # Increase the count of Welterweight if the there

    # is only 1 entry in Lightweight.

    if className["Lightweight"] == 1:

        className["Welterweight"] += 1

        className["Lightweight"] = 0

    # Compute the average weight of all the competitors.

    average = total/competitors

    print("The number of competitors in each category is as follows:")

    # Start the loop to traverse the dictionary.

    for category in className.keys():

        # Print the category and its count if the count is

        # not equal to 0.

        if className[category] != 0:

            print(category + ":", className[category])

    

    # Display the average weight.

    print("The average weight of all competitors is", average)

# Call the main() function.

if __name__ == "__main__":

    main()

    

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Q1. A clinical trial is run to assess the effects of different forms of regular exercise...
Q1. A clinical trial is run to assess the effects of different forms of regular exercise on HDL levels in persons between the ages of 18 and 29. Participants in the study are randomly assigned to one of three exercise groups - Weight training, Aerobic exercise, or Stretching/Yoga – and instructed to follow the program for 8 weeks. Their HDL levels are measured after 8 weeks and are summarized below. Weight Training Aerobic Exercise Stretching/Yoga 48 38 56 49 41...
Write a java program that creates an integer array with 50 random values, prompts the user...
Write a java program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (e.g. “Out of Bounds”) and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle invalid inputs,...
Lance H. and Wanda B. Dean are married and live at 431 Yucca Drive, Santa Fe,...
Lance H. and Wanda B. Dean are married and live at 431 Yucca Drive, Santa Fe, NM 87501. Lance works for the convention bureau of the local Chamber of Commerce, while Wanda is employed part-time as a paralegal for a law firm. During 2016, the Deans had the following receipts: Salaries ($60,000 for Lance, $41,000 for Wanda) $101,000 Interest income—    City of Albuquerque general purpose bonds $1,000    Ford Motor company bonds 1,100    Ally Bank certificate of deposit 400 2,500 Child...
Total utility can be objectively measured in numbers that indicate usefulness or benefit to the consumer....
Total utility can be objectively measured in numbers that indicate usefulness or benefit to the consumer. ____ 2. Consumers should purchase quantities of a good to the point where MU > P. ____ 3. Voluntary exchange requires that there must be mutual gain. ____ 4. Points along a budget line represent the maximum combinations of two commodities that a consumer can afford. ____ 5. The budget line represents a consumer's preferences for a commodity. ____ 6. A change in consumer...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From the April 2004 Issue Save Share 8.95 In 1991, Progressive Insurance, an automobile insurer based in Mayfield Village, Ohio, had approximately $1.3 billion in sales. By 2002, that figure had grown to $9.5 billion. What fashionable strategies did Progressive employ to achieve sevenfold growth in just over a decade? Was it positioned in a high-growth industry? Hardly. Auto insurance is a mature, 100-year-old industry...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
1. In which phase of the business cycle is the U.S. economy currently in? ________________. How...
1. In which phase of the business cycle is the U.S. economy currently in? ________________. How many months has the U.S. economy been in this stage of the business cycle? ___________ months 2. How long has the current expansion/recovery lasted to date? _________________ How does this compare to the average length of U.S. recessions since 1854? ______________________________. 3. What do the last four recoveries/expansions (that is, the current recovery/expansion and the previous three recovery/expansions), suggest about a new trend in...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT