Programming: create a file primes.py and copy the following isprime() function into it:
def isprime(num):
""" This returns True if the given int is prime, and False otherwise. """
if num <= 1:
return False
for i in range(2, num//2+1):
if num % i == 0:
return False
return True # If we reached here, then no divisor was found.
You must now define 2 more functions in primes.py. Add them below the provided isprime(num) function. You'll want to use isprime(num) for the second one:
# This code should print the number 4
words = [ "The", "zoo", "waz", "full", "of", "pandaz", "but", "OH", "NOEZ", "they", "died." ]
zees = countz( words )
print(zees)
# This code should print the number 17
next = next_prime(14)
print(next)
HINT: You can put the above code in your program (after your function definitions of course)! Run it and see if your functions produce the correct result! Once you are confident, remove the testing code and ONLY submit your file with three defined functions.
Submit your psearch.py to the online submission system under hw11-primes.
Make sure it has 3 function definitions, and nothing else in it.
submit -c=sd211 -p=hw11-primes primes.py