Question
how do would I solve this problem? I saw a similar one but the code didn't seem to run properly World Series Baseball (Points 10)
how do would I solve this problem? I saw a similar one but the code didn't seem to run properly
World Series Baseball (Points 10)
Given a text file that stores the World Series winners and losers for the years 1903 to 2015, write a program that allows a user do the following: 1 Find the World Series winner for a particular year 2 Find the World Series loser for a particular year 3 Count the number of times a team has won the World Series You can get the text file here: http://www.cs.uri.edu/~cingiser/csc110/labs/python/worldseries.txt Your program should allow the user to continue to enter choices until he/she is finished. To get you started, download this python code: http://www.cs.uri.edu/~cingiser/csc110/labs/python/worldseries_skeleton.py
Part A: Run the program (1 point) Save the Python file and the text file both to the same location on the computer. Run the program in IDLE to see how it should work. You will notice that it runs, but does not do anything except execute the main function and the getChoice function.
Part B: Get the data (3 points) Write the function to get the data from the data file. The function is called: getChamps Be sure to look at the file to see how the data is organized so that you can read it and store it into three separate lists. Also make sure that you account for the user entering an incorrect file name. You may need another function to handle this possible error. Insert a call into the main function in the appropriate place.
Part C: Find the winner and loser (2 points) Write the function to find the winner and loser of the World Series for a given year. The function is called: findWinnerAndLoser The function should take as a parameter the year for which they would like to know the World Series results. It should then look through the yearList to find the given year and return the winner and loser from that year. The program should display an error if the user enters a year that is not in the list or if the user enters something other than a year.
Part D: Count the wins (2 points) Write the function to count the number of wins for a given team. The function is called: countWins The function should take as a parameter the name of a team, and then count how many times that team was the winner of the World Series. The function should return the number of wins for that team. Add the function call to the main function in the appropriate place.
Part E: Check for Errors (2 points) Modify the getChoice function so that it handles the case where a user enters input other than an integer (use exception handling).
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