## ASSIGNMENT 3

**Due date:** 10/11/16 at 10am

#### Exercise 1: Prime numbers

Your task is to write a function called `primes_in_range(first, last)`

that counts the number of prime numbers that are in the range between first and last (not including last).
To make the task easier, write a “helper function” that determines whether a given number is prime or not. Call it `is_prime(n)`

, and have it return a Boolean value that indicates whether the number given to it as input is prime or not. Now how to figure out whether a number is prime or not? Here is some guidance on how to do it:

The number 1 is not considered prime.

If n is even and greater than two then it clearly is not prime (the number 2 is considered prime).

Loop over all odd numbers up to the sqrt number of n. If at any point you find a number that divides n what do you need to do? How will you recognize that once the iteration is complete that the number is prime or not?

Note that are looping up to the sqrt of n is because if it is composite, then one of its factors is less than the square root of n.

And it also turns out that prime numbers have a biological significance!

#### Exercise 2: GC content

Write a function called `gc_content(sequence)`

that computes the GC content of a DNA sequence, i.e. the fraction of G or C nucleotides in the sequence. Your function should work regardless of the case in which the sequence is provided (upper/lower case). Note that a DNA sequence can contain positions that are ambiguous. These are represented by ambiguity codes. For example, 'N' denotes that any nucleotide is possible in that position. In computing GC content ignore positions that contain ambiguous nucleotides. For example, for the sequence

`TTACTNGGAGNT`

your function should return 0.4

An easy way to do this is to create a for loop in the form:

for nucleotide in sequence :
# do stuff

#### Exercise 3: Reverse complement

Write a function called `reverse_complement(sequence)`

that receives as input a DNA sequence and computes its reverse complement. For example, the reverse complement of AGTCATG is CATGACT. In computing the reverse complement assume that any character that is not A,C,G, or T is its own complement.

## Submission

Submit a single module named `assignment3.py`

via Canvas by the due date.
In writing your code use the following template. The “main” segment of the module should be used to test each of the functions.