2.6) Alternating Interactive Commands And Running Programs
One of the great features of Python is that you can use it both interactively by typing one line at a time and by running a program. When you write long programs, it is very useful to test commands interactively before adding them to your program. Alternating between interactive commands and running a program will help you learn Python and considerably speed up your writing time.
In the rest of this course:
- Code to be run interactively will start with >>>
- Code to be added to a file will not be preceded by anything
- When writing a program, test individual commands before adding them to your script. For example, if you're unsure how to write something, how to calculate a power or how to manipulate a string, try out a simple test interactively first.
Remember:
- The prompt will print out results of operations, but those will not be printed in your program.
- When you run a program in IDLE it forgets everything that was done before and starts from scratch. This will become clear in the following pages.