讲解:CMPS 5P、Python、Python、CanvasProcessing|Python

CMPS 5P Homework 2 Spring 19Instructions1. The aim of this assignment is to practice selection (if, else, and elif) and repetitionstructures (while, and for) in Python.2. The deadline for the assignment is 04/22/2019 (Monday) 11:59 PM.3. The grade of the assignment is out of 100 pts.4. Students must use Python3 (NOT Python2) to write the code.5. Don’t share code or get code from the internet, but working together is encouraged. Ifyou choose to work with someone you must mention them in one of the first commentsin the file.6. Students are expected to write the code that is easily readable. To this end, they mustemploy meaningful variable names and comment their code properly.7. The output of the code requires to be precisely as shown in the sample runs.8. Students must put the code in a file named FirstName LastName StudentID HW2.pyand submit it through Canvas. Please notice that failing to comply any of these requirementswill result in losing points at the discretion of the grader.Grading The assignment is out of 100 points. It is important that you practice commentingyour code, so each file submitted without comments will have 5 points deductedfrom its score (even if the program works perfectly)! Furthermore, the formatting of thethe file names (described in item 8) is important for us to grade all 240 assignments, sosubmissions which are not named in this way will have 5 points deducted from their overallscore.Problem 1Write a Python3 script which takes in a single stranded DNA sequence from the user andprints out the ‘GC’ content and molecular weight of the single stranded circular DNAmolecule.DNA is made up of four nucleotides, thymine (T), cytosine (C), adenine (A), or guanine (G).These are represented as strings of only A, C, G and T characters of either upper or lowercase).The program should prompt the user for a DNA sequence. If the provided string is not anucleotide sequence (i.e. contains any non A, C, G, T characters of either case), print an1CMPS 5P Homework 2 Spring 19error message and prompt the user for another DNA sequence. NOTE: the program needsto handle any mixture of upper and lower cases for the DNA sequence!Once a valid DNA sequence is entered by the use代做CMPS 5P作业、Python课程设计作业代写、代做Python编程作业、Canvas留学生作业代写 代做Procr, then calculate the ‘GC content’ - thefraction of G and C nucleotides in the sequence. For example, if the user entered ’ATGC’the ’GC’ content would be 50% because the sequence contains 2 G or C nucleotides and 4characters in total.Next calculate the total molecular weight of the DNA sequence in Daltons. The given nucleotideweights for each nucleotide is shown below in Table 1. For example, if the userentered ‘ATGC’ the molecular weight of the single stranded DNA sequence would be 1235.80Da.In detail the following steps should be followed:1. Prompt user for single stranded DNA sequence with the message”Input DNA Sequence: ”2. Check if input contains any characters not in {“T”, “A”, “G”, “C”, “t”, “a”, “g”, “c”}3. If the user entered an incorrect string, report error:“ERROR: Not a DNA sequence: user-input-seq”where user-input-seq is the input sequence, then prompt the user again.4. Calculate the molecular weight of the single stranded DNA using Table 1.5. Output the result with“DNA sequence weighs: weight Da”and round the weight to the second decimal position6. Calculate percent of G’s and C’s in the string and report“GC content of DNA sequence is: percentage”and round the percentage to the second decimal position.7. Ask the user if they want to analyze another sequence with the message“Analyze another DNA Sequence (y/n)?: ”8. If the user inputs ‘y’ then go through the loop again. If ‘n’, then exit, if neither y norn, then ask again.2CMPS 5P Homework 2 Spring 19Table 1: DNA nucleotides’ molecular weightsDNA Nucleotide Molecular weight (Da)Thymine 304.20Cytosine 289.18Adenine 313.21Guanine 329.21Example RunsEXAMPLE 1Input DNA Sequence: ATGCDNA sequence weighs: 1235.80 DaGC content of DNA sequence is: 50.00Analyze another DNA Sequence (y/n)?: yInput DNA Sequence: atgcDNA sequence weighs: 1235.80 DaGC content of DNA sequence is: 50.00Analyze another DNA Sequence (y/n)?: nEXAMPLE 2Input DNA Sequence: AFtTT!ERROR: Not a DNA sequence: AFtTT!Analyze another DNA Sequence (y/n)?: yInput DNA Sequence: AGTTTDNA sequence weighs: 1555.02 DaGC content of DNA sequence is: 20.00Analyze another DNA Sequence (y/n)?: n3转自:http://www.7daixie.com/2019052248576076.html

你可能感兴趣的:(讲解:CMPS 5P、Python、Python、CanvasProcessing|Python)