Git Product home page Git Product logo

python-geocoder's Introduction

Python Programming

Python Modules, Packages, and APIs: Practice Problems, Part 1

In this assignment, you're going to write code for a challenge problem.

You will practice these programming concepts we've covered in class:

  • Including and using modules and packages

Note: This lab is Part 1 of a two-part assignment. Save your solution code — the next homework will build off of it!


Deliverables

This lab will be a two-part code challenge with a bonus. It will be a little different than the other assignments because Part 2 will build on the code from Part 1. You can put all of your code in one file called solution.py. Right now, just make that one file.

Reminder: On your laptop, you can run the file from your command line with the following:

python solution.py

Hint: Make sure you are printing something out with the print statement. Otherwise, you won't see any output from running your program!

Requirements:

By the end of this, you should have:

  • A file called solution.py with your code from this challenge.

Code Challenges

Problem 1: Geo Cody

Skill you're practicing: Importing and using modules/packages.

Cody and his friends Heather and Matt are going on a road trip across the Western United States and Canada. They want to visit several landmarks, national parks, and big cities. Here's their agenda:

Space Needle
Crater Lake
Golden Gate Bridge
Yosemite National Park
Las Vegas, Nevada
Grand Canyon National Park
Aspen, Colorado
Mount Rushmore
Yellowstone National Park
Sandpoint, Idaho
Banff National Park
Capilano Suspension Bridge

Your job is to put these destinations into a list of strings called destinations. Then, import the geocoder module and use it to translate each of the landmarks into latitude-longitude coordinates. You'll need to loop through the list and print each location's latitude and longitude. We will be using arcgis to translate the places to coordinates. Visit the docs for more sample code.

Sample Code (geocoder/arcgis)

import geocoder

g = geocoder.arcgis('Redlands, CA')

print(g.latlng) # latlng is a tuple with a length of 2.

Starter Code

import geocoder

# Declare destinations list here.

# Loop through each destination.
for point in destinations:
#   Get the lat-long coordinates from `geocoder.arcgis`.
#   Print out the place name and the coordinates.

Expected Output

Space Needle is located at (47.6205, -122.3493)
Crater Lake is located at (42.8684, -122.1685)
Golden Gate Bridge is located at (37.8199, -122.4783)
Yosemite National Park is located at (37.8651, -119.5383)
Las Vegas, Nevada is located at (36.1699, -115.1398)
Grand Canyon National Park is located at (36.1070, -112.1130)
Aspen, Colorado is located at (39.1911, -106.8175)
Mount Rushmore is located at (43.8791, -103.4591)
Yellowstone National Park is located at (44.4280, -110.5885)
Sandpoint, Idaho is located at (48.2766, -116.5535)
Banff National Park is located at (51.4968, -115.9281)
Capilano Suspension Bridge is located at (49.3429, -123.1149)

Hint: We're following the pattern in the geonames example in the docs, only replacing geonames with arcgis.


Check Your Work

Take a look at the solution to check your work!

Done and Done!

Unless... you'd like to tackle part 2 as a bonus?

python-geocoder's People

Contributors

brandiw avatar 009kings avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.