Chapter 3. Writing Programs

Up to now, we’ve been writing single Python statements and running them at the interactive command line. While that’s useful for learning about Python functions, it quickly becomes tiresome when you need to solve problems that require many lines of Python code.

Thus we turn to writing programs (also known as scripts). Programs are just text files containing a collection of Python commands. When you run (or execute) a program, Python performs each statement in the file one after the other.

In this chapter, we’ll learn how to write and run programs in IDLE and from the command line. We’ll see how to get keyboard input from the user and print strings to the screen.

This is just the first step in writing Python programs. In ...

Get Python: Visual QuickStart Guide, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.