Home›Lesson Plans›Computer Science›Programming · Grade 10

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 crashing on bad or unexpected data. They order the steps, then validate input in code.

Grade 10Input Validation50 minutes1 class periodCSTA / ISTEExplicit teaching4 StandardsCSTA
Start the Lesson
Assign or share this lesson

Copy link works with Canvas, Schoology, Moodle and any other LMS — paste it in as a resource or assignment.

Lesson at a Glance

Everything you need before the bell rings

Learning Objectives

Students will be able to…

  • ✓Validate input.
  • ✓Check type & range.
  • ✓Handle bad input.
  • ✓Prevent crashes.
Essential Question

What happens when a user types something your program didn’t expect?

0
Lesson Phases
0
Vocabulary Terms
0
Standards Aligned
0
Interactive Task
Put in Order · Interactive

Order the Validation Steps

Project this and have students put the input-validation steps in order.

✅ Put the input-validation steps in orderTry it
Tap the first step of validating input!
The Lesson · Explicit teaching

50 minutes, five moves

Tap any phase to open the teacher moves and student actions.

1

Hook — Bad Input

5 min

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.
2

Use — Input Validation

12 min

Students learn.

👩‍🏫 Teacher Moves

  • Send students to Order the Validation Steps.
  • Order them.
  • Note handle bad input.

🎒 Student Actions

  • Order.
  • Say.
  • Note it.
3

Modify — Try It

13 min

Students practice.

👩‍🏫 Teacher Moves

  • Get a number input.
  • Check the type.
  • Check the range.

🎒 Student Actions

  • Get.
  • Type.
  • Range.
4

Create — Create

15 min

Students apply.

👩‍🏫 Teacher Moves

  • Add validation to a program.
  • Handle bad input.
  • Re-ask the user.

🎒 Student Actions

  • Validate.
  • Handle.
  • Re-ask.
5

Reflect — Reflect

5 min

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.
Standards Alignment

Built to the standards you report on

Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students.

CSTA
3A-AP-17

Validate input and handle errors.

CSTA
3A-AP-16

Design robust programs.

CSTA
3B-AP-21

Develop and test defensively.

ISTE
5c

Anticipate program edge cases.

Differentiation

One lesson, every learner

Multilingual Learners

ELL / EMERGING READERS
  • Validation step cards.
  • Frame: "first I get the ___."
  • Validate a tiny program.

Support & Access

IEP / 504
  • Use 3 core steps.
  • Check one type.
  • Use a template.

Stretch & Extend

GIFTED / EARLY FINISHERS
  • Validate with try/except.
  • Check a format (email).
  • Loop until valid.
Materials

What to gather

  • ⌨️Sample inputs
  • 📽️Screen / board
  • 💻Order the Validation Steps
  • 💻Python
  • 📓Notebooks
  • 🎫Exit-ticket slips
Vocabulary

Key terms — hover for a quick definition

input validationchecking user inputtype checkverifying the data typerangevalid min/max valuesformatthe expected patternedge casean unusual inputerror handlingdealing with problemsrobusthandles bad input wellpromptasking for input
Evaluate

Exit Ticket

Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students.

QUESTION 1
What is the first validation step?
Get the input from the user.
QUESTION 2
Why validate input?
To stop programs from crashing on bad data.
QUESTION 3
What do you do with bad input?
Handle it — ask again or show a message.

Reflect: input validation.

Have students add input validation to a program. A printable validation sheet is in the CS library.

Study · Flashcards

Study the key terms

Tap a card to flip it, then rate whether you knew it. Built from this lesson’s vocabulary.

🃏 Input ValidationFlip
Card 1
Term
Tap to flip →
Meaning
0

Nice work!

Practice · Quiz

Check your understanding

A quick self-check with instant feedback, drawn from this lesson’s key terms.

📝 Input ValidationQuiz
Score: 0
1 / 6
Question 1
0%

Nice work!

Practice · Worksheet

Printable worksheet

A print-and-go review sheet with a built-in answer key. Tap “Show answer key” to reveal answers, or print the clean version for students.

🖨️ Input ValidationPrint
Name: ________________________
Date: ____________

Part A · Write the word that matches each meaning

Word bank: edge case, error handling, format, input validation, prompt, range, robust, type check
  1. handles bad input well
  2. valid min/max values
  3. verifying the data type
  4. the expected pattern
  5. an unusual input
  6. asking for input
  7. dealing with problems
  8. checking user input

Part B · Show what you learned

  1. What is the first validation step?
  2. Why validate input?
  3. What do you do with bad input?
Answer key — Part A: 1) robust · 2) range · 3) type check · 4) format · 5) edge case · 6) prompt · 7) error handling · 8) input validation
Part B: 1) Get the input from the user. 2) To stop programs from crashing on bad data. 3) Handle it — ask again or show a message.