DNA Strand Maker --> RNA strand --> Codons --> Amino Acids

This is my 7th project using python, and this program creates a random DNA strand which is then converted to an RNA strand, then to codons, and finally to amino acids.


import random print ("This is a random DNA string generator.") length = int(input("Enter the length of the DNA sequence(length needs to be divisible by 3): ")) while length % 3 != 0: length = int(input("Length has to be divisible by 3. Please enter another length: ")) DNA = [] RNA = [] codons = [] aminoAcids = [] def makeDNA (): for x in range(length): num = random.randint (1,5) if num == 1: DNA.append ("A") elif num == 2: DNA.append ("C") elif num == 3: DNA.append ("G") else: DNA.append ("T") def RNAConverter (): for char in DNA: if char == 'A': RNA.append ('U') elif char == 'C': RNA.append ('G') elif char == 'G': RNA.append ('C') else: RNA.append ('A') def codonConverter(): numOfCodons = 0 for x in range(int(len(RNA) / 3)): codon = RNA[numOfCodons * 3] codon += RNA[(numOfCodons * 3) + 1] codon += RNA[(numOfCodons * 3) + 2] codons.append(codon) numOfCodons += 1 def aminoAcidMaker(): for codon in codons: if codon == 'UUU' or codon == 'UUC': aminoAcids.append('Phe') elif codon == 'UUA' or codon == 'UUG' or codon == 'CUU' or codon == 'CUC' or codon == 'CUA' or codon == 'CUG': aminoAcids.append('Leu') elif codon == 'AUU' or codon == 'AUC' or codon == 'AUA': aminoAcids.append('Ile') elif codon == 'AUG': aminoAcids.append('Met') elif codon == 'GUU' or codon == 'GUC' or codon == 'GUA' or codon == 'GUG': aminoAcids.append('Val') elif codon == 'UCU' or codon == 'UCC' or codon == 'UCA' or codon == 'UCG' or codon == 'AGU' or codon == 'AGC': aminoAcids.append('Ser') elif codon == 'CCU' or codon == 'CCC' or codon == 'CCA' or codon == 'CCG': aminoAcids.append('Pro') elif codon == 'ACU' or codon == 'ACC' or codon == 'ACA' or codon == 'ACG': aminoAcids.append('Thr') elif codon == 'GCU' or codon == 'GCC' or codon == 'GCA' or codon == 'GCG': aminoAcids.append('Ala') elif codon == 'UAU' or codon == 'UAC': aminoAcids.append('Tyr') elif codon == 'UAA' or codon == 'UAG' or codon == 'UGA': aminoAcids.append('Stop') elif codon == 'CAU' or codon == 'CAC': aminoAcids.append('His') elif codon == 'CAA' or codon == 'CAG': aminoAcids.append('Gln') elif codon == 'AAU' or codon == 'AAC': aminoAcids.append('Asn') elif codon == 'AAA' or codon == 'AAG': aminoAcids.append('Lys') elif codon == 'GAU' or codon == 'GAC': aminoAcids.append('Asp') elif codon == 'GAA' or codon == 'GAC': aminoAcids.append('Glu') elif codon == 'UGU' or codon == 'UGC': aminoAcids.append('Cys') elif codon == 'UGG': aminoAcids.append('Trp') elif codon == 'CGU' or codon == 'CGC' or codon == 'CGA' or codon == 'CGG' or codon == 'AGA' or codon == 'AGG': aminoAcids.append('Arg') elif codon == 'AGU' or codon == 'AGC': aminoAcids.append('Ser') elif codon == 'GGU' or codon == 'GGC' or codon == 'GGA' or codon == 'GGG': aminoAcids.append('Gly') makeDNA() RNAConverter() codonConverter() aminoAcidMaker() print ("The DNA strand is :", str(DNA)) print ("The DNA strand converted to RNA is :", str(RNA)) print ("The RNA strand converted to codons is :", str(codons)) print ("The codons converted to amino acids are :", str(aminoAcids))

Aarush's Guessing Game (with stats)

This is my 2nd project called "The Guessing Game."

import random scoreList = [] question1 = "yes" while question1 == "yes": n = random.randint (1,99) print ("This is the guessing game.") guess = 0 numberOfGuesses = 0 totalNumberOfGames = 0 while n!= guess: guess = int(input("What is your guess between 1 and 99?")) numberOfGuesses = numberOfGuesses + 1 if guess < n: print ("Your guess is lower than the random number.") elif guess > n: print ("Your guess is higher than the random number.") else: print ("Your guess is correct!") totalNumberOfGames = totalNumberOfGames + 1 scoreList.append(numberOfGuesses) question1 = input ("Do you want to play again?") print ("Total number of games:", len(scoreList)) sum = 0 for i in scoreList: sum+=i sum/=len(scoreList) print("Average guesses per game:", sum) lowestNumber = scoreList[0] for i in scoreList: if lowestNumber > i: lowestNumber = i print ("Best Game:", lowestNumber)
1