Beispiel #1
0
#    http://www.fly.faa.gov/flyfaa/usmap.jsp
#    http://services.faa.gov/docs/services/airport


# 2. Write code to report weather information at various airports.
#
#    I have provided a Python module in this folder named "faa"
#    that contains a function that you will find helpful.
#
#    Your goal is to write code that will display weather
#    information for each airport code in the list below.
#
#    Example output for an airport code:
#
#    ORD (Chicago): The temperature is 30.0 F (-1.1 C), and the wind is Northeast at 8.1mph.
#
#    Good luck!

airport_codes = ['ORD', 'SFO', 'JFK']

# Your code goes here:

from faa import get_weather
# Or could have done...
# import faa
# for code in airport_codes:
#   data = faa.get_weather(code)

for airport in airport_codes:
  print(get_weather(airport)['name'] + ": The temperature is ", get_weather(airport)['weather']['temp'], "and the wind is", get_weather(airport)['weather']['wind'])
# Classifying things
# Classes vs. instances, data attributes, and methods.

import faa;

class Airport:
  pass

  def city()
    data = faa.get_weather(....)
    return data['city']



my_airport = Airport()
your_airport = Airport()
my_airport.code = 'ORD'

print("O'Hare Airport serves the city of", my_airport.city())
# print("The temperature is:", my_airport.temp())
# print("The wind is:", my_airport.wind())
Beispiel #3
0
import faa
data = faa.get_weather('ORD')

assert data['city'] == 'Chicago'
assert data['name'] == 'Chicago OHare International'
assert data['ICAO'] == 'KORD'
Beispiel #4
0
 def city():
     data = faa.get_weather("ORD")
     return data["city"]
Beispiel #5
0
import faa
data = faa.get_weather('JFK')

assert data['city'] == 'Chicago', "Should be Chicago"
assert data['name'] == 'Chicago OHare International'
assert data['ICAO'] == 'KORD'
Beispiel #6
0
# 2. Write code to report weather information at various airports.
#
#    I have provided a Python module in this folder named "faa"
#    that contains a function that you will find helpful.
#
#    Your goal is to write code that will display weather
#    information for each airport code in the list below.
#
#    Example output for an airport code:
#
#    ORD (Chicago): The temperature is 30.0 F (-1.1 C), and the wind is Northeast at 8.1mph.
#
#    Good luck!

airport_codes = ['ORD', 'SFO', 'JFK']

# Your code goes here:

import faa
airport_codes = ['ORD', 'SFO', 'JFK']

# Your code goes here:

for airport in airport_codes:
	result = faa.get_weather(airport)
	temperature = result['weather']['temp']
	wind = result['weather']['wind']
	city = result['city']
	print(airport,'(',city,') : The temperature is',temperature,', and the wind is',wind)
	print(result['city'])
Beispiel #7
0
def get_city_for(airport):
  return faa.get_weather(airport)['city']
Beispiel #8
0
# 1. Look at these websites first:
#
#    http://www.fly.faa.gov/flyfaa/usmap.jsp
#    http://services.faa.gov/docs/services/airport


# 2. Write code to report weather information at various airports.
#
#    I have provided a Python module in this folder named "faa"
#    that contains a function that you will find helpful.
#
#    Your goal is to write code that will display weather
#    information for each airport code in the list below.
#
#    Example output for an airport code:
#
#    ORD (Chicago): The temperature is 30.0 F (-1.1 C), and the wind is Northeast at 8.1mph.
#
#    Good luck!

airport_codes = ['ORD', 'SFO', 'JFK']
import faa

# Your code goes here:
for code in airport_codes:
    data = faa.get_weather(code)
    city = data['city']
    temp = data['weather']['temp']
    wind = data['weather']['wind']
    print(code, "(" + data['city'] +")", ": The temperature is", data['weather']['temp'], " and the wind is", data['weather']['wind'])
Beispiel #9
0
def get_wind_at(code):
  data = faa.get_weather(code)
  return data['weather']['wind']
 def temp(self):
     data = faa.get_weather(self.code)
     return data['weather']['temp']
 def wind(self):
     data = faa.get_weather(self.code)
     return data['weather']['wind']
 def city(self):
     data = faa.get_weather(self.code)
     return data['city']
Beispiel #13
0
 def city(self):
   # whenever you call a function (on line 23), it always passes the object on the left of the dot
   # every method must accept at least one parameter
   data = faa.get_weather(self.code)
   return data['city']
Beispiel #14
0
def get_temperature_at(airport):
  return faa.get_weather(airport)['weather']['temp']
Beispiel #15
0
	def city(airport_obj):
		data = faa.get_weather(airport_obj.code)
		return data ['city']
Beispiel #16
0
def get_city_for(code):
  data = faa.get_weather(code)
  return data['city']
Beispiel #17
0
	def name(airport_obj):
		data = faa.get_weather(airport_obj.code)
		return data ['name']
Beispiel #18
0
def get_temperature_at(code):
  data = faa.get_weather(code)
  return data['weather']['temp']
Beispiel #19
0
import faa

data = faa.get_weather("ORD")

assert data["city"] == "Chicago", "Should be Chicago"  # customize error message
assert data["name"] == "Chicago OHare International"
assert data["ICAO"] == "KORD"
Beispiel #20
0
def get_wind_at(airport):
  return faa.get_weather(airport)['weather']['wind']