Please enable JavaScript to use CodeHS

  • Autograded
  • Beginners

Transcribe DNA to RNA

In this project, students will write a program to use conditional statements transcribe a DNA string into an RNA string.

Easy

1 Hour

High School

Middle School

Project Description

Background

A nucleic acid is a chain of nucleotides that stores genetic information in the biological system. Each nucleotide contains a sugar, phosphate group, and nitrogen base.


Nucleic acids come in two natural forms called deoxyribonucleic acid (DNA) and ribonucleic acid (RNA). DNA consists of four nitrogenous bases: adenine, cytosine, guanine, and thymine. RNA consists of four nitrogenous bases: adenine, cytosine, guanine, and uracil.



Transcription is the process of copying a segment of DNA into a new molecule of messenger RNA.


To transcribe a DNA sequence into a sequence of messenger RNA, apply the following rules of complementary nitrogenous base pairing:

  • DNA’s guanine (G) base is complementary to RNA’s cytosine (C) base.
  • DNA’s cytosine (C) base is complementary to RNA’s guanine (G) base.
  • DNA’s thymine (T) base is complementary to RNA’s adenine (A) base.
  • DNA’s adenine (A) base is complementary to RNA’s uracil (U) base.


Example:

Consider the following DNA sequence:

AAGCTGGTTTTGACGAC

The messenger RNA transcribed from the DNA sequence would be:

UUCGACCAAAACUGCUG


Your Task

Write a function called dna_to_rna() that accepts a string representing a DNA sequence as a parameter and returns the corresponding transcribed RNA sequence as a string.


To transcribe a DNA sequence into a sequence of messenger RNA, apply the following rules of complementary nitrogenous base pairing:

  • G is complementary to C
  • C is complementary to G
  • T is complementary to A
  • A is complementary to U


If an invalid DNA sequence is passed as an argument, dna_to_rna() returns -1.

Project Demo

Explore this program before assigning it!

Project Overview

Here is an outline of the project activities: