Debugging and testing · 14 / 14 Exercise Easy

Boundary values

Objective

Create a Python program with a function whose most important test cases are at the boundaries of each interval: just before, right on and just after.

Instructions

  • Define classify_age(age), which returns: Invalid if the age is less than 0 or greater than 120; Child up to 12 years; Teenager from 13 to 17; Adult from 18 to 64; and Senior from 65 on.
  • Read an integer n and then n ages, one per line.
  • For each age, show age: category.
Input
4
-1
0
12
13
Output
-1: Invalid
0: Child
12: Child
13: Teenager

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise