6
User Inputs and Outputs
The key purpose of software is to produce useful output. One simple type of output is text displaying some 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.
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() ...
Get Modern Python Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.