Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

answer in python idle 3.5 be very descriptive new to this subject!! Thanks Write a program that reads in the file and allows a user

image text in transcribed

answer in python idle 3.5 be very descriptive new to this subject!! Thanks

Write a program that reads in the file and allows a user to look up the location of the summer Olympics in a particular year. Specifically, the program will: Ask the user to enter the name of the data file. Read the data from the file into two lists one for the years and one for the locations. Ask the user to enter the year for which they are interested in the location of the olympics. Print the location of the olympics for that year. Here are a few things to note when working on this program: In the text file, the data is delimited by a tab so you will need to use the following command to get a line of data from the file: year, loc = line. split ("\t") You should have at least three functions in the program: getData, findLocation and main. Be sure to test that the file entered by the user exists and catch the error with exception handling. Be sure to test that the year entered by the user is an integer and catch the error with exception handling. Your output will look something like this: Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type copyright credits or "license()" for more information >>> RESTART:/Users/ldipippo/Documents/csc 110/homework/hw-solutions-fall2016 hw-5-olympics .py >>> main() Please the name of the data file olympics. txx Invalid file name ... Please the name of the data file olympics.txt Enter the year you are interested in: 2004 In 2004 the 0lympics were held in Athens, Greece >>> main() Please the name of the data file olympics txt Enter the year you are interested in 2005 No Olympics were held that year >>> main() Please the name of the data file olympics. txt Enter the year you are interested in 200x Invalid year must be an integer Enter the year you are interested in: 1994 No Olympics were held that year >>> main() Please the name of the data file olympics .txt Enter the year you are interested in: 2016 In 2016 the 0lympics were held in Rio de Janeiro, Brazil

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

Step: 3

blur-text-image

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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions