This is a hangman game

https://repl.it/@9arnavr/AntiqueTediousConfigfiles#main.py
import random name = input("What is your name?: ") print("Good Luck", name) words = ["computer", "pen", "dog", "plane", "paper", "glue", "damage", "fire", "blaze", "branch", "avacado", "hat", "bat", "ice", "lighting", "wires", "bear"] word=random.choice(words) #print(word) print("Guess a Letter: ") guesses='' turns = 10 while turns > 0: failed = 0 for char in word: if char in guesses: print(char) else: print("_") failed += 1 if failed == 0: print("You won the game!") print("The word is: ", word) break guess = input("Guess a Letter: ") guesses += guess if guess not in word: turns -= 1 print("Incorrect!") print("You have ", turns, "more guesses") if turns == 0: print("Oh No", name, "You lost, the secret word was ", word)
A Nov 24

Later on I will explain the program with comments

DNA Converter

This program converts a randomly generated DNA string to its corresponding polypeptide. However, while writing the program, I realized that it is more complicated than just basic conversions. The thing is, methionine (AUG) is the only amino acid that can start the strand and the strand is always ended by UUA, UAG, or UGA. So, the ribosome has to stop creating the polypeptide when it sees these. This is still something that I am working on including in the program. Anyway, hope you enjoy it!

from random import randint possiblevals= ["A","C", "T","G"] generatedlist= [] lengthsequence= int(input("Enter a number for the length of the DNA sequence ")) while lengthsequence%3 !=0: lengthsequence= int(input("Remember, nucleic acids are always present in groups of 3 called codons. Your number has to be divisible by 3. Please try again. ")) i=0 #making the DNA sequence while i<lengthsequence: randnum= randint(0,3) sequenceval= possiblevals[randnum] generatedlist.append(sequenceval) i=i+1 print (generatedlist) #making the RNA sequence possiblerna= ["U", "G", "A", "C"] rnalist= [] s=0 while s< lengthsequence: DNAval= generatedlist[s] dnaindex= possiblevals.index(DNAval) rnaconversion= possiblerna[dnaindex] rnalist.append(rnaconversion) s=s+1 print (rnalist) #making the amino acid chain finallist= [] str1="" a=0 b=1 c=2 e=0 p=3 listpossible= ["GCA", "GCC", "GCG", "GCU", "UGC", "UGU", "GAC", "GAU", "GAA", "GAG", "UUC", "UUU", "GGA", "GGC", "GGG", "GGU", "CAC","CAU", "AUA", "AUC", "AUU", "AAA", "AAG", "UUA", "UUG", "CUA", "CUC", "CUG", "CUU", "AUG", "AAC", "AAU","CCA", "CCC", "CCG", "CCU", "CAA","CAG","AGA", "AGG","CGA","CGC","CGG", "CGU", "AGC", "AGU", "UCA", "UCC", "UCG", "UCU", "ACA", "ACC", "ACG", "ACU", "GUA", "GUC", "GUG", "GUU", "UGG", "UAC", "UAU"] listamacids= ["Alanine", "Alanine", "Alanine", "Alanine", "Cysteine", "Cysteine", "Aspartic acid", "Aspartic acid", "Glutamic acid", "Glutamic acid", "Phenylalanine", "Phenylalanine", "Glycine", "Glycine","Glycine","Glycine", "Histidine", "Histidine", "Isoleucine", "Isoleucine", "Isoleucine", "Lysine", "Lysine", "Leucine", "Leucine", "Leucine", "Leucine", "Leucine", "Leucine", "Methionine", "Asparagine", "Asparagine", "Proline", "Proline", "Proline", "Proline", "Glutamine", "Glutamine", "Arganine", "Arganine", "Arganine", "Arganine", "Arganine", "Arganine", "Serine", "Serine", "Serine", "Serine", "Serine", "Serine", "Threonine", "Threonine", "Threonine", "Threonine", "Valine", "Valine", "Valine", "Valine", "Tryptophan", "Tyrosine", "Tyrosine"] while e< (lengthsequence/3): str1="" str1= str1+rnalist[a] str1= str1+rnalist[b] str1= str1+rnalist[c] index= listpossible.index(str1) var= listamacids[index] finallist.append(var) a=a+3 b=b+3 c=c+3 e=e+1 print (len(listpossible)) print (len(listamacids)) print (finallist)

Ultra Proogram

This program is just a combination on all my past programs. :D

#This first one is a number guessing game import random #while flag = True while flag: num = input("Type a number for an upper bound: ") #Starting the Game if num.isdigit(): print("Let's Play!") num = int(num) flag = False: else: print("Invalid input! Try Again!") secret = random.randint(1,num) guess = 5 count = 1 #Asking for the Numbers while guess != secret: guess = input("Type a number between 1 and ' + str (num) + ": ") if guess.isdigit(): guess = int(guess) #If you get it correct or incorrect if guess == secret: print("You got it!") else: print("Try agian!") count += 1 print('It took you', count, 'guesses!') #This next one is a rock paper scissors game import random comp_wins = 0 player_wins = 0 #Asking user to choose rock, paper, or scissors def Choose_Option(): user_choice = input("Choose Rock, Paper or Scissors: ") if user_choice in ["Rock", "rock", "r", "R"]: user_choice = "r" elif user_choice in ["Paper", "paper", "p", "P"]: user_choice = "p" elif user_choice in ["Scissors", "scissors", "s", "S"]: user_choice = "s" else: print("I don't understand, try again.") Choose_Option() return user_choice def Computer_Option(): comp_choice = random.randint(1, 3) if comp_choice == 1: comp_choice = "r" elif comp_choice == 2: comp_choice = "p" else: comp_choice = "s" return comp_choice while True: print("") user_choice = Choose_Option() comp_choice = Computer_Option() print("") #If you won, lost, or tied and a scoreboard if user_choice == "r": if comp_choice == "r": print("You chose rock. The computer chose rock. You tied.") elif comp_choice == "p": print("You chose rock. The computer chose paper. You lose.") comp_wins += 1 elif comp_choice == "s": print("You chose rock. The computer chose scissors. You win.") player_wins += 1 elif user_choice == "p": if comp_choice == "r": print("You chose paper. The computer chose rock. You win.") player_wins += 1 elif comp_choice == "p": print("You chose paper. The computer chose paper. You tied.") elif comp_choice == "s": print("You chose paper. The computer chose scissors. You lose.") comp_wins += 1 elif user_choice == "s": if comp_choice == "r": print("You chose scissors. The computer chose rock. You lose.") comp_wins += 1 elif comp_choice == "p": print("You chose scissors. The computer chose paper. You win.") player_wins += 1 elif comp_choice == "s": print("You chose scissors. The computer chose scissors. You tied.") #Tells number of points user and AI have print("") print("Player wins: " + str(player_wins)) print("Computer wins: " + str(comp_wins)) print("") #Asking if they want to play again user_choice = input("Do you want to play again? (y/n)") if user_choice in ["Y", "y", "yes", "Yes"]: pass elif user_choice in ["N", "n", "no", "No"]: break else: break #This last program is a calculator #Asking for the Numbers and Operation num1 = float(input("Enter First Number: ")) op = (input("Enter Operation: ")) num2 = float(input("Enter Second Number: ")) #Converting Operation to Calculator if op == "+": print(num1 + num2) elif op == "-": print(num1 - num2) elif op == "/": print(num1 / num2) elif op == "*": print(num1 * num2) else: print("Invalid! Try again!")

Hangman

This is my hangman game without a GUI

https://repl.it/join/emtopwks-supython3
#importing random because you need it import random print("this is hangman") #making an insanely long list of words WORDBANK = ["airplane",'hawkeye', 'robin', 'Galactus', 'thor', 'mystique', 'superman', 'deadpool', 'vision', 'sandman', "aquaman", 'pear', 'mango', 'apple', 'banana', 'apricot', 'pineapple','cantaloupe', 'grapefruit','jackfruit','papaya'] UnchosenWordBank = [] guesses = [] attempts = 15 #greet your user name = input("Enter your name ") print("Hello", name.capitalize(), "let's start playing Hangman!") print("The objective of the game is to guess the secret word chosen by the computer.") print("You can guess only one letter at a time. Don't forget to press 'enter key' after each guess.") print("Let the fun begin!") #pick out your secret word secretWord = random.choice(WORDBANK) print(secretWord) print("The number of allowed guesses for this word is:", attempts) g=0 guesses="" #loop da loop your question for g in range(attempts): Word = input("input a letter in lower case ") # just a benchmark # print(Word) # print(guesses) # the meat of it inside of the loop to find the letter if Word in guesses: print("You already guessed this letter, try something else.") continue else: if Word in secretWord: print("Nice guess!") else: print ("missed, try again") continue guesses+=Word

Super Program(Python)

This Project is a Combination of some of the Projects I have done:) It took some time adjusting the programs to fit this one:)

def MthNYr(): import calendar def CalMth(): yy = int(input("Enter year: ")) mm = int(input("Enter month: ")) print(calendar.month(yy, mm)) def CalYr(): #while(cont): yy = int(input("Enter year: ")) for i in range(1, 13): print(calendar.month(yy, i)) while True: ask = input("Would you like for I to print month or year? M or Y ") if ask == "Y": CalYr() if ask == "M": CalMth() if ask == "X": break def MtplyX(): def Multiply2Numbers(): Number1 = int(input("Enter the first number? ")) Number2 = int(input("Enter the second number? ")) Solution = Number1 * Number2 print(str(Number1) + " + " + str(Number2) + "=" + str(Solution)) def MultTable(): for x in range(1, 11): for y in range(1, 11): Answer = x * y print(x, "*", y, "=", Answer) opar = input( "Would you like to Multiply 2 numbers or print tables? Table or Multiply? " ) if opar == "T": MultTable() elif opar == "M": Multiply2Numbers() else: print("Please try again") def PNC(): def PrimeNumbers(): Type = int(input("Enter a number: ")) isPrime = True if Type == "2": print("This is a prime number.") isPrime = True else: for i in range(2, int(Type)): if (Type % i) == 0: print(str(Type) + " Is Composite!!") #print(i) isPrime = False break if isPrime != False: print(str(Type) + " Is Prime!!") while True: Q = input( "Do U Want me, NCOE To Figure Out If A Number Is Prime Or Composite? (Enter Y Or N) " ) if Q == "Y": PrimeNumbers() if Q == "N": break def KOMI(): def Miles(): mi = float(input("Enter the value in Miles: ")) ratio = 1.6 km = mi / ratio print("The entered value in Kilometers: ", mi) def Kilo(): km = float(input("Enter the value in kilometers: ")) ratio = 1.6 mi = km / ratio print("The entered value in Miles: ", mi) while True: End = input( "Do you want miles to kilo or kilo to miles?(K,M and V(V is for exit))" ) if End == "M": Miles() if End == "K": Kilo() if End == "V": break def TEP(): def Temp(): temp = int(input("What is the temperature?")) if temp > 70: print("Wear Shorts") else: print("Wear long Pants") print("Get some Excersise Outside") while True: Help = ("Im T the Weather Robot,Would you like some help?") if Help == "yes": Temp() if Help == "no": break while True: print("Welcome to the Project Picker,I am Matrix the AI") Pick = input("To use the Calendar Project Press C,For the Multiply Project Press M,For the prime and composite Press P,For the kilo2miles Press K,for the temp project press R,and if you want to quit pressX C,M,P,K,R,X ") if Pick == "C": MthNYr() if Pick == "M": MtplyX() if Pick == "P": PNC() if Pick == "X": break if Pick == "K": KOMI() if Pick == "N": TEP()

AT-BASH CIPHER

my take on AT-BASH CIPHER

https://repl.it/join/nyoobkmd-supython3
#for the effects import time #asking the user to input the sentence print("") print("THIS IS THE AT-BASH CIPHER AND PRESS ENTER") time.sleep(1) print("") print("PLEASE TYPE IN LOWERCASE OR ELSE THE PROGRAM WON'T WORK") cipher = input("TYPE IN YOUR SENTENCE THAT YOU WANT TO SCRAMBLE: ") time.sleep(1) print("caculating.....") #replacing each letter cipher = cipher.replace("a", "Z") cipher = cipher.replace("b", "Y") cipher = cipher.replace("c", 'X') cipher = cipher.replace("d", 'W') cipher = cipher.replace("e", 'V') cipher = cipher.replace("f", 'U') cipher = cipher.replace("g", 'T') cipher = cipher.replace("h", 'S') cipher = cipher.replace("i", 'R') cipher = cipher.replace("j", 'Q') cipher = cipher.replace("k", 'P') cipher = cipher.replace("l", 'O') cipher = cipher.replace("m", 'N') cipher = cipher.replace("n", 'M') cipher = cipher.replace("o", 'L') cipher = cipher.replace("p", 'K') cipher = cipher.replace("q", 'J') cipher = cipher.replace("r", 'I') cipher = cipher.replace("s", 'H') cipher = cipher.replace("t", 'G') cipher = cipher.replace("u", 'F') cipher = cipher.replace("v", 'E') cipher = cipher.replace("w", 'D') cipher = cipher.replace("x", 'C') cipher = cipher.replace("y", 'B') cipher = cipher.replace("z", 'A') #displaying the ciphered text time.sleep(3) print("caculating.......") print("") time.sleep(3) print("") print("YOUR SENTENCE IS:") time.sleep(2) print("") print(cipher) print("")
A Nov 22

Interesting

dna converter

this is my interpretation of the DNA converter from python1B

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)

Rock, Paper, Scissors

This is a simple Rock, Paper, Scissors game

https://repl.it/@9arnavr/KindheartedAcrobaticCookies#main.py
import random comp_wins = 0 player_wins = 0 def Choose_Option(): user_choice = input("Choose Rock, Paper or Scissors: ") if user_choice in ["Rock", "rock", "r", "R"]: user_choice = "r" elif user_choice in ["Paper", "paper", "p", "P"]: user_choice = "p" elif user_choice in ["Scissors", "scissors", "s", "S"]: user_choice = "s" else: print("I don't understand, try again.") Choose_Option() return user_choice def Computer_Option(): comp_choice = random.randint(1, 3) if comp_choice == 1: comp_choice = "r" elif comp_choice == 2: comp_choice = "p" else: comp_choice = "s" return comp_choice while True: print("") user_choice = Choose_Option() comp_choice = Computer_Option() print("") if user_choice == "r": if comp_choice == "r": print("You chose rock. The computer chose rock. You tied.") elif comp_choice == "p": print("You chose rock. The computer chose paper. You lose.") comp_wins += 1 elif comp_choice == "s": print("You chose rock. The computer chose scissors. You win.") player_wins += 1 elif user_choice == "p": if comp_choice == "r": print("You chose paper. The computer chose rock. You win.") player_wins += 1 elif comp_choice == "p": print("You chose paper. The computer chose paper. You tied.") elif comp_choice == "s": print("You chose paper. The computer chose scissors. You lose.") comp_wins += 1 elif user_choice == "s": if comp_choice == "r": print("You chose scissors. The computer chose rock. You lose.") comp_wins += 1 elif comp_choice == "p": print("You chose scissors. The computer chose paper. You win.") player_wins += 1 elif comp_choice == "s": print("You chose scissors. The computer chose scissors. You tied.") print("") print("Player wins: " + str(player_wins)) print("Computer wins: " + str(comp_wins)) print("") user_choice = input("Do you want to play again? (y/n)") if user_choice in ["Y", "y", "yes", "Yes"]: pass elif user_choice in ["N", "n", "no", "No"]: break else: break

Matrices

#matrice #matrics array = [1,2,3,4,5,6] print(array[3]) matrix = [] row0 = [1,2,3] row1 = [4,5,6] row2 = [7,8,9] matrix.append(row0) matrix.append(row1) matrix.append(row2) print(matrix) print(matrix[0]) print(matrix[2]) print("printing first index of row1") print(matrix[0][1]) print(matrix[1]) #max index is 2, it can only be 0,1,2 print("printing second index of row 1") print(matrix[1][2]) print(matrix[2][1]) newMatrix = [[24,56,109,56],[13,5,73,80],[83,1,25,9],[70,2,25,4]] print() for i in range(0,4,1): print(newMatrix[i]) print(newMatrix[0][2]) print(newMatrix[1][1],newMatrix[1][2]) for row in range(0,len(newMatrix),1): for column in range(0,len(newMatrix[row]),1): if column == 1: print(newMatrix[row][column])

Temperature advice code

This code tells you about the temperature. It also tells advice on wether you should wear short sleeves or long sleeves.

advice= "yes" while advice == "yes": advice = input("Would you like advice to wear shorts or long pants") temperature = float(input('What is the temperature?')) if temperature > 70: print('Wear shorts.') else: print('Wear long pants.') print('Get some excersise.') for i in [1, 2, 3]: i += 1 print(i)

Atbash Cipher

The At--bash cipher is an encryption method in which each letter of a word is replaced with its "mirror" letter in the alphabet: A <=> Z; B <=> Y; C <=> X; etc. This function applies the atbash cipher to any string that is inputted.

#Making a list of all the possible letters- uppercase and lowercase. I also added special characters just in case people want to type them. But they will be the same after ciphering string2= "zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA !,./';:[]()+=-" string= "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ !,./';:[]()+=-" alphabet= list(string) printlist= "" reversealpha= list(string2) returnlist= [] #The input statement asks the user to input a string to be ciphered word= input("Input a string. ") #The Atbash cipher is applied def atbash(word): #Converting the string into a list so I can loop through it letters= list(word) for x in letters: # Finding the index of a letter in the alphabet and then finding the letter with the same index in the reverse alphabet a= alphabet.index(x) y= reversealpha[a] returnlist.append(y) return returnlist h=(atbash(word)) #Converting the list into a string print(printlist.join(h))

Rock, Paper, Scissors!

This is my version of Rock, Paper, Scissors. If you choose "Rock", type R,r,Rock, or rock. If you choose "Paper", type P,p,Paper, or paper. If you choose "Scissors", type S,s,Scissors, or scissors. If you see (y/n) Y stands for Yes and N stands for no.

import random comp_wins = 0 player_wins = 0 def Choose_Option(): user_choice = input("Choose Rock, Paper or Scissors: ") if user_choice in ["Rock", "rock", "r", "R"]: user_choice = "r" elif user_choice in ["Paper", "paper", "p", "P"]: user_choice = "p" elif user_choice in ["Scissors", "scissors", "s", "S"]: user_choice = "s" else: print("I don't understand, try again.") Choose_Option() return user_choice def Computer_Option(): comp_choice = random.randint(1, 3) if comp_choice == 1: comp_choice = "r" elif comp_choice == 2: comp_choice = "p" else: comp_choice = "s" return comp_choice while True: print("") user_choice = Choose_Option() comp_choice = Computer_Option() print("") if user_choice == "r": if comp_choice == "r": print("You chose rock. The computer chose rock. You tied.") elif comp_choice == "p": print("You chose rock. The computer chose paper. You lose.") comp_wins += 1 elif comp_choice == "s": print("You chose rock. The computer chose scissors. You win.") player_wins += 1 elif user_choice == "p": if comp_choice == "r": print("You chose paper. The computer chose rock. You win.") player_wins += 1 elif comp_choice == "p": print("You chose paper. The computer chose paper. You tied.") elif comp_choice == "s": print("You chose paper. The computer chose scissors. You lose.") comp_wins += 1 elif user_choice == "s": if comp_choice == "r": print("You chose scissors. The computer chose rock. You lose.") comp_wins += 1 elif comp_choice == "p": print("You chose scissors. The computer chose paper. You win.") player_wins += 1 elif comp_choice == "s": print("You chose scissors. The computer chose scissors. You tied.") print("") print("Player wins: " + str(player_wins)) print("Computer wins: " + str(comp_wins)) print("") user_choice = input("Do you want to play again? (y/n)") if user_choice in ["Y", "y", "yes", "Yes"]: pass elif user_choice in ["N", "n", "no", "No"]: break else: break
1 2 ... 30