The Python Shell

The python shell

There are different ways we can use Python, depending on what we want to do. One of these ways is the shell.

When we use the Python shell, each command is run as soon as we finish typing them.

Try opening the shell to see how it looks.

The Python Shell is an area where we can type Python commands.

Opening the Shell

Windows

Option 1: Click Start, then find Python in the start menu

Option 2: Open a command prompt, then type python

Linux

Open a terminal, and then type python3.

Note: If you run python (without the ‘3’) Python version 2 will open

Online

If you don’t have Python installed yet, you can use it online.

Open a browser, and go to python.org/shell

If you look at the shell, one of the lines starts with three ‘greater-than’ symbols (>>>). This is called the prompt. The prompt is where you type your command.

I understand if you’re thinking “this shell thing looks really boring”. I get it. It’s just a blank screen that we type in. It will get more interesting as we learn more, I promise. We’ve got to start with the basics before we move on though.

We’ll start with something simple. Type in a number. Any number will do. Then press enter. The shell will write that number on the screen on the next line. Please try to contain your excitement.

You can try some basic math too if you want to. For example, type in 6 + 6 and press enter. The shell will write the answer on the screen.

You can try addition (+), multiplication (*), division (/), subtraction (-), brackets, or a combination of all of them.

Give it a try now and see what happens.

Python 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 6
6
>>> 6+6
12
>>> 12*(3+7)-(8/2)
116.0

Next…

Next, we’re going to use the shell a bit more, and write (print) text to the screen.

Leave a Reply