Activity 01
Pair Programming: Safe Calculator
Pairs write a calculator program that takes two numbers from user input. Add a try-except block to handle division by zero with a polite error message and prompt retry. Test with invalid inputs like letters to refine except clauses.
Explain the importance of error handling in creating robust and user-friendly programs.
Facilitation TipDuring Safe Calculator, circulate and ask each pair to predict what error would occur with invalid inputs before running the code.
What to look forProvide students with a short Python code snippet that includes a potential ZeroDivisionError. Ask them to write the try-except block needed to handle this error and explain in one sentence what their code does if the error occurs.