Project #2Assignment Solved

30.00 $ 15.00 $

Category:

Description

1. You will develop a Python program to manage information about baseball players. The program will maintain the following information for each player in the data set:player’s name (string)
team identifier (string)
games played (integer)
at bats (integer)
runs scored (integer)
hits (integer)
doubles (integer)
triples (integer)
homeruns (integer)
batting average (real)
slugging percentage (real)The first nine items will be taken from a data file; the last two items will be computed by the program. The following formulas will be used for those computations:singles = hits – (doubles + triples + homeruns)
total bases = singles + 2*doubles + 3*triples + 4*homeruns
batting average = (hits) / (at bats)
slugging percentage = (total bases) / (at bats)A player with zero at bats is defined to have a batting average and slugging percentage of zero2. The program will recognize the following commands:QUIT
HELP
TEAM identifier
REPORT BATTING AVERAGE
REPORT SLUGGING PERCENTAGEThe program will recognize commands entered with any mix of upper and lower case letters.The program will be operated interactively: it will prompt the user and accept commands from the keyboard.If the user enters an invalid command, the program will display an appropriate message and prompt the user to enter another command.3. The “QUIT” command will halt execution.4. The “HELP” command will display information to the user about the commands recognized by the program.5. The “TEAM” command will be followed by a string representing a team identifier. The program will display all information about all players on that team.If the user enters an invalid team identifier, the program will display an appropriate message and prompt the user to enter another command;6. The “REPORT” command will be followed by a string (BATTING” or “SLUGGING”).If the user enters an invalid command, the program will display an appropriate message and prompt the user to enter another command; the program will not display an empty report.If the user enters valid command “ REPORT BATTING”, generate a file named “ players_battingaverage.txt” that contains all the player information along with their batting averageIF the user enters valid command “ REPORT SLUGGING”, generate a file named “ players_sluggingpercentage.txt” that contains all the player information along with their slugging percentage.7. The program will display appropriate messages to inform the user about any unusual circumstances.Assignment Notes
1. The file named “players.txt” contains information about 20 players on the teams in Major League Baseball3. As noted above, your program must consist of at least three meaningful functions; you certainly may develop more than three functions. You will have to decide how to decompose the overall program into smaller tasks. Note that it would be natural to implement some (or even all) of the subtasks as functions.Each function should have a coherent purpose which can be expressed succinctly in a line or two.You may not use any global variables in your program. All communication between the functions which constitute your program will be done using parameters and return values.