Answered step by step
Verified Expert Solution
Link Copied!
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 name,position,at_bats, 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":"1B","at_bats":537, "hits":170},
{"name":"Craig Mitchell", "position":"CF","at_bats":396, "hits":125}]
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 (FileIO.py) 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 7,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 #1. 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 60 characters long and based on the
multiplication operator. The format for the lineup display columns will use 3 spaces for the order
number, 31 spaces for the player name, 6 spaces for the position, at bats, and hits, and 8 spaces for
the batting average. The batting average must be formatted to always displays 3 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

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_2

Step: 3

blur-text-image_3

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students explore these related Databases questions

Question

What are the main objectives of Inventory ?

Answered: 3 weeks ago