Activity 01
Pair Programming: Error-Proof Reader
Pairs write a Python script to read a text file of quiz scores, calculate the average, and print it. Add try-except for FileNotFoundError and ValueError from bad data. Test by deleting the file or editing inputs.
Explain the importance of error handling when performing file operations.
Facilitation TipDuring Pair Programming: Error-Proof Reader, circulate and listen for students explaining their error-handling logic to each other out loud.
What to look forProvide students with a short Python code snippet that attempts to read from a non-existent file without error handling. Ask them to predict the output and explain why the program might crash. Then, ask them to modify the code to include a try-except block to handle the 'FileNotFoundError'.