A real Python based task that I was asked to complete during an interview with a Fortune 500 company.
Given a list of requirements, make a Python console program that fulfills them.
Here is the actual task requirements. They are very informal, but from my experience, is typical of lazy analyst lol:
There is an API (http://api.open-notify.org/) that provides information on the International Space Station. Documentation is provided via the website, along with sample request/response.
Implement a Python script that will accept the following command line arguments, along with any required information, and print the expected results
loc
print the current location of the ISS
Example: “The ISS current location at {time} is {LAT, LONG}”
pass
print the passing details of the ISS for a given location
Example: “The ISS will be overhead {LAT, LONG} at {time} for {duration}”
people
for each craft print the details of those people that are currently in space
To really sum up what they want:
Create an HTTP client that hits the three endpoints (as described in the link) and processes the returned JSON.
Format and print the processed data in a meaningful way.
The endpoint you hit is based on console arguments, where some will need additional arguments (i.e pass)
The task is pretty open ended, so you can print what you please as long as it gives relevant information from each endpoint.
In addition, you'll notice a lot of little caveats in the JSON payloads, and it's really up to you to decide what parts you include or exclude in your output.
The following was used for my submission:
- Python 3.7.3
- requests v2.22.0
I attempted to showcase my understanding of the following:
- Use of an HTTP library
- Data Validation
- Exception handling for various situations (e.g
IndexError
, error check after hitting endpoint) - Processing JSON data into organized structures (e.g dictionaries)
- Use of time functions
- String formatting
To emphasize data validation, latitude and longitude are in a range of [-90, 90]
and [-180, 180]
, respectively.
Validation will then be checking for the inputs existence, if they are numeric, and lastly ensuring that the inputs are within their intervals (inputs are the coordinates when using pass
).
Usage: iss_poc ['loc', 'people', 'pass'] [latitude: float] [longitude: float]