The Python Shell
The Python Shell is an excellent tool to experiment with single lines of code.
Accessing the Python Shell
To access the Python Shell, in the terminal,
simply type $ python
. Make sure it opens to python
3.6
or higher. On some computers, many versions of Python may be
installed. On our Chromebooks, open the shell with $ python3.8
.
It should look something like:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Running commands
You will know you are in the Python Shell by the three greater-than signs >>>
.
You can then type in python code one line at a time to see the result.
>>> 3 + 5
8
>>> a = 6
>>> b = 2
>>> a + b
8
>>> a
6
Exiting the Python Shell
To exit the Python shell, press
ctrl + z
and press ENTER
(for Windows) or
ctrl + d
(for Linux).
In the shell, pressing ctrl + z
should look like:
>>> ^Z