Lecture 11/25/2025
This commit is contained in:
parent
e071375fdd
commit
b6d80f4e8b
2 changed files with 27 additions and 11 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Create three dictionaries
|
# Create three dictionaries
|
||||||
dict1 = {'fName': 'Edward', 'lName': 'Bigos', 'Office': 617, 'Phone': '413-755-4544'}
|
dict1 = {'fName': 'Edward', 'lName': 'Bigos', 'Office': 617, 'Phone': '413-755-4544'}
|
||||||
dict2 = {'fName': 'Bill', 'lName': 'Gates', 'Office': 700, }
|
dict2 = {'fName': 'Bill', 'lName': 'Gates', 'Office': 700, 'email': 'bgates@microsoft.com'}
|
||||||
dict3 = {'fName': 'Harry', 'lName': 'Smith', 'Office': 677, 'Phone': '413-000-0000'}
|
dict3 = {'fName': 'Harry', 'lName': 'Smith', 'Office': 677, 'Phone': '413-000-0000'}
|
||||||
|
|
||||||
# Put the three dictionaries in a list
|
# Put the three dictionaries in a list
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import json
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import turtle
|
import turtle
|
||||||
import pprint
|
import pprint
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
debugFlag = True
|
debugFlag = True
|
||||||
|
|
@ -16,9 +16,13 @@ result = json.loads(response.read())
|
||||||
if debugFlag:
|
if debugFlag:
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
pp.pprint(result)
|
pp.pprint(result)
|
||||||
time.sleep(10)
|
# time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
people = result['people']
|
people = result['people']
|
||||||
|
|
||||||
ISSpeople = []
|
ISSpeople = []
|
||||||
Tiangongpeople = []
|
Tiangongpeople = []
|
||||||
|
|
||||||
|
|
@ -34,7 +38,8 @@ if debugFlag:
|
||||||
pp.pprint(ISSpeople)
|
pp.pprint(ISSpeople)
|
||||||
print("Tiangongpeople")
|
print("Tiangongpeople")
|
||||||
pp.pprint(Tiangongpeople)
|
pp.pprint(Tiangongpeople)
|
||||||
time.sleep(10)
|
# time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
print("People on the ISS: ",len(ISSpeople))
|
print("People on the ISS: ",len(ISSpeople))
|
||||||
for person in ISSpeople :
|
for person in ISSpeople :
|
||||||
|
|
@ -44,17 +49,28 @@ print("People on the Tiangong: ",len(Tiangongpeople))
|
||||||
for person in Tiangongpeople :
|
for person in Tiangongpeople :
|
||||||
print(f"\t{person}")
|
print(f"\t{person}")
|
||||||
|
|
||||||
|
## ============================================================
|
||||||
|
|
||||||
|
try:
|
||||||
url = 'http://api.open-notify.org/iss-now.json'
|
url = 'http://api.open-notify.org/iss-now.json'
|
||||||
response = urllib.request.urlopen(url)
|
response = urllib.request.urlopen(url)
|
||||||
result = json.loads(response.read())
|
result = json.loads(response.read())
|
||||||
|
except:
|
||||||
|
print("ERROR: The sever at NASA did not respond. ")
|
||||||
|
print("Please try again later.")
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
|
|
||||||
|
if debugFlag:
|
||||||
|
print(type(result))
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
location = result['iss_position']
|
location = result['iss_position']
|
||||||
latitude = location['latitude']
|
latitude = location['latitude']
|
||||||
longitude = location['longitude']
|
longitude = location['longitude']
|
||||||
|
if debugFlag:
|
||||||
print('Latitude: ',latitude)
|
print('Latitude: ',latitude)
|
||||||
print('Longitude: ',longitude)
|
print('Longitude: ',longitude)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue