-
Notifications
You must be signed in to change notification settings - Fork 0
/
Locate_the space_station.txt
41 lines (35 loc) · 959 Bytes
/
Locate_the space_station.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import json
from urllib.request import urlopen, Request
import turtle
import time
url = 'http://api.open-notify.org/astros.json'
request = Request(url)
response = urlopen(request)
print(type(response))
result = json.loads(response.read())
print(result, '\n')
print('People in Space:', result['number'],'\n')
people = result['people']
for p in people:
print(p['name'], '\n')
url = 'http://api.open-notify.org/iss-now.json'
request= Request(url)
response =urlopen(request)
result = json.loads(response.read())
print(result,'\n')
location = result['iss_position']
lat = location['latitude']
long = location['longitude']
print('Latitude:', lat)
print('Longitude:', long)
print('\n')
screen = turtle.Screen()
screen.setup(720,360)
screen.setworldcoordinates(-180, -90, 180, 90)
screen.bgpic(r'C:\Users\map.gif')
screen.register_shape(r'C:\Users\ss.gif')
ss = turtle.Turtle()
ss.setheading(90)
ss.penup()
ss.goto(float(long), float(lat))
ss.pendown()