Data Wrangling Course

James Howison's Data Wrangling course from the Information School at the University of Texas at Austin.

Hello World in Python

In this class we test our setup by getting a very simple Python script up and working. “Hello World” has a venerable history in programming and XKCD has a comic specifically about Hello World in Python.

For online learning the rest of Spring 2020, we will be using the Docker installs that we have in place on our laptops. Details of the setup are on the Tech Setup page (which we did earlier in the semester, so ideally nothing should need to be installed).

You will be working in the Jupyter Notebook. When you have run docker-compose up you will be able to access that from the Application Links.

For teaching materials I have screencasts, showing my screen while I provide audio narrative. These use exactly the same code, but unfortunately these are from two semesters ago and do not use Jupyter Notebooks. The major difference is that in the screencasts I’m editing the code in a code editor and executing it on the command line (and the output shows up on the command line as well). Happy things are simpler in Jupyter Notebook, because the code and output shows up in the browser window. DataCamp also uses embedded Jupyter Notebooks.

You “The Programming Historian” has a useful introduction to the Jupyter Notebook interface. Read down from that link to the first paragraph of “Working in Jupyter notebooks”.

Creating a new Jupyter Notebook file

Navigate to your Docker jupyter notebook. Log in with the password data. You will see the Jupyter file browser interface. The embedded video below shows creating a new Python 3 notebook (click to play/pause/restart).

You can then name the file, by clicking on the name at the top, which is “Untitled” by default.

You can then copy the code from the code sections on these pages into cells in Jupyter. You execute the code by hitting shift-enter (or clicking the “Run” button). You see relevant output immediately below that cell.

Here is the screencast for this week, which uses a different application but is useful nonetheless: Hello World in Python.

You can copy this code into a cell in Jupyter, after creating a new Notebook.

print("Hello World!")