Question: In this homework assignment, you will write a program that prints out pairs of twin primes. Since that may sound a bit overwhelming, we've broken

In this homework assignment, you will write a program that prints out pairs of twin primes.
Since that may sound a bit overwhelming, we've broken up this process into a few steps for you.
First, write a function that determines whether or not a number is a prime number. As a
reminder, a prime number is a number that only has two factors: 1 and itself. Note that 0,
and 1 are not prime numbers, and that 2 is a prime number. You can not look up any
formulas or algorithms online to determine if a number is prime. You must use the
information above to write your own algorithm to determine if a number is prime.
Your function must have the following function header:
def is_prime(num)
As seen from the function header, the function should be named is_prime and have
one parameter, num. This function should return a boolean that indicates whether or not
the number is prime. More specifically, if the number passed into this function is prime,
the function should return True. If the number passed into this function is not prime,
the function should return False.
After writing the is_prime function, it's time to begin testing! Programmers often
write test cases to ensure that their code has been written correctly. While there are
useful Python frameworks designed specifically for testing (such as unittest, which you
are welcome to read more about if you are interested), we will not be using them in this
class (due to time constraints that don't allow us to fit this into our curriculum). Instead,
we will test our code by calling the functions we want to test in main, printing out the
functions' return values, and manually checking that the functions return what we
expect.
Write a main function that has three test cases for is_prime. Each test case should call
is_prime with a different argument and print out the return value of the function call.
Then, you should manually check that the return value is correct (according to whether
the argument is actually prime or not).
A comprehensive group of test cases will test different paths of execution that the
is_prime function may take. Put another way, all the test cases should not use just
prime numbers or just non-prime numbers as the arguments, since then your test cases
are never checking that the function behaves correctly in the other situation. We will be
grading this part of the assignment manually and checking that you wrote a
comprehensive group of test cases.
If your code fails the test cases, now is the time to go back and fix your is_prime
function! You will use the is prime function in the next part of this assignment, so
In this homework assignment, you will write a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!