Lecture 11/25/2025

This commit is contained in:
Edward Bigos 2025-11-25 12:03:54 -05:00
parent e071375fdd
commit b6d80f4e8b
2 changed files with 27 additions and 11 deletions

View file

@ -2,7 +2,7 @@
# Create three dictionaries
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'}
# Put the three dictionaries in a list

View file

@ -3,7 +3,7 @@ import json
import urllib.request
import turtle
import pprint
import sys
import time
debugFlag = True
@ -16,9 +16,13 @@ result = json.loads(response.read())
if debugFlag:
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(result)
time.sleep(10)
# time.sleep(10)
people = result['people']
ISSpeople = []
Tiangongpeople = []
@ -34,7 +38,8 @@ if debugFlag:
pp.pprint(ISSpeople)
print("Tiangongpeople")
pp.pprint(Tiangongpeople)
time.sleep(10)
# time.sleep(10)
print("People on the ISS: ",len(ISSpeople))
for person in ISSpeople :
@ -44,17 +49,28 @@ print("People on the Tiangong: ",len(Tiangongpeople))
for person in Tiangongpeople :
print(f"\t{person}")
## ============================================================
try:
url = 'http://api.open-notify.org/iss-now.json'
response = urllib.request.urlopen(url)
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)
location = result['iss_position']
latitude = location['latitude']
longitude = location['longitude']
if debugFlag:
print('Latitude: ',latitude)
print('Longitude: ',longitude)