Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The first project used a list of lists to hold player data. This project will be refactored to use a list of dictionaries where each
The first project used a list of lists to hold player data. This project will be refactored to use a list
of dictionaries where each player is represented by a dictionary with four keys listed here for the
players namepositionatbats and hits Note: the next project will use a list of objects.
Here is a short example of a list of player dictionaries. This can be used to update the interface
code without the need to call the function that reads from the data file.
playersList
name:"Dominick Gilbert", "position":"Batbats": "hits":
name:"Craig Mitchell", "position":"CFatbats": "hits":
The batting average is calculated as needed when it is printed, not stored in the list or dictionary.
The program will consist of one Python file to hold the main function and supporting functions,
and a second Python file FileIOpy with two functions which read from and write to a comma
delimited csv file. The program will use the file named players.csv to store the data. Remember
that each row in a CSV reader object is a list and each element in the row can be accessed with a
list index. Review chapter How to read a CSV file
The data is loaded into a list in the main function before the user is asked for a menu option. The
lineup list variable will still be used as an argument when calling a support function as was done
in Project # The code in the functions will need to be changed to use a dictionary that holds the
player information instead of a list that holds the player information.
The new formatting requires that the separator lines are characters long and based on the
multiplication operator. The format for the lineup display columns will use spaces for the order
number, spaces for the player name, spaces for the position, at bats, and hits, and spaces for
the batting average. The batting average must be formatted to always displays decimals. Update
the display formatting to match the alignment formatting shown below.
Use a tuple to represent the valid positions a player can have.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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