Skip to content

Instantly share code, notes, and snippets.

@Janbuller

Janbuller/all.py Secret

Last active August 27, 2017 10:22
Show Gist options
  • Save Janbuller/49a372d40a293c601e1e5251b12c42f5 to your computer and use it in GitHub Desktop.
Save Janbuller/49a372d40a293c601e1e5251b12c42f5 to your computer and use it in GitHub Desktop.
All the small solutions to my "python-beginner-projects" repository!
from function import start
while True:
print("Try all my small solutions to \"Python Beginner Projects\"")
print("Remember all input in these are case-sensitive")
print("")
print("Type 1 for \"Addition Calculator\"")
print("Type 2 for \"Name Generator\"")
print("Type 3 for \"Rock Paper Scissors\"")
try:
start(game=input("Type a number 1-3: "))
except:
print("Please only type numbers!")
import os
import time
from random import randint
def start(game="1"):
os.system("cls")
if game == "1":
print("Addition Calculator")
numList = []
whileLoop1 = 0
while whileLoop1 == 0:
numList.append(int(input("Please type a number:")))
os.system('cls')
while True:
nextNumber = input("Do you want to type another number:")
if nextNumber == "yes" or nextNumber == "Yes" or nextNumber == "YES" or nextNumber == "yEs" or nextNumber == "yeS" or nextNumber == "yES" or nextNumber == "YeS":
break
elif nextNumber == "no" or nextNumber == "No" or nextNumber == "nO" or nextNumber == "NO":
whileLoop1 = 1
print(sum(numList))
else:
print("Please only type Yes or No")
time.sleep(2.5)
os.system('cls')
elif game == "2":
tryNumber = 0
print("Name Generator!")
while tryNumber == 0:
try:
amount = int(input("How many names do you want to generate?"))
tryNumber = 1
except ValueError:
print("Please only type numbers!")
time.sleep(2.5)
os.system('cls')
amountDone = 1
os.system('cls')
firstNames = (
"Adam", "Bob", "Tom", "Ellis", "Monet", "Franklyn", "Gwen", "Peter", "Neil", "Leonard", "Howard", "Brian",
"Penny", "Matthew", "Joe", "Albert", "Jane", "Gordon", "Jack", "Lois", "Kyle", "Kenny", "Steve", "Olivia",
"Janelle", "Malissa", "Hailey", "Katie", "James", "John", "Robert", "Micheal", "William", "Charles", "David")
lastNames = (
"Short", "Harmon", "Jacobson", "Antonyson", "Bullard", "Washington", "Armstrong", "Tash", "Durand", "Colbert",
"Matthews", "Santoro", "Kennedy", "Swanson", "Smith", "Johnson", "Jones", "Clark", "Jackson", "Robinson",
"Miller", "Scottson", "Nelson", "Cooper", "Parker", "Adams", "Copeland", "Davenport", "Bruce", "Perry",
"Fisher", "Russell")
middleNames = (
"James", "Lee", "Micheal", "Joseph", "Alexander", "David", "William", "Andrew", "Matthew", "Robert", "Marie",
"Ann", "Rose", "Mae", "Jane", "Thomas", "Nicole", "Lynn", "Grace", "Faith", "Elizabeth", "Renee", "Allen",
"Anthony", "Jones")
while amountDone <= amount:
num1 = randint(1, len(firstNames) - 1)
num2 = randint(1, len(lastNames) - 1)
num3 = randint(1, len(middleNames) - 1)
if firstNames[num1] == middleNames[num3]:
foo = "foo"
elif lastNames[num2] == middleNames[num3]:
bar = "bar"
else:
print(firstNames[num1], middleNames[num3], lastNames[num2])
amountDone += 1
input("Press enter to close")
elif game == "3":
while True:
print("Rock, Paper, Scissors")
print("")
print("Type 1 For Rock")
print("Type 2 For Paper")
print("Type 3 For Scissors")
Num1 = 0
try:
Num1 = int(input("Type a Number:"))
except ValueError:
print("")
Num2 = randint(1, 3)
if Num1 == 1:
if Num2 == 1:
print("The computer chooses Rock!")
time.sleep(0.5)
print("You have tied!")
elif Num2 == 2:
print("The computer chooses Paper!")
time.sleep(0.5)
print("You have lost!")
elif Num2 == 3:
print("The computer chooses Scissors!")
time.sleep(0.5)
print("You have won!")
elif Num1 == 2:
if Num2 == 1:
print("The computer chooses Rock!")
time.sleep(0.5)
print("You have won!")
elif Num2 == 2:
print("The computer chooses Paper!")
time.sleep(0.5)
print("You have tied!")
elif Num2 == 3:
print("The computer chooses Scissors!")
time.sleep(0.5)
print("You have lost!")
elif Num1 == 3:
if Num2 == 1:
print("The computer chooses Rock!")
time.sleep(0.5)
print("You have lost!")
elif Num2 == 2:
print("The computer chooses Paper!")
time.sleep(0.5)
print("You have won!")
elif Num2 == 3:
print("The computer chooses Scissors!")
time.sleep(0.5)
print("You have tied!")
else:
print("Please only type 1, 2 or 3")
time.sleep(2)
Again = int(input("Type 1 to play again else press enter"))
if Again == 1:
Again = 0
else:
break
os.system('cls')
else:
print("Please only type a number between 1 and 3")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment