Homework 12: Population Density

Objective: To write a program to select population density data from a text file

Write a program that reads this text file of population data on all the countries of the world with over 1 million people (sorted by population) (copied from Wikipedia (data from 2018)). Your program should output a file in the same format as this one, but showing only the countries with population density higher than the amount entered by the user. For example:
[cpersiko@fog cs110a]$ python3 popDensity.py.txt
This program saves a file containing data on all the countries with population density above a specified number.
Please enter population density in people / square kilometer: 300
The file 'HighDensity.csv' has been saved with the list of all countries with population density above 300.0

[cpersiko@fog cs110a]$ cat HighDensity.csv 
Country,Population,Area,Density
 India,1354051854,3287240,364
 Bangladesh,164994076,147570,1118
 Japan,127387000,377873,337
 South Korea,48456369,99538,487
 Taiwan(China),23069345,35980,639
 Sri Lanka,20238000,65610,308
 Netherlands,17310000,41526,417
 Belgium,10827519,30528,355
 Haiti,10033000,27750,362
 Rwanda,9998000,26338,380
 Israel,7697600,20770,371
 Hong Kong (China),7347000,1104,6349
 Singapore,5612300,719.9,7796
 Lebanon,4224000,10452,404
 Palestinian Authority (disputed),4100000,6020,681
 Puerto Rico (US),3982000,8875,449
 Mauritius,1288000,2040,631
 Bahrain,1234596,750,1646
 
[cpersiko@fog cs110a]$ python3 popDensity.py.txt
This program saves a file containing data on all the countries with population density above a specified number.
Please enter population density in people / square kilometer: 500
The file 'HighDensity.csv' has been saved with the list of all countries with population density above 500.0

[cpersiko@fog cs110a]$ cat HighDensity.csv 
Country,Population,Area,Density
 Bangladesh,164994076,147570,1118
 Taiwan(China),23069345,35980,639
 Hong Kong (China),7347000,1104,6349
 Singapore,5612300,719.9,7796
 Palestinian Authority (disputed),4100000,6020,681
 Mauritius,1288000,2040,631
 Bahrain,1234596,750,1646
[cpersiko@fog cs110a]$ 

Hints and Rules