Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.
Join our LinkedIN Community.
Write a program that reads an integer number from the keyboard and
determines with the function is_prime
from the Checking if a number is prime exercise if it is a prime number. Write the program in such a way that it can be used to read several different numbers from the keyboard until the user writes the word end. When the user types something that is not an integer, you have to indicate it and give him the opportunity to write a number again.
You can test your program with the following tests:
>>> %Run
Write an integer number, or 'end' to finish: end
>>> %Run
Write an integer number, or 'end' to finish: 4
4 it is not a prime number
Write an integer number, or 'end' to finish: 97
97 is a prime number
Write an integer number, or 'end' to finish: -4
-4 it is not a prime number
Write an integer number, or 'end' to finish: hello?
just integer numbers or 'end' to finish!
Write an integer number, or 'end' to finish: x
just integer numbers or 'end' to finish!
Write an integer number, or 'end' to finish: end
>>>
Insist that the students test their programs by giving them example
test runs.