Page 40 -
P. 40
idle hands
Use IDLE to help learn Python
IDLE lets you write code in its full-featured code editor as well as experiment
with code at the Python Shell. You’ll use the code editor later in this book
but, when learning Python, IDLE’s shell really rocks, because it lets you try
out new Python code as you go.
When you first start IDLE, you are presented with the “triple chevron”
prompt (>>>) at which you enter code. The shell takes your code statement
and immediately executes it for you, displaying any results produced on screen.
IDLE knows all about Python syntax and offers “completion hints” that pop
up when you use a built-in function like print(). Python programmers
generally refer to built-in functions as BIFs. The print() BIF displays Unlike other C-based
messages to standard output (usually the screen).
languages, which use { and }
to delimit blocks, Python uses
Enter your code indentation instead.
at the >>> prompt.
See results
immediately.
IDLE knows
IDLE uses colored syntax to highlight your code. By default, built-in
functions are purple, strings are green, and language keywords (like if) are
orange. Any results produced are in blue. If you hate these color choices, Python’s syntax
don’t worry; you can easily change them by adjusting IDLE’s preferences. and helps you
IDLE also knows all about Python’s indentation syntax, which requires code
blocks be indented. When you start with Python, this can be hard to get conform to
used to, but IDLE keeps you straight by automatically indenting as needed.
the Python
indentation rules.
4 Chapter 1