Activity 01
Pair Programming: Input Validator
Students pair up to code a while loop prompting for a positive integer until valid entry. Test with letters and negatives, then add range checks. Pairs swap codes to debug each other's work.
Compare the use cases for a for loop versus a while loop.
Facilitation TipDuring Pair Programming: Input Validator, ask one student to explain the condition after every input check to reinforce the link between validation and loop control.
What to look forPresent students with two code snippets: one using a for loop and one using a while loop to achieve a similar outcome (e.g., printing numbers 1 to 5). Ask them to identify which loop is more appropriate for a scenario where the number of iterations is unknown, like reading data until an empty line is entered.