Answer:
Answer 1:
dna = input("Enter DNA type: ")
dna = dna.upper()
print(dna)
if dna == "A" or dna == "B" or dna == "Z":
print("valid")
else:
print("invalid")
Answer 2:
rna = input("Enter DNA type: ")
rna = rna.lower()
print(rna)
if rna == "m" or rna == "t" or rna == "r":
print("valid")
else:
print("invalid")
Answer 3:
dnaSquence = input("Enter the DNA sequence: ")
type = "valid"
for char in dnaSquence:
if char not in ["A", "C", "G", "T"]:
type = "invalid"
break
print(type)
Answer 4:
rnaSquence = input("Enter the RNA sequence: ")
type = "valid"
for char in rnaSquence:
if char not in ["A", "C", "G", "U"]:
type = "invalid"
break
print("valid")
Explanation:
There are three types of DNA; Type A, Type B and Type Z.
A DNA sequence consists of; A, C, G and T.
There are three types of RNA; mRNA, tRNA and rRNA.
An RNA sequence consists of; A, C, G and U.
Code Explanations:
Code 1:
dna = input("Enter DNA type: ")
dna = dna.upper()
print(dna)
if dna == "A" or dna == "B" or dna == "Z":
print("valid")
else:
<em> print("invalid")</em>
- prompts and Takes a single character input
- converts the character to upper case
- compares the input to the DNA types
- Prints "valid" for a valid input else prints "invalid"
Code 2:
rna = input("Enter DNA type: ")
rna = rna.lower()
print(rna)
if rna == "m" or rna == "t" or rna == "r":
print("valid")
else:
<em> print("invalid")</em>
<em />
- prompts and Takes a single character input
- converts the character to lower case
- compares the input to the RNA types
- Prints "valid" for a valid input else prints "invalid"
Code 3:
Answer 3:
dnaSquence = input("Enter the DNA sequence: ")
type = "valid"
for char in dnaSquence:
if char not in ["A", "C", "G", "T"]:
type = "invalid"
break
print(type)
- It prompts for a DNA sequence.
- Declares a string variable "type" and initializes type to valid.
- The FOR loop checks every character in the DNA sequence.
- If the character is not in the list [A, C, G, T] type becomes invalid and the loop breaks and the type "invalid" is printed to the screen.
- if all the characters are in the list, then type will remain valid and will be printed to the screen.
Code 4:
rnaSquence = input("Enter the RNA sequence: ")
type = "valid"
for char in rnaSquence:
if char not in ["A", "C", "G", "U"]:
type = "invalid"
break
print("valid")
- It prompts for a RNA sequence.
- Declares a string variable "type" and initializes type to valid.
- The FOR loop checks every character in the RNA sequence.
- If the character is not in the list [A, C, G, U] type becomes invalid and the loop breaks and the type "invalid" is printed to the screen.
- if all the characters are in the list, then type will remain valid and will be printed to the screen.