Grade 5 · lesson 4 of 4

Count Accepted Results

Filter invalid inputs before counting those that meet a threshold.

Download the grade pack

Supplied materials

  • Paper and pencil; an adult may read aloud. No device, account or purchase is needed.

Learn the idea

Combining validation with counting requires a clear order. First decide whether an input is allowed; only then decide whether it meets the goal. A count of reached results is not the sum of page numbers and is not the number of all records. Increment the counter once for each qualifying record.

Use whole-number page inputs [9, 10, 31, 12, −1, 0]. Accept only 0 through 30 and count accepted values at least 10. Algorithm: set reached_count = 0; for each pages, if pages is valid and pages ≥ 10, add 1; show reached_count. Invalid values contribute zero even when numerically large.

  1. Create columns pages, valid?, meets goal?, and running count.
  2. Start reached_count = 0 before the loop.
  3. For each value, validate before checking the goal.
  4. Compare the final count with the qualifying inputs you circled.
Worked example

See the method in action

9 is valid but below goal; 10 qualifies; 31 is invalid; 12 qualifies; −1 is invalid; 0 is below goal. Running counts: 0, 1, 1, 2, 2, 2. Final reached_count = 2.

Your turn

Check your reasoning

Your answer is temporary and is not saved to an account. Download your current answer before leaving or reloading. Written work on paper or in another app stays in your own file.

For [10, 30, 40, 5], using the same contract and threshold, how many qualify?

Feedback appears here after you check. This is practice, not a graded school assessment.

See the answer and explanation

2

10 and 30 are accepted and at least 10. 40 is rejected and 5 is below the goal, so the count is 2.

Take it further

Change the goal threshold to 12 for the original list. Expected count: 1, from input 12 only; 31 remains invalid.

Nothing here is saved to an account or sent to a teacher. The answer download includes your current choice and any checked feedback.

Check the subject sources

These LifeStarter passages, scenarios and exercises are authored for this Academy with AI assistance and review. External resources keep their publishers’ terms. A grade label suggests a starting level; it does not establish alignment with your school’s complete requirements.