Ask Question
6 August, 13:28

1. Write a program to prompt the user to enter a single character and respond back whether or not the character is valid dna. 2. Write a program to prompt the user to enter a single character and respond back whether or not the character is valid rna. 3. Write a program to prompt the user to enter a dna sequence and respond back whether or not the sequence is valid. 4. Write a program to prompt the user to enter a rna sequence and respond back whether or not the sequence is valid.

+2
Answers (1)
  1. 6 August, 14:26
    0
    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:

    print ("invalid")

    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:

    print ("invalid")

    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “1. Write a program to prompt the user to enter a single character and respond back whether or not the character is valid dna. 2. Write a ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers