Activity 01
Pair Program: Input Validator
Pairs begin with a simple program that asks for numbers but crashes on letters. They add a try-except block to catch ValueError, print a friendly message, and reprompt. Test with varied inputs and refine together.
Justify the importance of error handling in user-facing applications.
Facilitation TipDuring Pair Program: Input Validator, circulate and ask each pair to trace the exact line that could raise ValueError before they write the first except block.
What to look forProvide students with a short Python code snippet that attempts to convert user input to an integer without error handling. Ask them to write one sentence explaining what error might occur and then modify the code to include a try-except block that catches this specific error and prints 'Invalid input'.