The installed Python software package includes the Integrated DeveLopment Environment (IDLE) in which you can easily code and run programs, or snippets, written in the Python language. IDLE provides two different windows for program development:
- Shell Window
- Edit Window
When you start up IDLE it opens a new window containing a menu bar, a banner describing the version, and a >>> prompt. This is the Shell Window in which you can interact directly with the Python interpreter by entering statements at the prompt.
< Menu Bar
< Version Banner
< Interactive Prompt
If the interpreter understands your entry it will respond with an appropriate reply, otherwise it will report an error.
You can make the interpreter print out a string of text by entering a Python print() function statement that encloses your string within quote marks inside the parentheses at the interactive prompt.
You can also make the interpreter print out the result of a simple arithmetic sum by entering a valid sum statement at the prompt.
If your statement is not valid, such as a sum that attempts to divide a number by zero, the interpreter will print out an error message helpfully describing the nature of the error.
Most programming languages require text strings to be enclosed in quote marks to differentiate them from program code. By convention, Python coders use single quotes.
Open an IDLE Shell Window then precisely enter this statement at the interactive prompt
print( ‘Hello World!’ )
Next, hit the Return key to see the interpreter’s response
Now, enter this sum statement at the interactive prompt
8 + 4
Hit Return to see the interpreter print the result total
Spaces in statements are ignored – so 8+4 can be entered without spaces.
Enter this invalid statement at the interactive prompt
8 / 0
Hit Return to see the interpreter print an error message
… and it’s as easy as that!
For the complete Coding for Beginners guide, in the trusted In Easy Steps style, click here.
Coding for Beginners in easy steps has an easy-to-follow style that will appeal to anyone, of any age, who wants to begin coding computer programs. You need have no previous knowledge of any computer programming language so it’s ideal for the newcomer, including youngsters needing to learn programming basics for the school curriculum.