Nexclap

Prime/Composite Number Program

This is just a simple prime/composite number program for how to print prime and composite numbers

primelist = ("2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97") def primenumber(num): ''' while True: answer = str(input("Would you like to print a list of all prime numbers from 1 to 100 or enter a number to tell whether it is prime or composite? All/Single ")) if answer == "single" : ''' #num = int(input("Enter the number you want: ")) #add new if statement if num == 2: print("it is a prime number") else: print("Let's find out if that number is prime or not.") composite = 0 for i in range(2,num): if (num % i) == 0: composite = composite + 1 print(composite) if composite == 0: print(num, "is a prime number") else: print(num,"is a composite number") #print(num, "is a prime number") #print(i,"times",num//i,"is",num) #print(num, "is a prime number") ''' elif answer == "prime 100": print(primelist) ''' start = str(input("Let's Start! Enter to continue!")) while True: ask = input("Would you like to continue? yes or no?: ") if ask == "yes": answer = str(input("Would you like to print a list of all prime numbers from 1 to 100 or enter a number to tell whether it is prime or composite? prime 100/single? prime 100 will print a list of numbers from 1 to 100. Single will ask you for what number do you wan't to be called as prime or composite. ")) if answer == "single" : num = int(input("Enter the number you want: ")) primenumber(num) elif answer == "prime 100": print(primelist) if ask == "no": break
A Nov 22

ok

Aarush Dhawan Jul 27

It has some things that I will fix and update soon. I will post the updated program later and explain the program though comments.

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))

Coding Standards in Python Programming

https://www.siliconvalley4u.com/blogs/coding-standards-in-python-programming
Announcements
  • Test Announcement from Nexclap

    Test message from nexclap - please ignore

    2023-02-13

  • Test message

    Test message from nexclap - please ignore

    2023-02-11

  • Test message

    Test message from nexclap - please ignore

    2023-02-11

  • View all