# Input Validation > Tenth graders learn input validation — checking that user input is the right type, range, and format before a program uses it. Validation keeps programs from… **Computer Science** | **Grade 10** *A free lesson plan from K12 Academics. Source page: https://lessonplans.k12academics.com/k12-lesson-g10-cs-input-validation.html* Tenth graders learn input validation — checking that user input is the right type, range, and format before a program uses it. Validation keeps programs from crashing on bad or unexpected data. They order the steps, then validate input in code. **Copy link** works with Canvas, Schoology, Moodle and any other LMS — paste it in as a resource or assignment. ## Everything you need before the bell rings ### Learning Objectives Students will be able to… - **Validate** input. - Check **type** & range. - **Handle** bad input. - Prevent crashes. What happens when a user types something your program didn’t expect? ## Order the Validation Steps Project this and have students put the input-validation steps in order. ## 50 minutes, five moves Tap any phase to open the teacher moves and student actions. ### Hook — Bad Input What if your program asks for a number and the user types "banana"? #### 👩‍🏫 Teacher Moves - Pose the question. - Share ideas. - Set the goal. #### 🎒 Student Actions - Think. - Share. - Get ready. ### Use — Input Validation Students learn. #### 👩‍🏫 Teacher Moves - Send students to Order the Validation Steps. - Order them. - Note handle bad input. #### 🎒 Student Actions - Order. - Say. - Note it. ### Modify — Try It Students practice. #### 👩‍🏫 Teacher Moves - Get a number input. - Check the type. - Check the range. #### 🎒 Student Actions - Get. - Type. - Range. ### Create — Create Students apply. #### 👩‍🏫 Teacher Moves - Add validation to a program. - Handle bad input. - Re-ask the user. #### 🎒 Student Actions - Validate. - Handle. - Re-ask. ### Reflect — Reflect Students close. #### 👩‍🏫 Teacher Moves - What’s the first step? - Why validate input? - Complete the exit ticket. #### 🎒 Student Actions - Say it. - Say it. - Complete the exit ticket. ## Built to the standards you report on Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students. Validate input and handle errors. Design robust programs. Develop and test defensively. Anticipate program edge cases. ## One lesson, every learner ### Multilingual Learners - Validation step cards. - Frame: "first I get the ___." - Validate a tiny program. ### Support & Access - Use 3 core steps. - Check one type. - Use a template. ### Stretch & Extend - Validate with try/except. - Check a format (email). - Loop until valid. ### What to gather - ⌨️Sample inputs - 📽️Screen / board - 💻Order the Validation Steps - 💻Python - 📓Notebooks - 🎫Exit-ticket slips ### Key terms - **input validation**: checking user input - **type check**: verifying the data type - **range**: valid min/max values - **format**: the expected pattern - **edge case**: an unusual input - **error handling**: dealing with problems - **robust**: handles bad input well - **prompt**: asking for input ## Exit Ticket Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students. ### Reflect: input validation. Have students add input validation to a program. A printable validation sheet is in the CS library. ## Check your understanding **1. What does “input validation” mean?** - dealing with problems - verifying the data type - checking user input *(correct)* - asking for input “input validation” means: checking user input **2. Which word means: “verifying the data type”?** - prompt - type check *(correct)* - edge case - robust “type check” means: verifying the data type **3. What does “range” mean?** - checking user input - valid min/max values *(correct)* - handles bad input well - an unusual input “range” means: valid min/max values **4. Which word means: “the expected pattern”?** - format *(correct)* - edge case - prompt - error handling “format” means: the expected pattern **5. What does “edge case” mean?** - an unusual input *(correct)* - dealing with problems - handles bad input well - checking user input “edge case” means: an unusual input **6. Which word means: “dealing with problems”?** - input validation - type check - edge case - error handling *(correct)* “error handling” means: dealing with problems ## Printable worksheet --- Full lesson page: https://lessonplans.k12academics.com/k12-lesson-g10-cs-input-validation.html All lessons: https://lessonplans.k12academics.com/