Coding · Grade 7
Structured Input and Validation
Learners discover why programs must check input, using a coding-club sign-up form that keeps crashing. They classify presence, type, range, length and format checks, write checks with string methods, build validation loops that re-ask until input is valid, handle conversion errors with try and except, and choose normal, boundary and invalid test data.
- 4 lessons
- About 85 minutes
- Check what you learned: 8 questions
- Ways to answer: fill in the blanks, choose an answer, put code in order, trace code, sort into groups and true or false
What learners will discover
- Explain why input is validated and classify presence, type, range, length and format checks.
- Write validation checks using strip(), isdigit(), len() and range comparisons in a safe order.
- Use a validation loop and try/except to handle invalid input without crashing.
- Choose normal, boundary and invalid test data with expected outcomes for a validation rule.
Lessons
-
Why programs check their input 5 steps2 practiceabout 18 min
-
Writing validation checks 6 steps4 practiceabout 22 min
-
Re-asking and handling errors 6 steps3 practiceabout 22 min
-
Choosing test data for validation 5 steps2 practiceabout 16 min
-
Check what you learned 8 questions at the end
Keep exploring
Games to practice with
- Bug DetectiveA robot program almost works. Run it, spot the buggy block, and fix it.
- Sorting FactoryTurn a work order into if/else rules and watch the conveyor sort every item.
- Garden AutomationProgram a garden robot with sensor rules — then watch a whole day play out.
More 7th grade coding
- 7th Grade Coding Games4 games to play free
- 7th Grade Coding Worksheets11 printable worksheets
Guide for grown-ups
- How to start homeschooling: a step-by-step guide for familiesA guide for parents · 7 min read