Question

In: Computer Science

The attached WorldSeriesWinners.txt ( since I cannot share it directly I will send the information for...

The attached WorldSeriesWinners.txt ( since I cannot share it directly I will send the information for the text file )  file contains the name of the winner of the World Series (duh) and the year in which they won. 1904 and 1994 did not have World Series played, so "No Winner" is displayed for those years. Your job is to write a program that lets the user enter the name of a team (or "No Winner") and then display the number of times the team won and a list of the years in which they won. Some hints/tips:

  • You should use at least one try/catch error validation
  • You can use the string function lower() to convert a string into lowercase letters which might make it easier as a user interface.
  • You should use a while loop that allows the user to enter another team name after results are displayed
  • Use the mainline logic function
  • use propper indentation
  • THIS IS A Python program !
Boston Americans 
1903
No Winner
1904
New York Giants 
1905
Chicago White Sox 
1906
Chicago Cubs 
1907
Chicago Cubs 
1908
Pittsburgh Pirates 
1909
Philadelphia Athletics 
1910
Philadelphia Athletics 
1911
Boston Red Sox 
1912
Philadelphia Athletics 
1913
Boston Braves 
1914
Boston Red Sox 
1915
Boston Red Sox 
1916
Chicago White Sox 
1917
Boston Red Sox 
1918
Cincinnati Reds 
1919
Cleveland Indians 
1920
New York Giants 
1921
New York Giants 
1922
New York Yankees 
1923
Washington Senators 
1924
Pittsburgh Pirates 
1925
St. Louis Cardinals 
1926
New York Yankees 
1927
New York Yankees 
1928
Philadelphia Athletics 
1929
Philadelphia Athletics 
1930
St. Louis Cardinals 
1931
New York Yankees 
1932
New York Giants 
1933
St. Louis Cardinals 
1934
Detroit Tigers 
1935
New York Yankees 
1936
New York Yankees 
1937
New York Yankees 
1938
New York Yankees 
1939
Cincinnati Reds 
1940
New York Yankees 
1941
St. Louis Cardinals 
1942
New York Yankees 
1943
St. Louis Cardinals 
1944
Detroit Tigers 
1945
St. Louis Cardinals 
1946
New York Yankees 
1947
Cleveland Indians 
1948
New York Yankees 
1949
New York Yankees 
1950
New York Yankees 
1951
New York Yankees 
1952
New York Yankees 
1953
New York Giants 
1954
Brooklyn Dodgers 
1955
New York Yankees 
1956
Milwaukee Braves 
1957
New York Yankees 
1958
Los Angeles Dodgers 
1959
Pittsburgh Pirates 
1960
New York Yankees 
1961
New York Yankees 
1962
Los Angeles Dodgers 
1963
St. Louis Cardinals 
1964
Los Angeles Dodgers 
1965
Baltimore Orioles 
1966
St. Louis Cardinals 
1967
Detroit Tigers 
1968
New York Mets 
1969
Baltimore Orioles 
1970
Pittsburgh Pirates 
1971
Oakland Athletics 
1972
Oakland Athletics 
1973
Oakland Athletics 
1974
Cincinnati Reds 
1975
Cincinnati Reds 
1976
New York Yankees 
1977
New York Yankees 
1978
Pittsburgh Pirates 
1979
Philadelphia Phillies 
1980
Los Angeles Dodgers 
1981
St. Louis Cardinals 
1982
Baltimore Orioles 
1983
Detroit Tigers 
1984
Kansas City Royals 
1985
New York Mets 
1986
Minnesota Twins 
1987
Los Angeles Dodgers 
1988
Oakland Athletics 
1989
Cincinnati Reds 
1990
Minnesota Twins 
1991
Toronto Blue Jays 
1992
Toronto Blue Jays 
1993
No Winner
1994
Atlanta Braves 
1995
New York Yankees 
1996
Florida Marlins 
1997
New York Yankees 
1998
New York Yankees 
1999
New York Yankees 
2000
Arizona Diamondbacks 
2001
Anaheim Angels 
2002
Florida Marlins 
2003
Boston Red Sox 
2004
Chicago White Sox 
2005
St. Louis Cardinals 
2006
Boston Red Sox 
2007
Philadelphia Phillies 
2008
New York Yankees 
2009
San Francisco Giants 
2010
St. Louis Cardinals 
2011
San Francisco Giants 
2012
Boston Red Sox 
2013
San Francisco Giants
2014
Kansas City Royals
2015
Chicago Cubs
2016

Solutions

Expert Solution

def main():
data={}
teamLine=True
filename='WorldSeriesWinners.txt'
try:
with open(filename) as f:
for line in f:
token = line.strip()
if teamLine:
teamLine=False
if token.lower() not in data:
data[token.lower()]=[]
team=token.lower()
else:
teamLine=True
data[team].append(int(token))
again="y"
while again.lower()!="n":
team = input("Enter a team name: ")
if team.lower() in data:
print("{} won the World Series {} times.".format(team,len(data[team.lower()])))
print('Years won:',data[team.lower()])
again=input("Do you want to enter again (y/n)?: ")
except FileNotFoundError:
print('File {} not found!!'.format(filename))
  


Related Solutions

A periscope ( See the Fig.) is useful for viewing objects that cannot be seen directly....
A periscope ( See the Fig.) is useful for viewing objects that cannot be seen directly. It can be used in submarines and when watching golf matches from behind a crowd of people. Suppose the object is a distance p1 from the upper mirror and the centers of the two flat mirrors are separated by a distance h. (a) What is the distance of the final image from the lower mirror? (b) Is the final image real or virtual?(c) Is...
Costs that cannot be directly traced to a profit center are called: a. variable costs. b....
Costs that cannot be directly traced to a profit center are called: a. variable costs. b. common costs. c. segment costs. d. fixed costs.
DIET ANALYSIS PART 4 : NO FILE NEEDS TO BE ATTACHED FOR THIS SECTION. Cannot submit...
DIET ANALYSIS PART 4 : NO FILE NEEDS TO BE ATTACHED FOR THIS SECTION. Cannot submit part 4 if you have not submitted part 1-3. Review SAM: SUBJECT: SAM Age: 39 Birthdate:7/14/1980 Height: 6 feet 2 inches Weight: 312 pounds Waist circumference: 65 inches Sam works at the local Wells Fargo Bank. He is a Branch Manager He works 40 hours per week. Sam spends a lot of his time behind a desk working for his clients. He smokes cigarette...
1. Horizontal siding may be attached to wood studs or sheathing. directly to wood studs. using...
1. Horizontal siding may be attached to wood studs or sheathing. directly to wood studs. using bolts. directly to sheathing. 2. Structural steel members are designed, fabricated, and assembled in the shop. shop fabricated and site assembled. site fabricated and site assembled. shop fabricated and shop assembled. 3. Light-gauge steel studs are attached to top and bottom tracks using rivets. staples. nails. bolts in predrilled holes. self-tapping screws. 4. A length of LVL lumber is more likely to warp or...
Risk management is not rocket science-it cannot be, since the past does not repeat itself on...
Risk management is not rocket science-it cannot be, since the past does not repeat itself on a sufficiently reliable basis. Future risks cannot be understood without examining the economic forces that shape them…..However, understanding risks makes sense only if that understanding is used to create value. This means that risk management cannot be done independently of an understanding of the profits that come from taking risks.’ [Rene Stultz, ‘Why Risk Management is not a Rocket Science’, Financial Times, 27 June...
I need to send my students I am doing distant classes a test How do I...
I need to send my students I am doing distant classes a test How do I do this and have them answer it without the ability for the to keep it or print it out
Attached is the problem I am working on I have to use phantoms, and i have...
Attached is the problem I am working on I have to use phantoms, and i have already completed steps p and H, I need help help with step A , which is to "state and check the assumptions for the hypothesis test", I think the correct hypothesis test to use would be the 2 sample t test, but im not sure. The number of cell phones per 100 residents in countries in Europe is given in table #9.3.9 for the...
I have to code the assignment below. I cannot get the program to work and I...
I have to code the assignment below. I cannot get the program to work and I am not sure what i am missing to get the code to work past the input of the two numbers from the user. My code is listed under the assignment details. Please help! Write a Java program that displays the prime numbers between A and B. Inputs: Prompt the user for the values A and B, which should be integers with B greater than...
Since there is high unemployment in the US and so many college graduates cannot get jobs,...
Since there is high unemployment in the US and so many college graduates cannot get jobs, it is only fair to consider instituting a broad mandatory retirement age again in most workplaces. Agree or disagree? Explain your answer in full details
Sorry, this is all the info I have on this problem, I have. If you cannot...
Sorry, this is all the info I have on this problem, I have. If you cannot do it please cancel/refund the question so we both can save time :) 5. A type of order that becomes a market order when a round lot trades at or through a particular price is called a a. market order b. limit order c. stop order d. none of the above 6. A customer's initial transaction in a margin account is the purchase of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT