rightph.blogg.se

Thonny for android
Thonny for android







The names of all the astronauts on the International Space Station will appear in the Python Shell.

#Thonny for android code

Save the code and when ready click on Run to start the code.ħ. We then use another key, ‘name’ to get the name of that astronaut. Our dictionary ‘astronauts’ has many keys, but we are interested in the ‘people’, the value of “i” will increment each time the loop goes round, and it selects each person from a list embedded in the dataset. Print the name of each astronaut on the International Space Station using a series of keys that target the specific data. This value could change as astronauts come and go, so rather than hard coding a value we use the live data. Create a for loop that will iterate for the number of people on the International Space Station. The value linked to that key is then stored in the number object. Create an object, number, which will open the astronauts object, and look for the key ‘number’. JavaScript Object Notation is an open standard file format which bears a striking resemblance to Python’s Dictionary which uses keys (names) to retrieve values from the object.

thonny for android

After print(wlan.isconnected()) add a new line which creates an object “astronauts” and then uses urequests to get the information in a JSON format. This module enables us to work with network requests such as HTTP and JSON. Add a line after “import time” and import the urequests module. We are going to adapt our previous example code, Wi-Fi.py.ġ. This has the number and names of all the astronauts currently on the International Space Station. For this example we are going to use Open Notify’s “How many people are in space right now” dataset. Now that we have an Internet connection, we will use it with publicly available datasets to pull data from external sources and display it on the Pico W.







Thonny for android