Day 1

Computing as an Interdisciplinary Toolkit

The Powerpoint presentation we gave in the auditorium (and a PDF version of it) are available.

SoftDes is a class designed to:

SoftDes is NOT a class that:

Themes covered

Some course that are illustrated (intentionally or inadvertently) in class:

This course teaches several levels:

Programming Languages

Learning a programming language is like learning a (non-native) natural language. The first one is difficult. Each new one is easier, with a speed bump if it’s not in the same family as the ones you know. (Going from French to Spanish to Italian is easier than going from French to German to Russian to Japanese.)

Why Python?

On the other hand, Python is slower than most of these (although including its libraries makes this comparison harder), doesn’t run on mobile, doesn’t run on resource-constrained devices (such as the Arduino), and doesn’t run in the browser.

Deciding which language to use is an example of a tradeoff, given a context and constraints. This is an engineering idea.

Python is also a tool that a growing number of hobbyists and professionals who have different dispositions use. You might encounter python examples from communities who want to: leverage programming to be more expressive and make beautiful artifacts; help automate tasks while optimizing for efficiency; or advance knowledge in the sciences - to name a few.

Note that this course changes because the context (coding and Python technology and community) continues to evolve.

Materials

Activity 1 – Get Started

1. Setup your development environment

Follow the instructions on the Setup Your Environment page.

2. Open a Terminal Window

In this course you will make use of the Terminal program. Press cmd+alt+T, or launch the Terminal from your Programs menu.

Launching Terminal or (Anaconda) Command Prompt is called “creating a terminal session”.

Typing into a terminal session is called “in a terminal session”, “in a terminal”, or “in the shell”

Typing some text – such as ls – and then pressing the Enter or Return key, is called “entering command“ or “running command”, where command is the entered text.

3. Explore Python

Enter python. This starts the python interpreter.

You should see something like this:

Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Details such as the date, and the material inside brackets […] will differ. The first line should say Python 3.6.x, where x is some digit. If it says Python 2.x.y check in with a NINJA.

The chevron’s >>> are Python’s prompt. Python is waiting for you to type something. Type 42 and press Enter. You should see something like:

>>> 42
42

Now type 40 + 2:

>>> 40 + 2
42

Try out using Python as a calculator:

4. Quitting Python

To quit Python, enter quit() or press control+d (hold the control key; press the d key; and then release them in either order).

Activity 2 – Jupyter

1. Create a new directory

In a terminal window, create a new directory: mkdir notebooks.

Set the terminal session to use that directory: cd notebooks.

Now this terminal session is “in” the notebooks directory.

2. Launch Jupyter

In the same terminal window, enter jupyter notebook. This should open a new window or tab in your web browser. The page in this window or tab will show a list of files in the directory. Since the notebooks directory is empty, it should show an empty list.

3. Create a Notebook

In the New menu, select Python 3. (Your Python may have a slightly different name, such as Python [default] or Python [conda root].)

Type 40 + 2 into the cell.

Using the icons and the “cell type” popup menu (Code, to the right of the icons) at the top of the page to do the following:

4. Quit Jupyter

Press the Save icon (the leftmost icon, that looks like a floppy disk from the 90’s) to save your Jupyter notebook. Close the tab or window.

Find the terminal session that is running jupyter notebook. Press control-c. (Hold the control key down, and while it is down press c. Then release them in either order.)

You will see some messages, including Shutdown this notebook server (y/[n])?. This is another prompt. Answer it by typing y, and then return.

(Control-c requests that a program that you have started from the terminal, stop. It works on more programs than just jupyter.)

In the terminal, enter ls (Linux or macOS) or dir (Windows). You now see a file named Untitled.ipynb. The file suffix .ipynb standards for “iPython Notebook” (“iPython” was the original name for “Jupyter”). It means that the file is a Jupyter notebook.

Going Beyond

For Next Time