After lecture 20251112
This commit is contained in:
parent
c6dcbb0606
commit
dc82c5032c
6 changed files with 48 additions and 2 deletions
5
bigos/lecture20251112/numpy/hack.py
Normal file
5
bigos/lecture20251112/numpy/hack.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
import requests,json;
|
||||||
|
url = 'https://vpic.nhtsa.dot.gov/api/vehicles/GetModelsForMakeId/440?format=json';
|
||||||
|
r = requests.get(url);
|
||||||
|
print(r.text);
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy import pi
|
from numpy import pi
|
||||||
|
|
||||||
np.linspace(0, 2, 9) # 9 numbers from 0 to 2
|
np.linspace(0, 2, 9) # 9 numbers from 0 to 2
|
||||||
x = np.linspace(0, 2 * pi, 100) # useful to evaluate function at lots of points
|
x = np.linspace(0, 2 * pi, 100) # useful to evaluate function at lots of points
|
||||||
f = np.sin(x)
|
f = np.sin(x)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ def prettyPrintDictionary(myDict):
|
||||||
|
|
||||||
joke = get_joke()
|
joke = get_joke()
|
||||||
|
|
||||||
#prettyPrintDictionary(joke)
|
prettyPrintDictionary(joke)
|
||||||
|
|
||||||
print(joke['value'])
|
print(joke['value'])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,5 @@ result = json.loads(response.read())
|
||||||
|
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
print("\nPrint using Pretty Print\n")
|
||||||
pprint.pprint(result)
|
pprint.pprint(result)
|
||||||
|
|
|
||||||
39
bigos/lecture20251112/urllib/iss/iss-3a.py
Normal file
39
bigos/lecture20251112/urllib/iss/iss-3a.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
import json
|
||||||
|
import urllib.request
|
||||||
|
import turtle
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
url = 'http://api.open-notify.org/astros.json'
|
||||||
|
response = urllib.request.urlopen(url)
|
||||||
|
result = json.loads(response.read())
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
print(result)
|
||||||
|
|
||||||
|
print("People on the ISS: ",result['number'])
|
||||||
|
people = result['people']
|
||||||
|
#print(people)
|
||||||
|
|
||||||
|
#for person in people:
|
||||||
|
# print(person)
|
||||||
|
|
||||||
|
print("People on the ISS right now.")
|
||||||
|
for person in people :
|
||||||
|
print(f"\t {person['name']}")
|
||||||
|
|
||||||
|
|
||||||
|
url = 'http://api.open-notify.org/iss-now.json'
|
||||||
|
response = urllib.request.urlopen(url)
|
||||||
|
result = json.loads(response.read())
|
||||||
|
|
||||||
|
pprint.pprint(result)
|
||||||
|
|
||||||
|
location = result['iss_position']
|
||||||
|
latitude = location['latitude']
|
||||||
|
longitude = location['longitude']
|
||||||
|
|
||||||
|
print("The current position")
|
||||||
|
print('Latitude: ',latitude)
|
||||||
|
print('Longitude: ',longitude)
|
||||||
|
|
@ -52,4 +52,4 @@ iss.goto(float(longitude),float(latitude) )
|
||||||
|
|
||||||
# Print the map
|
# Print the map
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(15)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue