Question: # Below is an api endpoint to show you all countries that speak spanish. Dive into the data and answer the following # questions: #

# Below is an api endpoint to show you all countries that speak spanish. Dive into the data and answer the following
# questions:
# 1) Display the common name, currency symbol, population and timezone of each country that is NOT landlocked and is in
# the South American continent.
# 2) using the latitude and longitude of the data from the query above, diplay the country information on a world map (using code below)
import requests
import json
the website needed is called rest countries.
# make the call to the API
#create an output file so you can see the json response that was returned by the API call
print(f"status code: {r.status_code}")
# Create a list of country names, longitudes, latitudes and population for all countries.
# NOTE: It is important to use these names for the map to work correctly.
names =[]
lons =[]
lats =[]
population =[]
# populate this list with the data from the api call using a loop and print out information
# per requirements in 1)
#Plotly World Map (NOTE: NO CODING NEEDED HERE!)
from plotly.graph_objs import Scattergeo, Layout
from plotly import offline
data =[{
'type': 'scattergeo',
'lon': lons,
'lat': lats,
'text':names,
'marker':{
'size':[p/3_000_000 for p in population],
'color':population,
'colorscale':'Viridis',
'reversescale':True,
'colorbar':{'title':'Population'}
},
}]
my_layout = Layout(title='South American Countries that are not landlocked')
fig ={'data':data, 'layout':my_layout}
offline.plot(fig,filename='south_america.html')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!