コード例 #1
0
ファイル: 0_warmup.py プロジェクト: lakshman111/week4
#    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'])
コード例 #2
0
# 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())
コード例 #3
0
ファイル: 5_assertions.py プロジェクト: hwei009/week4
import faa
data = faa.get_weather('ORD')

assert data['city'] == 'Chicago'
assert data['name'] == 'Chicago OHare International'
assert data['ICAO'] == 'KORD'
コード例 #4
0
 def city():
     data = faa.get_weather("ORD")
     return data["city"]
コード例 #5
0
ファイル: 5_assertions.py プロジェクト: jcyang2/week4
import faa
data = faa.get_weather('JFK')

assert data['city'] == 'Chicago', "Should be Chicago"
assert data['name'] == 'Chicago OHare International'
assert data['ICAO'] == 'KORD'
コード例 #6
0
ファイル: 0_warmup.py プロジェクト: fungedwin/week4
# 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'])
コード例 #7
0
ファイル: 2_functions.py プロジェクト: lakshman111/week4
def get_city_for(airport):
  return faa.get_weather(airport)['city']
コード例 #8
0
ファイル: 0_warmup.py プロジェクト: hiesenburg88/week4
# 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'])
コード例 #9
0
ファイル: 2_functions.py プロジェクト: jcyang2/week4
def get_wind_at(code):
  data = faa.get_weather(code)
  return data['weather']['wind']
コード例 #10
0
 def temp(self):
     data = faa.get_weather(self.code)
     return data['weather']['temp']
コード例 #11
0
 def wind(self):
     data = faa.get_weather(self.code)
     return data['weather']['wind']
コード例 #12
0
 def city(self):
     data = faa.get_weather(self.code)
     return data['city']
コード例 #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']
コード例 #14
0
ファイル: 2_functions.py プロジェクト: lakshman111/week4
def get_temperature_at(airport):
  return faa.get_weather(airport)['weather']['temp']
コード例 #15
0
ファイル: 3_defining_classes.py プロジェクト: fungedwin/week4
	def city(airport_obj):
		data = faa.get_weather(airport_obj.code)
		return data ['city']
コード例 #16
0
ファイル: 2_functions.py プロジェクト: jcyang2/week4
def get_city_for(code):
  data = faa.get_weather(code)
  return data['city']
コード例 #17
0
ファイル: 3_defining_classes.py プロジェクト: fungedwin/week4
	def name(airport_obj):
		data = faa.get_weather(airport_obj.code)
		return data ['name']
コード例 #18
0
ファイル: 2_functions.py プロジェクト: jcyang2/week4
def get_temperature_at(code):
  data = faa.get_weather(code)
  return data['weather']['temp']
コード例 #19
0
ファイル: 5_assertions.py プロジェクト: SuperSocrates/week4
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"
コード例 #20
0
ファイル: 2_functions.py プロジェクト: lakshman111/week4
def get_wind_at(airport):
  return faa.get_weather(airport)['weather']['wind']