Your first program in Python

Learn to write Python script and install third party packages using pip.

Code App comes with many built-in languages including C++, Python and others. To see the full list, click the link below:

pageSupported Languages

A Hello World program in Python

Let's start by creating a Python source file. Expand the file explorer side bar and select the new file icon (document with a plus icon). You can either use the built in template or enter a custom file name to create an empty file.

For now, let's use the built in template.

You should now see the hello world program written in Python. Tap the play button to run it.

Congratulations! You now ran your first program on Code App.

Python - Installing a third party module

Third party modules allow you to do awesome things, including making network requests to a web server, drawing charts to analysis data, or downloading a YouTube video.

Code App comes with the pip command in the terminal. To install a modules, just type pip install <module name> in the terminal.

Note that not all modules work on Code App, see the FAQ for more.

In this example, we will try out the requests module. It allows Python to make network requests to web servers. Let's try to get the list of people currently in the space.

Tap on the chevron button to bring up the terminal and type pip install requests in the terminal.

Copy the following code to your source file and click run:

import requests

res = requests.get('http://api.open-notify.org/astros.json')
print(res.text)

Cool! You now have the list of all astronauts currently on their mission in the space.

Last updated