Curriculum

Curriculum

Define the Valid Range for an Input

Scenario

A classroom quiz scores whole points from 0 through 100 inclusive.

Selected choicePick a choice below
Result—

Try it yourself

Check which values lie inside the valid range and which fall outside.

Reveal the explanation
  1. score = 0

    Valid lower bound. Normal pass/fail rule applies (Fail).

  2. score = 100

    Valid upper bound. Normal pass/fail rule applies (Pass).

  3. score = -1 or score = 101

    Out of valid range. Must trigger the declared invalid-input behavior.

Naming both endpoints (0 and 100) and whether they are inclusive lets every test agree on where valid data ends and invalid input begins.

Download shared test cases

Your turn

Declare the valid range for a study room with 8 total seats (requestedSeats and freeSeats).

Common mistake Forgetting the upper bound so freeSeats = 50 is accepted for an 8-seat room.

Check your work

Exact inclusive ranges: freeSeats in 0..8 and requestedSeats in 1..8 (whole integers).

Quick check

For a 6-seat study room, which pair states the valid range for freeSeats?
Show the answer and reasoning

Correct answer Any integer from 0 through 6 inclusive

A 6-seat room can have 0 (full) up to 6 (empty) whole seats available.