From b6d80f4e8ba2c5b5fc2cf68381d7692fa0f97540 Mon Sep 17 00:00:00 2001 From: Edward Bigos Date: Tue, 25 Nov 2025 12:03:54 -0500 Subject: [PATCH] Lecture 11/25/2025 --- .../dictionaries/dictionary4.py | 2 +- bigos/lecture20251125/urllib/iss/iss-4a.py | 36 +++++++++++++------ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/bigos/lecture20251118/dictionaries/dictionary4.py b/bigos/lecture20251118/dictionaries/dictionary4.py index c2fd2cf..92896ec 100644 --- a/bigos/lecture20251118/dictionaries/dictionary4.py +++ b/bigos/lecture20251118/dictionaries/dictionary4.py @@ -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 diff --git a/bigos/lecture20251125/urllib/iss/iss-4a.py b/bigos/lecture20251125/urllib/iss/iss-4a.py index 03f0250..93b9164 100644 --- a/bigos/lecture20251125/urllib/iss/iss-4a.py +++ b/bigos/lecture20251125/urllib/iss/iss-4a.py @@ -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,19 +49,30 @@ 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) -url = 'http://api.open-notify.org/iss-now.json' -response = urllib.request.urlopen(url) -result = json.loads(response.read()) -print(result) location = result['iss_position'] latitude = location['latitude'] longitude = location['longitude'] - -print('Latitude: ',latitude) -print('Longitude: ',longitude) +if debugFlag: + print('Latitude: ',latitude) + print('Longitude: ',longitude) screen = turtle.Screen()