Create a python script

143 views 8:23 am 0 Comments August 5, 2023

!! Please comment your code!!! Tasks Group I The file CityPop.esv (CityPop.esv) contains 39 cities with their coordinates and populations (in millions) over several years in CSV (comma -scparated valucs) format. If you open this file in Notepad or Notepad++, you will see 40 lines of text with values separated by commas. The first line of the file contains the column names, and the other lines cach pertain Note that all of the column names begin with a letter; this isn't a big deal here, but many programs run into problems when identifying a value using a number, so this is generally good practice. If you open a CSV file in Excel, you will see a table with cach line shown as a row and each comma separated value in its own cell. Excel detects the CSV format and knows to automatically convert newline characters into ow separations and commas into column to a different city Tasks For the following tasks, you can assume all coordinates are given in valid formats Task 1 Create a python script that reads in the contents of CityPop.csv and stores the data in a container Task 2 will expect that your program can find cities by name within the containcr, so think about that as you set up your data container (see Strategies session below). Briefly describe how you store the data in comments Task 2: Extend Task I so that the user can query the population of a city in a particular year. To Do: Prompt the user for a city and a year (note that the format of year is 'yr1970'). Test their input to make sure it is valid and corresponds to values within the file. Task 3: Extend Task 1 so that the program can calculate the distance between two cities in the file specified by the user To Do: Prompt the user for the city names, find the corresponding latitude and longitude valucs in the file contents (if they exist) and utilize your great circle distance function to calculate the distance Task 4: (this is very important part) Extend Task 1 so that your program calculates the population change over two years specified by the user for all the cities.

Tags: , , , , , , , , , , ,