Skip to content

Language

Sign in

Python file modes: activity sheet

Goal: See what the open() modes r, w, a and r+ do to a text file that exists or is missing.

You need: Only the simulation is needed. You can repeat it later in Python with a scratch file.

Safety: No special safety needs.

  1. Open the existing file with 'r' and note what changes.
  2. Open it with 'w' and write HELP.
  3. Repeat with 'a' and 'r+'.
  4. Try 'r' on a missing file and record the error.
My observations
ModeFile existedText writtenResult in file

Use your browser's Print option to print this page.

Ask Flint AI
EduFlint: learn and play for free