Programming with Python

Running and Quitting

Overview

Teaching: 5 min
Exercises: 0 min
Questions
  • How can I run Python programs?

Objectives
  • Launch iPython.

  • Run some simple python commands.

  • Exit the iPython interpreter.

Python programs are plain text files.

Start iPython

$ ipython

The iPython interpreter

A few simple commands

Upon executing the iPython command, the following prompt will appear at the bottom of your screen.

In [1]:

The In portion indicates that iPython is waiting for input and the [1] indicates that this is the first command we’ll run in the iPython session.

Let’s start by running a few simple commands to get a feel for interacting with this interpreter.

Type the following command and press return.

In [1]: 2 + 7

After pressing return you should see something like the following.

Out [1]: 9

Here the Out is indicating that this is the output from the code we executed in command [1].

For the remainder of the workshop, these lessons won’t include the input/output portions shown here but rather just the commands and resulting output.

Installing iPython on your own machine

Key Points