Hangman

Hangman in python, not hard to add more letters.

apple = ["a","p","p","l","e"] bean = ["b","e","a","n","s"] carrot = ["c","a","r","r","o","t"] dolphin = ["d","o","l","p","h","i","n"] elephant = ["e","l","e","p","h","a","n","t"] fish = ["f","i","s","h"] gas = ["g","a","s"] hot = ["h","o","t"] igloo = ["i","g","l","o","o"] jelly = ["j","e","l","l","y"] kite = ["k","i","t","e"] lion = ["l","i","o","n"] moon = ["m", "o","o","n"] nice = ["n","i","c","e"] own = ["o","w","n"] pig = ["p","i","g"] quit = ["q","u","i","t"] road = ["r","o","a","d"] star = ["s","t","a","r"] toad = ["t","o","a","d"] use = ["u","s","e"] vote = ["v","o","t","e"] wind = ["w","i","n","d"] xray = ["x","r","a","y"] your = ["y","o","u","r"] zebra = ["z","e","b","r","a"] import random correct = 0 Chances = 10 wrong = "" ListWrong = [] Word = [apple, bean, carrot, dolphin, elephant, fish, gas, hot, igloo, jelly, kite, lion, moon, nice, own, pig, quit, road, star, toad, use, vote, wind, xray, your, zebra] Chosen = Word[random.randint(0, 25)] length = len(Chosen) if length == 3: Guesser = ["_","_","_"] elif length == 4: Guesser = ["_","_","_","_"] elif length == 5: Guesser = ["_","_","_","_","_"] elif length == 6: Guesser = ["_","_","_","_","_","_"] elif length == 7: Guesser = ["_","_","_","_","_","_","_"] elif length == 8: Guesser = ["_","_","_","_","_","_","_","_"] print(Guesser) print("You have", Chances, "chances.") for control in range(0, 10, 1): if correct == 0: letter = str(input("Choose a letter:")) Place = length section = 0 while section != Place: if letter == Chosen[section]: Guesser[section] = Chosen[section] section = section + 1 else: wrong = letter section = section + 1 print(Guesser) Chances = Chances - 1 print("you have" , Chances, "chance(s) left.") ListWrong.append(wrong) print("The letters", ListWrong, "are incorrect or already used.") if Chances == 0 and correct == 0: print(Chosen, "was the word. You lose!") if Guesser == Chosen and Chances > 0: print("Good job! You guessed the word!") print(Guesser) correct = 1 section = Place Chances = 0

Cyber Bank

import random money = 0 str_name = input("welcome the the cyber bank. what will you be named as") while True: random.randint(0, 1000) print("hello" + str_name + ", what would you want to do") if random.randint == "1": print("you have been hacked and your money is at zero") money = 0 print("(1) deposit money") print("(2) take money") str_choice = input("(3) show balance") choice = int(str_choice) if str_choice == "1": str_money1 = input("how much do you want to deposit") print("okay, we got it!") money1 = int(str_money1) money = money+money1 elif str_choice == "2": str_moneytaken = input("how much do you want to take") print("okay, we got it") moneytaken = int(str_moneytaken) money = money-moneytaken elif str_choice == "3": print("your total balance is") print(money)

SPK (Social Platform for Kids)

str_m = input("Welcome to SPK! SPK is a social platform for kids. What do you want to be known as?") post = [] postname = [] while True: print("(1)post") print("(2)Delete") print("(3)See posts") print("(4)leave") str_a = input("What do you want to do?") if str_a == "4": print("bye " + str_m + "!") break elif str_a == "1": str_post = input("What do you want to post?") print("We got it!") str_postname = input("what do you want to name it?") post.append(str_post) elif str_a == "2": if not post: print("You do not have any posts.") else: for x in post: print(x) str_e = input("what post do you want to delete") post.remove(postname.index(str_e)) postname.remove(postname.index(str_e)) elif str_a == "3": if not post: print("You do not have any posts.") for x in post: print(x)

Rock, Paper, Scissors.

import random while True: number = random.randint(1, 3) str_number = int(input("choose (1) rock (2) paper or (3)scissors")) if str_number == number: print("Tie!") elif str_number == 1 and number == 2: print("You lose!") elif str_number == 1 and number == 3: print("You win!") print("Your opponent picked") elif str_number == 2 and number == 1: print("You win!") elif str_number == 2 and number == 3: print("You lose!") elif str_number == 3 and number == 1: print("You lose!") elif str_number == 3 and number == 2: print("You win!") if number == 1: print("Your opponent chose rock") if number == 2: print("Your opponent chose paper") if number == 3: print("Your opponent chose scissors") str_m = input("Do you want to play again?(yes or no)") if str_m == "no": print("bye") break

War Card Game

This is a version of the card game War, and it is also my final Python A project.

# War Card game # A player wins if they gain 52 cards or have more cards after 5 rounds. These amounts can be adjusted if needed. # There are 2 checks placed in the code for player and opponent deck contents, these show the movement of cards. # A tie breaker within a tie breaker is decided with a coin flip in this version of the game. from random import randint total_cards = ["2", "2", "2", "2", "3", "3", "3", "3", "4", "4", "4", "4", "5", "5", "5", "5", "6", "6", "6", "6", "7", "7", "7", "7", "8", "8", "8", "8", "9", "9", "9", "9", "10", "10", "10", "10", "11", "11", "11", "11", "12", "12", "12", "12", "13", "13", "13", "13", "14", "14", "14", "14"] player_cards = [] opponent_cards = [] for x in range(0, 26): y = 51-x card_number = randint(0, y) card = total_cards[card_number] player_cards.append(card) total_cards.pop(card_number) for x in range(0, 26): y = 25-x card_number = randint(0, y) card = total_cards[card_number] opponent_cards.append(card) total_cards.pop(card_number) print("player") print(player_cards) print("opponent") print(opponent_cards) # This is a check to see the starting moves, feel free to remove if using the code. p = len(player_cards) o = len(opponent_cards) moves = 0 while p != 52 and o != 52 and moves < 5: p_card = int(player_cards[0]) o_card = int(opponent_cards[0]) print("You have placed down a ", p_card) print("The opponent has placed down a ", o_card) moves = moves + 1 if p_card > o_card: continue_playing = input("Your card is higher, take all cards and keep playing? Enter yes to continue: ") if continue_playing == "yes": player_cards.append(str(o_card)) player_cards.pop(0) player_cards.append(str(p_card)) opponent_cards.pop(0) elif o_card > p_card: continue_playing = input("Your card is lower, give opponent cards and keep playing? Enter yes to continue: ") if continue_playing == "yes": opponent_cards.append(str(p_card)) opponent_cards.pop(0) opponent_cards.append(str(o_card)) player_cards.pop(0) elif o_card == p_card: continue_playing = input("The cards are the same, time for a tie-breaker? Enter yes to continue: ") if continue_playing == "yes": print("You and the opponent place 3 cards face down and one face up. Lets see who wins the war!") p_card1 = player_cards[1] p_card2 = player_cards[2] p_card3 = player_cards[3] p_card4 = int(player_cards[4]) o_card1 = opponent_cards[1] o_card2 = opponent_cards[2] o_card3 = opponent_cards[3] o_card4 = int(opponent_cards[4]) print("You place down a ", p_card4, "and your opponent has placed down a ", o_card4) if p_card4 > o_card4: print("Congrats! You won the war and gain a ", o_card1, o_card2, o_card3, "and", o_card4) player_cards.pop(0) player_cards.pop(1) player_cards.pop(2) player_cards.pop(3) player_cards.pop(4) player_cards.append(str(p_card)) player_cards.append(str(p_card1)) player_cards.append(str(p_card2)) player_cards.append(str(p_card3)) player_cards.append(str(p_card4)) opponent_cards.pop(0) opponent_cards.pop(1) opponent_cards.pop(2) opponent_cards.pop(3) opponent_cards.pop(4) player_cards.append(str(o_card)) player_cards.append(str(o_card1)) player_cards.append(str(o_card2)) player_cards.append(str(o_card3)) player_cards.append(str(o_card4)) elif o_card4 > p_card4: print("You lost the war, your opponent gains a ", p_card1, p_card2, p_card3, "and", p_card4) opponent_cards.pop(0) opponent_cards.pop(1) opponent_cards.pop(2) opponent_cards.pop(3) opponent_cards.pop(4) opponent_cards.append(str(o_card)) opponent_cards.append(str(o_card1)) opponent_cards.append(str(o_card2)) opponent_cards.append(str(o_card3)) opponent_cards.append(str(o_card4)) player_cards.pop(0) player_cards.pop(1) player_cards.pop(2) player_cards.pop(3) player_cards.pop(4) opponent_cards.append(str(p_card)) opponent_cards.append(str(p_card1)) opponent_cards.append(str(p_card2)) opponent_cards.append(str(p_card3)) opponent_cards.append(str(p_card4)) elif o_card4 == p_card4: print("Wow, another tie! You placed a ", p_card4, "and your opponent placed a ", o_card4, ".") p_coin = input("Lets decide this one with a coin flip. Heads or tails? ") continue_playing = input("Would you like to keep playing? Enter yes to continue: ") coin = randint(1, 2) if coin == 1 and p_coin == "heads" and continue_playing == "yes": print("You won the coin flip and gain the cards!") player_cards.pop(0) player_cards.pop(1) player_cards.pop(2) player_cards.pop(3) player_cards.pop(4) player_cards.append(str(p_card)) player_cards.append(str(p_card1)) player_cards.append(str(p_card2)) player_cards.append(str(p_card3)) player_cards.append(str(p_card4)) opponent_cards.pop(0) opponent_cards.pop(1) opponent_cards.pop(2) opponent_cards.pop(3) opponent_cards.pop(4) player_cards.append(str(o_card)) player_cards.append(str(o_card1)) player_cards.append(str(o_card2)) player_cards.append(str(o_card3)) player_cards.append(str(o_card4)) elif coin == 2 and p_coin == "tails": print("You won the coin flip and gain the cards!") player_cards.pop(0) player_cards.pop(1) player_cards.pop(2) player_cards.pop(3) player_cards.pop(4) player_cards.append(str(p_card)) player_cards.append(str(p_card1)) player_cards.append(str(p_card2)) player_cards.append(str(p_card3)) player_cards.append(str(p_card4)) opponent_cards.pop(0) opponent_cards.pop(1) opponent_cards.pop(2) opponent_cards.pop(3) opponent_cards.pop(4) player_cards.append(str(o_card)) player_cards.append(str(o_card1)) player_cards.append(str(o_card2)) player_cards.append(str(o_card3)) player_cards.append(str(o_card4)) else: print("You lost the coin flip and your opponent gains the cards.") opponent_cards.pop(0) opponent_cards.pop(1) opponent_cards.pop(2) opponent_cards.pop(3) opponent_cards.pop(4) opponent_cards.append(str(o_card)) opponent_cards.append(str(o_card1)) opponent_cards.append(str(o_card2)) opponent_cards.append(str(o_card3)) opponent_cards.append(str(o_card4)) player_cards.pop(0) player_cards.pop(1) player_cards.pop(2) player_cards.pop(3) player_cards.pop(4) opponent_cards.append(str(p_card)) opponent_cards.append(str(p_card1)) opponent_cards.append(str(p_card2)) opponent_cards.append(str(p_card3)) opponent_cards.append(str(p_card4)) # This is another check to see how the content of the decks has changed during the round. print(player_cards) print(opponent_cards) p = len(player_cards) o = len(opponent_cards) if p > o: print("You have won the game!") elif o > p: print("You lost, the opponent won this game.") else: print("You and the opponent have tied.")

Java DNA to RNA Calculation

DNA to RNA sequence conversion done in Java. I used a HashMap holding three-letter-combinations as keys and codons as inputs (line 53 holds the method). This way, it is easier to access the items in the HashMap by calling the key.

import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Random rd = new Random(); System.out.println("Please enter a positive integer: "); int dnaLength = sc.nextInt(); // generate random dna sequence of that length (random assortment of 4 possible chars at specified DNA strand length String[] dnaChars = {"A", "T", "C", "G"}; String newDnaSequence = ""; for (int i = 0; i < dnaLength; i++) { String item = dnaChars[rd.nextInt(4)]; newDnaSequence += item; } // convert DNA to RNA (video 58 seconds in) /* * "A" in dna becomes "U" in rna * "T" in dna becomes "A" in rna * "C" in dna becomes "G" in rna * "G" in dna becomes "C" in rna * */ String newRnaSequence = ""; for (int i = 0; i < dnaLength; i++) { switch (newDnaSequence.substring(i, i + 1)) { case "A" -> newRnaSequence += "U"; case "T" -> newRnaSequence += "A"; case "C" -> newRnaSequence += "G"; case "G" -> newRnaSequence += "C"; } } System.out.println(newRnaSequence); // convert RNA to amino acid chain, see link http://www.math.utep.edu/Faculty/mleung/bioinformatics/aacodon.html HashMap<String, String> aminoAcids = insertItemsToMap(new HashMap<>()); String aminoAcidSeq = ""; for (String set : splitSequence(newRnaSequence)) { aminoAcidSeq += aminoAcids.get(set); } System.out.println(aminoAcidSeq); } public static HashMap<String, String> insertItemsToMap(HashMap<String, String> aminoAcids) { aminoAcids.put("GCA", "A"); aminoAcids.put("GCC", "A"); aminoAcids.put("GCG", "A"); aminoAcids.put("GCU", "A"); aminoAcids.put("UGC", "C"); aminoAcids.put("UGU", "C"); aminoAcids.put("GAC", "D"); aminoAcids.put("GAU", "D"); aminoAcids.put("GAA", "E"); aminoAcids.put("GAG", "E"); aminoAcids.put("UUC", "F"); aminoAcids.put("UUU", "F"); aminoAcids.put("GGA", "G"); aminoAcids.put("GGC", "G"); aminoAcids.put("GGG", "G"); aminoAcids.put("GGU", "G"); aminoAcids.put("CAC", "H"); aminoAcids.put("CAU", "H"); aminoAcids.put("AUA", "I"); aminoAcids.put("AUC", "I"); aminoAcids.put("AUU", "I"); aminoAcids.put("AAA", "K"); aminoAcids.put("AAG", "K"); aminoAcids.put("UUA", "L"); aminoAcids.put("UUG", "L"); aminoAcids.put("CUA", "L"); aminoAcids.put("CUC", "L"); aminoAcids.put("CUG", "L"); aminoAcids.put("CUU", "L"); aminoAcids.put("AUG", "M"); aminoAcids.put("AAC", "N"); aminoAcids.put("AAU", "N"); aminoAcids.put("CCA", "P"); aminoAcids.put("CCC", "P"); aminoAcids.put("CCG", "P"); aminoAcids.put("CCU", "P"); aminoAcids.put("CAA", "Q"); aminoAcids.put("CAG", "Q"); aminoAcids.put("AGA", "R"); aminoAcids.put("AGG", "R"); aminoAcids.put("CGA", "R"); aminoAcids.put("CGC", "R"); aminoAcids.put("CGG", "R"); aminoAcids.put("CGU", "R"); aminoAcids.put("AGC", "S"); aminoAcids.put("AGU", "S"); aminoAcids.put("UCA", "S"); aminoAcids.put("UCC", "S"); aminoAcids.put("UCG", "S"); aminoAcids.put("UCU", "S"); aminoAcids.put("ACA", "T"); aminoAcids.put("ACC", "T"); aminoAcids.put("ACG", "T"); aminoAcids.put("ACU", "T"); aminoAcids.put("GUA", "V"); aminoAcids.put("GUC", "V"); aminoAcids.put("GUG", "V"); aminoAcids.put("GUU", "V"); aminoAcids.put("UGG", "W"); aminoAcids.put("UAC", "Y"); aminoAcids.put("UAU", "Y"); aminoAcids.put("UAA", "Z"); aminoAcids.put("UGA", "Z"); aminoAcids.put("UAG", "Z"); return aminoAcids; } public static ArrayList<String> splitSequence(String seq) { ArrayList<String> newSeq = new ArrayList<>(); for (int i = 0; i < seq.length(); i += 3) { if (i + 3 > seq.length()) { break; } newSeq.add(seq.substring(i, i + 3)); } return newSeq; } }

Java 1a DNA to RNA and amino acids

package javaClass; import java.util.Scanner; import java.lang.reflect.Array; import java.util.ArrayList; public class javaClass { private static Scanner input = new Scanner(System.in); public static void main(String [] args) { String DNA = ""; String RNA = ""; String aminoChain = ""; print("Enter a number length of a DNA sequence."); int sequenceLength = input.nextInt(); for (int n = 0; n < sequenceLength; n = n + 1) { int random = (int)(Math.random()*(4-1+1)+1); if (random == 1) { DNA = DNA + "A"; } else if (random == 2) { DNA = DNA + "T"; } else if (random == 3) { DNA = DNA + "G"; } else if (random == 4) { DNA = DNA + "C"; } } RNA = DNA.replace("A", "1"); RNA = RNA.replace("T", "2"); RNA = RNA.replace("C", "3"); RNA = RNA.replace("G", "4"); RNA = RNA.replace("1", "U"); RNA = RNA.replace("2", "A"); RNA = RNA.replace("3", "G"); RNA = RNA.replace("4", "C"); print("DNA sequence generated as " + DNA); print("DNA translated to RNA as " + RNA); for (int i = 0; i < Math.floor(sequenceLength / 3); i++) { if(RNA.substring(i * 3, i * 3 + 3).equals("UUU") || RNA.substring(i * 3, i * 3 + 3).equals("UUC")) { aminoChain = aminoChain + "phenylalanine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("UUA") || RNA.substring(i * 3, i * 3 + 3).equals("UUG") || RNA.substring(i * 3, i * 3 + 2).equals("CU")) { aminoChain = aminoChain + "leucine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("AGU") || RNA.substring(i * 3, i * 3 + 3).equals("AGC") || RNA.substring(i * 3, i * 3 + 2).equals("UC")) { aminoChain = aminoChain + "serine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("UAU") || RNA.substring(i * 3, i * 3 + 3).equals("UAC")) { aminoChain = aminoChain + "tyrosine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("UGU") || RNA.substring(i * 3, i * 3 + 3).equals("UGC")) { aminoChain = aminoChain + "cysteine"; } else if(RNA.substring(i * 3, i * 3 + 2).equals("CC")) { aminoChain = aminoChain + "proline"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("CAU") || RNA.substring(i * 3, i * 3 + 3).equals("CAC")) { aminoChain = aminoChain + "histidine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("CAA") || RNA.substring(i * 3, i * 3 + 3).equals("CAG")) { aminoChain = aminoChain + "glutamine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("AGG") || RNA.substring(i * 3, i * 3 + 3).equals("AGA") || RNA.substring(i * 3, i * 3 + 2).equals("CG")) { aminoChain = aminoChain + "arginine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("AUU") || RNA.substring(i * 3, i * 3 + 3).equals("AUC") || RNA.substring(i * 3, i * 3 + 3).equals("AUA")) { aminoChain = aminoChain + "isoleucine"; } else if(RNA.substring(i * 3, i * 3 + 2).equals("AC")) { aminoChain = aminoChain + "threonine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("AAU") || RNA.substring(i * 3, i * 3 + 3).equals("AAC")) { aminoChain = aminoChain + "asparagine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("AAA") || RNA.substring(i * 3, i * 3 + 3).equals("AAG")) { aminoChain = aminoChain + "lysine"; } else if(RNA.substring(i * 3, i * 3 + 2).equals("GU")) { aminoChain = aminoChain + "valine"; } else if(RNA.substring(i * 3, i * 3 + 2).equals("GC")) { aminoChain = aminoChain + "alanine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("GAU") || RNA.substring(i * 3, i * 3 + 3).equals("GAC")) { aminoChain = aminoChain + "asparatic acid"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("GAA") || RNA.substring(i * 3, i * 3 + 3).equals("GAG")) { aminoChain = aminoChain + "glutimic acid"; } else if(RNA.substring(i * 3, i * 3 + 2).equals("GG")) { aminoChain = aminoChain + "glycine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("AUG")) { aminoChain = aminoChain + "methionine"; } else if(RNA.substring(i * 3, i * 3 + 3).equals("UAA") || RNA.substring(i * 3, i * 3 + 3).equals("UAG") || RNA.substring(i * 3, i * 3 + 3).equals("UGA")) { aminoChain = aminoChain + "stop"; } if(i + 1 < Math.floor(sequenceLength / 3)) { aminoChain = aminoChain + ", "; if(!(i + 2 < Math.floor(sequenceLength / 3))) { aminoChain = aminoChain + "and "; } } else { aminoChain = aminoChain + "."; } } print("The chain of amino acids made were " + aminoChain); print("Any extra characters were excluded."); } public static void print(String print) { System.out.println(print); } }

Python Exercises

#1 - Create a variable named movie. Set it equal to your favorite movie. Movie = "Avengers:Endgame" #2 - Is the variable you created in Problem the first problem a String, Integer, or Float? It's a string, since "Avengers:Endgame" is a word. #3 - Print the variable named movie. print(movie) #4 - Create an integer variable x and set it equal to 10. x = 10 #5 - What type of variable is x? It is an integer variable since 10 is an integer (whole number). #6 - Create a variable called y and set it equal to 33.5. y = 33.5 #7 - What type of variable is y? y is a float, since 33.5 is a decimal number. #8 - Print the result of adding x and y together. print(x + y) Exercise 2 #1 name = "Elijah" age = 13 print("My name is " + name + ", and I'm " + str(age) + " years old.") #2 x = 20 print(x* 20) #3 decimal = "22.5" decimal = float(decimal) result = decimal * 4 print(result) Exercise 3 print("Hi I Am COE Which Is Calculator 0f Elijah") num1 = int(input("Type Your First Number:")) num2 = int(input ("Type Your Second Number:")) num3 = int(input ("Type Your Third Number:")) operator =(input ("Type a Operator:")) if (operator == "-"): answer = num1 - num2 - num3 elif (operator == "+"): answer = num1 + num2 + num3 elif (operator == "*"): answer = num1 * num2 * num3 elif (operator == "/"): answer = num1 / num2 / num3 print ("Here is the Answer:", answer) Exercise 4 #1 N=int(input("Enter the side of the square: ")) Area=N*N Perimeter=4*N print(Area) print(Perimeter) #2 FN = input("Type your First Name : ") LN = input("Type your Last Name : ") print ("Hello, " + FN + " " + LN) #3 str = input("Enter a string: ") print("Length of the input string is:", len(str)) #4 print("Input lengths of the triangle sides: ") x = int(input("x: ")) y = int(input("y: ")) z = int(input("z: ")) if x == y == z: print("Equilateral triangle") elif x==y or y==z or z==x: print("Obtuse/Scalene triangle") else: print("Scalene triangle") #5 days = int(input("Please enter days:")) seconds = days * 24 * 60 * 60 print(seconds, " Seconds") #6 num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) num3 = float(input("Enter third number: ")) if (num1 >= num2) and (num1 >= num3): largest = num1 elif (num2 >= num1) and (num2 >= num3): largest = num2 else: largest = num3 print("The largest number is", largest) #9 numberOfWordsInList = int(input("Enter number of words to be List: ")) def longestWordInList(numberOfWordsInListt): createdList = [input("Enter any word: ") for i in range(numberOfWordsInList)] lengthOfItems = [(len(items), items) for items in createdList] return max(lengthOfItems) print(longestWordInList(numberOfWordsInList))

Rock Paper Scissors

This is a typical game of rock paper scissors coded using python.

# Rock Paper Scissors from random import randint loop = input("Do you want to play rock paper scissors? Enter yes or no: ") while loop != "no": number = randint(0, 2) plays = ["rock", "paper", "scissors"] opponent = plays[number] play = str(input("Type in either rock, paper or scissors: ")) if (play != "rock") and (play != "paper") and (play != "scissors"): print("You may have misspelled a word") elif play == opponent: print("Tie! ") elif opponent == "rock": if play == "scissors": print("You lose, rock beats scissors. ") elif play == "paper": print("You win, paper beats rock. ") elif opponent == "paper": if play == "rock": print("You lose, paper beats rock. ") elif play == "scissors": print("You win, scissors beats paper") elif opponent == "scissors": if play == "rock": print("You win, rock beats scissors") elif play == "paper": print("You lose, scissors beat paper") loop = input("Do you want to play again? Enter either yes or no: ") print("Thanks for playing!")

Hangman Game

This is a typical hangman game that is coded using python and uses turtle for the graphical aspects.

# Hangman from random import randint import turtle s = turtle.getscreen() t = turtle.Turtle() t.shapesize(1, 1, 1) t.penup() t.goto(-250, -220) t.pendown() t.goto(-190, -220) t.penup() t.goto(-220, -220) t.pendown() t.goto(-220, 220) t.goto(0, 220) t.goto(0, 170) number = randint(0, 19) words = ["tiger", "television", "cinnamon", "racetrack", "lemonade", "closet", "leopard", "smoothie", "strawberry", "snowman", "pineapple", "counter", "coyote", "sewing", "movement", "paradox", "computer", "eighteen", "musical", "fantastic"] word = words[number] length = len(word) wrong_guesses = [] x = "_" underscore_list = [] for i in range(length): underscore_list.append(x) while len(wrong_guesses) < 6 and "_" in underscore_list: letter_guess = input("Input a letter you think is in the word: ") indexes = [index for index, element in enumerate(word) if element == letter_guess] if letter_guess in word: print("Nice job, that is one of the letters in the word!") for i in range(0, len(indexes)): place = indexes[0] indexes.remove(indexes[0]) underscore_list[place] = letter_guess else: wrong_guesses.append(letter_guess) print("That letter is not in the word, keep trying :)") guesses_left = 6 - len(wrong_guesses) if len(wrong_guesses) == 1: t.penup() t.goto(0, 110) t.pendown() t.circle(30) elif len(wrong_guesses) == 2: t.goto(0, -20) elif len(wrong_guesses) == 3: t.penup() t.goto(0, 90) t.pendown() t.goto(-50, 70) elif len(wrong_guesses) == 4: t.penup() t.goto(0, 90) t.pendown() t.goto(50, 70) elif len(wrong_guesses) == 5: t.penup() t.goto(0, -20) t.pendown() t.goto(-55, -70) print("You have", guesses_left, "wrong guesses left") print("These are the correct letters in the word you have guessed so far: ", underscore_list) print("These are the letters that are not in the word:", wrong_guesses) if "_" not in underscore_list: print("Nice job, you guessed the word and won the game!") elif len(wrong_guesses) == 6: t.penup() t.goto(0, -20) t.pendown() t.goto(55, -70) t.penup() t.goto(-15, 145) t.pendown() t.goto(-10, 140) t.penup() t.goto(-10, 145) t.pendown() t.goto(-15, 140) t.penup() t.goto(15, 145) t.pendown() t.goto(10, 140) t.penup() t.goto(10, 145) t.pendown() t.goto(15, 140) print("You have no more wrong guesses left, this game is lost :(") turtle.done()

Java - Two Number Calculator (add, subtract, multiply, divide)

https://replit.com/@FourTreys/MessyClearcutPaintprogram#index.js

Guessing Game

This is a game where you guess a number until you get it correct with the computer telling you if you are too high or too low!!

from random import randint number = randint(1, 100) Tries = "10" print(number) print("Welcome to the Guessing Game!!") tries = 10 guess = int(input("Please enter an integer between 1 to 100")) while guess != number: if guess > number: guess = int(input("Your guess was too high, try again!!")) print(str(tries) + " Tries left") tries -= 1 if tries == 0: print("You lost! The actual number was!", number, "If you want, you can try again!") break elif guess < number: guess = int(input("Your guess was too low, try again!!")) print(str(tries) + " Tries left") tries -= 1 if tries == 0: print("You lost! The actual number was!", number, "If you want, you can try again!") break if guess == number: print("Your guess was correct!!!!")
1 2 ... 35