Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

LinkedIN Community

Join our LinkedIN Community.

Is this character a digit? - part two

Write a program that reads a character from the keyboard and determines with the function is_digit from the previous exercise if it is one of the digits from 0 to 9. Write the program in such a way that it can be used to read several different characters from the keyboard until the user writes the word end.

An example of a test session you can execute manualy via the shell could be:

>>> %Run 
    Write a character or 'end' to finish: 4
    4 is a digit from 0 to 9
    Write a character or 'end' to finish: 56
    56 is not a digit from 0 to 9
    Write a character or 'end' to finish: z
    z is not a digit from 0 to 9
    Write a character or 'end' to finish: dfg
    dfg is not a digit from 0 to 9
    Write a character or 'end' to finish: 0
    0 is a digit from 0 to 9
    Write a character or 'end' to finish: end
>>>    
Insist that the students test their programs by giving them example
test runs.