DNA to RNA

from random import randint length = int(input("Enter a length of a DNA: ")) DNA = [] RNA = "" dna = "" a_a = "" amino_acid = [] C_D = ["A","T","C","G"] toRNA = {"A":"U","T":"A","C":"G","G":"C"} amino_acids = {"A":["GCA","GCC","GCG","GCU"],"C":["UGC","UGU"],"D":["GAC","GAU"],"E":["GAA","GAG"],"F":["UUC","UUU"],"G":["GGA","GGC","GGG","GGU"],"H":["CAC","CAU"],"I":["AUA","AUC","AUU"],"K":["AAA","AAG"],"L":["UUA","UUG","CUA","CUC","CUG","CUU"],"M":["AUG"],"N":["AAC","AAU"],"P":["CCA","CCC","CCG","CCU"],"Q":["CAA","CAG"],"R":["AGA","AGG","CGA","CGC","CGG","CGU"],"S":["AGC","AGU","UCA","UCC","UCG","UCU"],"T":["ACA","ACC","ACG","ACU"],"V":["GUA","GUC","GUG","GUU"],"W":["UGG"],"Y":["UAC","UAU"]} # making a DNA for i in range(length): DNA.append(C_D[randint(0,3)]) print(">>> DNA") for i in DNA: dna += i print(">>>> "+dna) # converting the DNA into a RNA. for i in DNA: RNA+=toRNA[i] print(">>> RNA") print(">>>> "+RNA) # converting the RNA to amino acid chain. for i in range(0,len(RNA),3): for item,value in amino_acids.items(): for v in value: if v == RNA[i:i+3]: #print(RNA[i:i+3],v,item) amino_acid.append(item) print(">>> amino_acid") for i in amino_acid: a_a += i print(">>>> "+a_a)

Calculator GUI using PYQT5

A gui that is very similar to the calculator app.

Hangman2

P.S. I edited the function "hangman" simpler. It took me 20 minutes to edit it.

import random """ def hangman(score,picture): print("-------") for i in range(0,1): print("| |") if score == 1: print("| ---") print("| [= =]") print("| ---") if score == 2: print("| ---") print("| [= =]") print("| ---") print("| | |") if score == 3: print("| ---") print("| [= =]") print("| ---") print("| /| |") if score == 4: print("| ---") <== Before print("| [= =]") print("| ---") print("| /| |/") if score == 5: print("| ---") print("| [= =]") print("| ---") print("| /| |/") print("| -|") if score == 6: print("| ---") print("| [= =]") print("| ---") print("| /| |/") print("| |-|") for i in range(0,3): print("|") print("--") """ def hangman(score,picture): if score == 1: picture = picture + "| ---\n| [= =]\n| ---\n" elif score == 2: picture = picture + "| /" elif score == 3: picture = picture + "| |" elif score == 4: picture = picture + "/\n" elif score == 5: picture = picture + "| |-" elif score == 6: picture = picture + "|\n|" #for i in range(0,3): # picture = picture + "|\n" print(picture) return picture def Question(word): question = [] word = 0 with open("words.txt") as fileobj: for line in fileobj: question.append(line) word = random.choice(question) return word def searching(Input,score,word,cipher,cipher2,picture): copy1 = "" copy2 = "" u = 0 TorF = "" #put each word to cipher for i in range(0,len(word)): u = 0 copy1 = "" if Input == word[i]: TorF = True cipher2[i] = Input for x in range(0,len(cipher2)-1): copy1 = copy1 + cipher2[x] copy2 = copy1 print(copy2) if not TorF: print("incorrect") print(copy1) if score < 6: score = score+1 picture = hangman(score,picture) return cipher2,"0",score,picture if score == 6: print("Game over...") #print(word.rstrip()) print("The word is '" + word.rstrip() + "'.") return cipher2,"Game over...",score,picture copy2 = copy2 + "\n" if len(copy2) == len(word): if copy2 == word: print("You win!!") return cipher2,"You win!!",score,picture return cipher2,"0",score,picture def game(picture): cipher = [] cipher2 = [] score = 0 word = 0 disposable_value = 0 return_value = "" word = Question(word) #print(word) ⇐⇐⇐⇐⇐⇐⇐⇐⇐⇐ When testing print("-" * (len(word) - 1)) for i in range(0,len(word)-1): cipher.append(word[i]) for i in range(0,len(word)): cipher2.append("-") while disposable_value == 0: c = 1 Input = input("Enter an alphabet: ") for i in range(0,len(cipher2)): if Input == cipher2[i]: c = 0 print("") if c == 1: cipher2,return_value,score,picture = searching(Input,score,word,cipher,cipher2,picture) if return_value == "You win!!" or return_value == "Game over...": if input("Do you want to play again?(y/n): ") == "n": return "not again" else: return "again" again = "again" while again == "again": picture = "-------\n" for i in range(0,1): picture = picture + "| |\n" again = "again" again = game(picture)
Nobu Jul 27

You click "Nobu" if you wanna see my previous programs or previous hangman game.

Aarush Dhawan Jul 27

Nice one! Really cool!

Nobu Jul 28

Thanks.

Maze

I was working on it 3 hours.

def Judgment(Maze1,WhereIam,ReturnValue): if WhereIam[0] == 14: if WhereIam[1] == 2: ReturnValue = "GOAL!!" return ReturnValue return "still playing" def directions(Maze1,direction,WhereIam): print(direction) if direction == "right": print(Maze1[WhereIam[0]][WhereIam[1]+1]) if Maze1[WhereIam[0]][WhereIam[1]+1] != "■": Maze1[WhereIam[0]][WhereIam[1]+1] = "o" Maze1[WhereIam[0]][WhereIam[1]] = " " WhereIam[0] = WhereIam[0] WhereIam[1] = WhereIam[1]+1 return WhereIam,Maze1 if direction == "left": print(Maze1[WhereIam[0]][WhereIam[1]-1]) if Maze1[WhereIam[0]][WhereIam[1]-1] != "■": Maze1[WhereIam[0]][WhereIam[1]-1] = "o" Maze1[WhereIam[0]][WhereIam[1]] = " " WhereIam[0] = WhereIam[0] WhereIam[1] = WhereIam[1]-1 return WhereIam,Maze1 if direction == "above": print(Maze1[WhereIam[0]-1][WhereIam[1]]) if Maze1[WhereIam[0]-1][WhereIam[1]] != "■": Maze1[WhereIam[0]-1][WhereIam[1]] = "o" Maze1[WhereIam[0]][WhereIam[1]] = " " WhereIam[0] = WhereIam[0]-1 WhereIam[1] = WhereIam[1] return WhereIam,Maze1 if direction == "under": print(Maze1[WhereIam[0]+1][WhereIam[1]]) if Maze1[WhereIam[0]+1][WhereIam[1]] != "■": Maze1[WhereIam[0]+1][WhereIam[1]] = "o" Maze1[WhereIam[0]][WhereIam[1]] = " " WhereIam[0] = WhereIam[0]+1 WhereIam[1] = WhereIam[1] return WhereIam,Maze1 return WhereIam,Maze1 def picture(Maze1): for i in range(0,15): Display = "" for n in range(0,9): Display += Maze1[i][n]+" " print(Display) def Maze(Maze1,WhereIam,ReturnValue): direction = input("Enter a direction:") if direction == "right": WhereIam,Maze1 = directions(Maze1,direction,WhereIam) picture(Maze1) print(WhereIam) elif direction == "left": WhereIam,Maze1 = directions(Maze1,direction,WhereIam) picture(Maze1) print(WhereIam) elif direction == "up" or direction == "above": direction = "above" WhereIam,Maze1 = directions(Maze1,direction,WhereIam) picture(Maze1) print(WhereIam) elif direction == "under" or direction == "down": direction = "under" WhereIam,Maze1 = directions(Maze1,direction,WhereIam) picture(Maze1) print(WhereIam) else: print("You cannot go that direction.") ReturnValue = Judgment(Maze1,WhereIam,ReturnValue) return ReturnValue def main(Maze1): print() print("This is a maze game.") print() picture(Maze1) print("You are at 'S' now.") ReturnValue = "still playing" WhereIam = [1,3] while ReturnValue == "still playing": ReturnValue = Maze(Maze1,WhereIam,ReturnValue) Maze1 = [["■","■","■","■","■","■","■","■","■"], ["■"," "," ","S"," "," "," "," ","■"], ["■"," ","■"," ","■","■","■"," ","■"], ["■","■"," "," "," "," "," ","■","■"], ["■","■"," ","■"," ","■"," "," ","■"], ["■","■"," ","■"," "," ","■"," ","■"], ["■","■"," ","■","■"," ","■","■","■"], ["■","■","■"," "," "," "," ","■","■"], ["■"," "," "," ","■"," ","■","■","■"], ["■","■","■"," ","■"," "," "," ","■"], ["■","■"," "," ","■"," ","■","■","■"], ["■","■"," ","■","■"," "," "," ","■"], ["■","■"," ","■"," "," ","■"," ","■"], ["■","■"," ","■","■"," ","■"," ","■"], ["■","■","G","■","■","■","■","■","■"],] main(Maze1)

Grade calculator

I was working on it for 40 minutes.

""" tell you what grade you got and how many more points you would have needed to get the next grade up. A - 90% and above B- 80% to 89.9% C- 70% to 79.99% """ score = int(input("Enter your exam score: ")) print(100*(score/80)) if 90 <= 100*(score/80) <= 100: print("Your grade is A.") elif 80 <= 100*(score/80) <= 89.9: print("Your grade is B.") print("You need " + str(89.9-(100*(score/80))) + " to get the next grade.") elif 70 <= 100*(score/80) <= 79.99: print("Your grade is C.") print(print("You need " + str(79.99-(100*(score/80))) + "points to get the next grade.")) else: print("You don't have a grade.")

Encryption2

I was working on it for 1 hour.

def check_alphabet(i,y): if y == 0: for key,value in alphabet.items(): if i == key: return str(value) break return i else: for key,value in alphabet.items(): if i == str(value): return str(key) break return i def decrypt(word): dec_word = "" for i in word: x = check_alphabet(i,y=1) dec_word += x dec_word = dec_word[::-1] return dec_word def encrypt(word): enc_word = "" st1_word = word[::-1] for i in st1_word: x= check_alphabet(i,y=0) enc_word += x return enc_word def main(): choice = input(">>>Menu\n>>>Encrypt:e\n>>>Decrypt:d\n>>>Quit:q\n>>>: ") if choice == "e": word = input(">>>Write a sentence or a word: ") enc_word = encrypt(word) print(">>>Encryped:" + enc_word) input() return True elif choice == "d": word = input(">>>Write cryptogram you got: ") dec_word = decrypt(word) print(">>>Decrypted:" + dec_word) input() return True elif choice == "q": return False else: return True alphabet = {"a"or"A":0,"i"or"I":1,"u"or"U":2,"e"or"E":3,"o"or"O":4,"k"or"K":5,"s":6,"t":7,"n":8,"h":9," ":"x","!":"/"} TorF = True while TorF == True: TorF = main()

Encryption

Input: "apple" Step 1: Reverse the input: "elppa" Step 2: Replace all vowels using the following chart: a => 0 e => 1 i => 2 o => 3 u => 4 Step 3: Add "aca" to the end of the word: "1lpp0aca" Output: "1lpp0aca" 
Example: encrypt("banana") ➞ "0n0n0baca" encrypt("karaca") ➞ "0c0r0kaca" encrypt("burak") ➞ "k0r3baca" encrypt("alpaca") ➞ "0c0pl0aca" I was working on it for 40 minutes.

def check_vowel(i): for key,value in vowels.items(): if i == key: return str(value) break else: return i break def encrypt(vowels): enc_word = "" word = input("Enter a ward: ") st1_word = word[::-1] print("Step1 " + st1_word) for i in st1_word: x= check_vowel(i) enc_word += x print("Step2 " + enc_word) enc_word += "aca" print("Step3 " + enc_word) vowels = {"a":0,"i":1,"u":2,"e":3,"o":4} encrypt(vowels)

Tic-tac-toe

This is a tic tac toe game. I was working on it for 3 days.

# very weak... import random def Judgment(Tic_tac_toe): memo = [] #Vertical for i in range(0,3): for n in range(0,3): memo.append(Tic_tac_toe[n][i]) if memo[0] == memo[1]: if memo[0] == memo[2]: if memo[1] == memo[2]: if memo[0] != " " and memo[1] != " " and memo[2] != " ": if memo[0] == "o" and memo[1] == "o" and memo[2] == "o": return "You win!",1 else: return "You lost!",1 memo = [] memo = [] #horizontal for i in range(0,3): for n in range(0,3): memo.append(Tic_tac_toe[i][n]) if memo[0] == memo[1]: if memo[0] == memo[2]: if memo[1] == memo[2]: if memo[0] != " " and memo[1] != " " and memo[2] != " ": if memo[0] == "o" and memo[1] == "o" and memo[2] == "o": return "You win!",2 else: return "You lost!",2 memo = [] memo = [] n = [2,1,0] for i in range(0,3): memo.append(Tic_tac_toe[i][n[i]]) if memo[0] == memo[1]: if memo[0] == memo[2]: if memo[1] == memo[2]: if memo[0] != " " and memo[1] != " " and memo[2] != " ": if memo[0] == "o" and memo[1] == "o" and memo[2] == "o": return "You win!",3 else: return "You lost!",3 memo = [] memo = [] if Tic_tac_toe[0][0] == "✖︎": if Tic_tac_toe[1][1] == "✖︎": if Tic_tac_toe[2][2] == "✖︎": return "You lost!",4 if Tic_tac_toe[0][0] == "o": if Tic_tac_toe[1][1] == "o": if Tic_tac_toe[2][2] == "o": return "You win!",4 ii = 0 for i in range(0,3): for o in range(0,3): if Tic_tac_toe[i][o] == "✖︎" or Tic_tac_toe[i][o] == "o": ii += 1 if ii == 9: return "This is a draw game." return "Still playing",1 def Appearance(Tic_tac_toe): #Status="✖︎" #Status="o" print(" 1 2 3") for i in range(0,3): string1 = " |" string2_1 = Tic_tac_toe[i][0] string2_2 = Tic_tac_toe[i][1] string2_3 = Tic_tac_toe[i][2] string2=(" " + string2_1 + " |")+(" " + string2_2 +" |")+(" " + string2_3 +" |") print((" ---" * 3)) print(str(i+1) + (string1*1) +(string2)) print(" ---" * 3) def playing(Tic_tac_toe): return_value = "Still playing" while return_value == "Still playing": nn = 1 while nn == 1: Appearance(Tic_tac_toe) x = input("Enter your horizontal number: ") y = input("Enter your vertical number: ") print("(" +x+ ',' +y+ ")") rr = 0 if 1 <= int(x) <= 3: if 1 <= int(y) <= 3: if Tic_tac_toe[int(y)-1][int(x)-1] != " ": nn = 1 print("***Select right place.***") else: nn = 2 else: print("***Enter a right number.***") continue else: print("***Enter a right number.***") continue Tic_tac_toe[int(y)-1][int(x)-1] = "o" Appearance(Tic_tac_toe) #勝敗判定 return_value,n = Judgment(Tic_tac_toe) if return_value == "You win!": print(return_value) break elif return_value == "You lost!": print(return_value) break elif return_value == "This is a draw game.": print(return_value) break print("My turn.") print() nn = 1 while nn == 1: choices = [0,1,2] x = random.choice(choices) y = random.choice(choices) if Tic_tac_toe[int(y)][int(x)] == "o" or Tic_tac_toe[int(y)][int(x)] == "✖︎": nn = 1 if Tic_tac_toe[int(y)][int(x)] == " ": nn = 2 Tic_tac_toe[int(y)][int(x)] = "✖︎" return_value,n = Judgment(Tic_tac_toe) if return_value == "You won!": print(return_value) break elif return_value == "You lost!": Appearance(Tic_tac_toe) print(return_value) break elif return_value == "This is a draw game.": print(return_value) break def main(Tic_tac_toe): for i in range(0,3): print("") print("This's a tic-tac-toe game.") for i in range(0,4): print() playing(Tic_tac_toe) Tic_tac_toe = [[" "," "," "], [" "," "," "], [" "," "," "]] main(Tic_tac_toe)

Hangman

This is a hangman game. I was working on it for 2 days.

import random def hangman(score,picture): print("-------") for i in range(0,1): print("| |") if score == 1: print("| ---") print("| [= =]") print("| ---") if score == 2: print("| ---") print("| [= =]") print("| ---") print("| | |") if score == 3: print("| ---") print("| [= =]") print("| ---") print("| /| |") if score == 4: print("| ---") print("| [= =]") print("| ---") print("| /| |/") if score == 5: print("| ---") print("| [= =]") print("| ---") print("| /| |/") print("| -|") if score == 6: print("| ---") print("| [= =]") print("| ---") print("| /| |/") print("| |-|") for i in range(0,3): print("|") print("--") """ def hangman(score,picture): for i in range(0,1): picture += "| |\n" print(picture) if score == 1: picture += "| ---\n| [= =]\n| ---\n" print(picture) elif score == 2: picture += "| | |\n" print(picture) elif score == 3: picture += "| /| |" print(picture) elif score == 4: picture += "| /\n" print(picture) elif score == 5: picture += "| |-" print(picture) elif score == 6: picture += "| |\n" for i in range(0,3): picture += "|\n" picture += "--" print(picture) """ def Question(word): question = [] word = 0 with open("words.txt") as fileobj: for line in fileobj: question.append(line) word = random.choice(question) return word def searching(Input,score,word,cipher,cipher2,picture): copy1 = "" copy2 = "" u = 0 TorF = "" #put each word to cipher for i in range(0,len(word)): u = 0 copy1 = "" if Input == word[i]: TorF = True cipher2[i] = Input for x in range(0,len(cipher2)-1): copy1 = copy1 + cipher2[x] copy2 = copy1 print(copy2) if not TorF: print("incorrect") print(copy1) if score < 6: score = score+1 hangman(score,picture) return cipher2,"0",score if score == 6: print("Game over...") #print(word.rstrip()) print("The word is '" + word.rstrip() + "'.") return cipher2,"Game over...",score copy2 = copy2 + "\n" if len(copy2) == len(word): if copy2 == word: print("You win!!") return cipher2,"You win!!",score return cipher2,"0",score def game(): cipher = [] cipher2 = [] score = 0 word = 0 disposable_value = 0 return_value = "" word = Question(word) picture = "-------\n" #print(word) ⇐⇐⇐⇐⇐⇐⇐⇐⇐⇐ When testing print("-" * (len(word) - 1)) for i in range(0,len(word)-1): cipher.append(word[i]) for i in range(0,len(word)): cipher2.append("-") while disposable_value == 0: c = 1 Input = input("Enter an alphabet: ") for i in range(0,len(cipher2)): if Input == cipher2[i]: c = 0 print("") if c == 1: cipher2,return_value,score = searching(Input,score,word,cipher,cipher2,picture) if return_value == "You win!!" or return_value == "Game over...": if input("Do you want to play again?(y/n): ") == "n": return "not again" else: return "again" again = "again" while again == "again": again = "again" again = game()

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

Fibonacci Sequence

#numbers n0=0 n1=1 #amount of fibonacci numbers input=input("How many fibonacci numbers would you like") #logic for i in range(1, input+1): print(n0) temp = n0 n0 =n1 n1 = n1 + temp;

Square Root Machine

#input number=int(input("Find the square root machine:")) #logic def squareroot(n): x=0 while x != number: if x*x==number: print(x) x=x+1 print(squareroot(number))
1 2 ... 29