Try It Yourself: Explore the Python Interactive Shell
This is your chance to try out the interactive shell yourself! Follow these steps to enter
a print function statement into the Python interactive shell and then exit from it:
- If you have not already done so, power up your Raspberry Pi and log in to the
system. - If you do not have the LXDE GUI started automatically at boot, start it now by typing
startx and pressing Enter. - Open the LXTerminal by double-clicking the LXTerminal icon.
- At the command-line prompt, type python3 and press Enter. You are now in the
Python interactive shell.
Watch Out!: Take Time
Before you press that Enter key, take time to review your Python statements. It
is very easy to leave out a quotation mark or use the wrong case on a command
(for example, Print instead of print). Getting into the habit of reviewing
your commands before you press Enter will save you lots of frustration and
time later on.
- At the >>> prompt, type print ("This is my first Python
statement!") and press Enter. You should see the shell display This is my
first Python statement! Pretty cool! You have taken your first small step
toward lots of great Python programming.
Watch Out!: My Keyboard Doesn’t Work!
When you press the " (double quote) key, if you get an @ symbol instead, then
your keyboard isn’t correctly configured. Go back to the “Checking the
Keyboard” section earlier in this hour.
- To exit the Python interactive shell, type exit () and press Enter.
Learning About the Python Development Environment Shell
A development environment shell is a single tool for creating, running, testing, and modifying Python
scripts. Often development environments color code key syntax for easier identification of various
statement features. This color coding helps with a script’s testing, modification, and debugging.
Another nice feature is automatic code completion. As you type Python syntax, the development
environment provides screen tips to help you complete your code.
In addition to these features, a development environment shell can provide syntax checking so that you
can find any incorrect Python syntax without having to run the entire Python script. To maintain
consistent indentation within a script, environment tools often provide automatic indentation.
Finally, debugging tools within the environment allow you to step through a Python script to uncover
logic errors. What doesn’t a development environment shell do? Well, it can’t write a Python script