From the course: Programming Foundations: Beyond the Fundamentals

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Working with file input and output

Working with file input and output

- Data input and output can take a number of forms. At its most basic, a program can simply prompt a user to enter data and then work with the user's response. In Python, you can collect user info at the command line using the input method, which pauses your program and gives the user the opportunity to type a response. When the user presses enter, the program resumes and it can then incorporate the user's response into any processing and output. But many tasks require more data than a user can enter by typing. In these situations, your program can access other methods of input, like opening a file from your computer. For instance, to use a word processing program, like Microsoft Word or Google Docs, you often start by opening an existing file that you've saved on your computer or in the cloud. When the processing is done, your program can write the results back to the same file or to another file. This preserves the…

Contents