Find latitude and longitude of first 20 countries with a population greater than or equal to the population limit given below. Use the country details from this dataset(https://cdn.jsdelivr.net/gh/apilayer/restcountries@3dc0fb110cd97bce9ddf27b3e8e1f7fbe115dc3c/src/main/resources/countriesV2.json).
Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.
Assume radius of earth: 6371 km
Round length of each line and final result to 2 decimal points
If co-ordinates are missing for any country use 0.000 N 0.000 E
Population limit: 65847
Note: Population limit will change at random intervals. So please make sure answer is computed for the correct population limit
import requests
import csv
rows = []
eligible_countries = []
url = input('Webpage to grab source from: ')
html_output_name = input('Name for html file: ')
req = requests.get(url, 'html.parser')
with open(html_output_name, 'r') as f:
f.read(req.text)
for row in req.text:
rows.append(row)
input = int(input("Please enter the limit of population: "))
eligible_countries = []
for i in rows:
if source[i][2] < input:
eligible_countries.append(rows[i])
print(eligible_countries)
f.close()
source = []
Comments
Leave a comment