Activity 01
File Mode Challenge
Students create a text file with student data and write a Python script to open it in different modes: read to display content, write to overwrite, and append to add new entries. They note changes after each operation. This reinforces mode implications.
Explain the different modes for opening a file in Python and their implications.
Facilitation TipFor the File Mode Challenge, give students a single file and ask them to write three different snippets, each using a different mode, and observe how the file changes.
What to look forPresent students with three code snippets, each opening a file in 'r', 'w', and 'a' mode respectively. Ask them to predict the content of the file after each snippet executes and explain their reasoning.