Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Section 1: Create the program Create a program that lets the manager of a baseball team keep the data for each player and also specify
Section 1: Create the program Create a program that lets the manager of a baseball team keep the data for each player and also specify and display the lineup for a baseball game. Console Norv optrons 1 - Display Lineup 2 - Add player 3 - Renove player 4 - Move player 5 - Dalt player ponition 6 - Edit player ntata 7 - Exit progran Lineup number: 4 You selected Mike POSnC Position: iB Mike was updated. Menu option: 3 Number: 4 Mike was deleted. Menu option:? Byel Section 1: Create the program (continued) Specifications - The formula for calculating batting average is: average = hits / at_bats - The program should round batting average to a maximum of three decimal places. - Use functions to organize the code to make it more reusable, easier to read, and casier to maintain. - If the user enters an invalid menu option, display an error message and display the menu again so the user can clearly see the valid menu options. - Make sure the user can't enter data that doesn't make sense (such as a negative number of hits or the player having more hits than at bats). - Use a list of lists to store each player in the lineup. - Use a tuple to store all valid positions (C, 1B, 2B, etc). - When entering/editing positiots, the program should always require the user to enter a valid position. - Use a CSV file named players.csy to store the lineup. - Store the functions for writing and reading the file of players in a separate module named db.py. - Handle the exception that occurs if the program can't find the data file. - Handle the exceptions that occur if the user enters a string where an integer is expected. - Handle the exception that occurs if the user enters zero for the number of at bats. In that case, the player's batting average should be 0.0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started