trying to figure out to go about doing this.: def currentData(str): \'\'\'(str)-
ID: 3821848 • Letter: T
Question
trying to figure out to go about doing this.:
def currentData(str):
'''(str)--> lst
This function returns a list of weather data to be written to a csv file'''
pass
def longTermHeader(attributes):
'''(str)-->lst
This function takes a string of letter and returns a list of attribute
names to be used as a header.'''
pass
def longTermData(att, date_range, obj):
'''(str)--> lst
This function returns a list of weather data to be written to a csv file'''
outer_lst = []#used to contain rows
inner_lst = []#this is where the row will be created. append this list to outer
for i in range(date_range-1):
obj.setDayNum(i)
#use if statements to append appropriate data to inner list
# after if statements append the inner list to out list
pass
Explanation / Answer
Json data
{{'coord': {'lat': 7.751, 'lon': -12.42},
'country': 'xxxxxxxxxxxxxxxxxxx',
'id': '111',
'name': 'xxxxxx',
'population': 0},
'cnt': 3,
'cod': '200',
'list': [{'clouds': 0,
'deg': 233,
'dt': 1402344000,
'humidity': 58,
'pressure': 1012.23,
'speed': 1.96,
'temp': {'day': 32.29,
'eve': 26.46,
'max': 02.29,
'min': 9.77,
'morn': 294.59,
'night': 9.77},
'weather': [{'description': 'sky is clear',
'icon': '01d'}]
}
code:
weatherData = json.loads(response.text)
# Print weather descriptions.
w = weatherData['list']
print('Current weather in %s:' % (location))
print(w[0]['weather'][0]['main'], '-', w[0]['weather'][0]['description'])
print()
print('Tomorrow:')
print(w[1]['weather'][0]['main'], '-', w[1]['weather'][0]['description'])
print()
print('Day after tomorrow:')
print(w[2]['weather'][0]['main'], '-', w[2]['weather'][0]['description'])
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.