6
User Inputs and Outputs
The key purpose of software is to produce useful output. Of the many possible outputs, one simple type of output is text displaying a useful result. Python supports this with the print() function.
The input() function has a parallel with the print() function. The input() function reads text from a console, allowing us to provide data to our programs. The use of print() and input() creates an elegant symmetry between input and output from an application.
There are a number of other common ways to provide input to a program. Parsing the command line is helpful for many applications. We sometimes need to use configuration files to provide useful input. Data files and network connections are yet more ways to provide input. Each of these methods is distinct and needs to be looked at separately. In this chapter, we’ll focus on the fundamentals of input() and print().
In this chapter, we’ll look at the following recipes:
-
...