Lab 11: File Operations
Practice reading from files and writing to files
- Find your partner
- Use CyberDuck to SFTP into one of your accounts on the
- On the server, navigate to the
- Download the
lab11folder to your Desktop (by dragging and dropping it from the CyberDuck window)
- Open Canopy and load the
lab11folder in the Canopy File Browser pane
Table of Contents
- What's the most important difference between writing output to the Canopy output window and writing output into a file?
Show AnswerAnyone who is familiar with Python programming will be able to see the output of a Python program. But even someone who knows nothing about Python might run a program and then look at a text file that it produced. So writing a file is a more general form of output that doesn't require familiarity with Canopy. Another important difference is that writing to a file can affect other parts of the computer: it's possible to destroy an important file by overwriting it.
- What's actually in a file when it's stored on your computer?
Show AnswerAt a technical level, just bits: ones and zeroes. But in terms of how Python relates to files, those bits are assumed to represent characters in a string, so we can think of files as containing strings. Even an image file or a sound file can be thought of as just a very complex string.