User Tools

Site Tools


assignment2

This is an old revision of the document!


ASSIGNMENT 2


Due date: 10/2/18 by 10 am

The exercises can be completed using only material covered so far.

Exercise 1

Write a function called nt_id() that evaluates whether or not a sequence entered by the user is DNA or RNA or unknown.

The sequence should be passed to the function and the return value printed as follows:

if __name__ == '__main__': 
	seq = input('Enter a sequence: ')
	print(nt_id(seq))

if name == 'main': basically means to execute the code within the body of the if statement only if the file is executed from the command line as a script.

Exercise 2

Write a function called stop_codon() that tests for the presence of a stop codon (UGA, UAA, and UGA) in an RNA sequence and returns a Boolean value indicating whether the sequence contains a stop codon. The sequence should be passed to the function as in 1.

Exercise 3

Write a function called peptide_length() that computes the maximum peptide length (an integer) that can be generated from a DNA or RNA sequence input by the user.

Exercise 4

Write a function called cube_root() that computes the cube root of a number. The function should contain a try and except clause that returns an informative error message if a non-numerical value is entered.

Hints:
1) Reassign the value input by the user to a float type in the cube_root() function, not in the input function.
2) The return value should be the cube root of the number if a valid number is entered or an error message if a valid number is not entered.

Exercise 5

Write a function called sum_num() that computes the sum of up to 4 numbers. You do not need to prompt the user for the numbers.

Exercise 6

Write a script that prompts the user for an RNA sequence, imports the module containing the stop_codon() function from exercise 2 and tests for the presence of a stop codon in the sequence. The script should print a message indicating whether the sequence contains a stop codon based on the return value of stop_codon().

To submit your assignment, combine the functions in exercise 1-5 along with the script in exercise 6 into one text file and upload it to Canvas.

assignment2.1538091485.txt.gz · Last modified: 2018/09/27 17:38 by dokuroot