Is prime or not
A prime number can only be divided by itself and 1 without remainders. In this exercise, you will test the function the is_prime() with unittest. The function gets a number and returns True if it is prime and False if it is not. It uses the math package to calculate the square root of the number. The packages math and unittest were already imported for you.
Bu egzersiz
Introduction to Testing in Python
kursunun bir parçasıdırUygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
def is_prime(num):
if num == 1: return False
up_limit = int(math.sqrt(num)) + 1
for i in range(2, up_limit):
if num % i == 0:
return False
return True
class TestSuite(unittest.TestCase):
def test_is_prime(self):
# Check that 17 is prime
____