commit 33451d727a9d3bbf43fcdd6bcdad5e20f9987990 Author: Logen Kain Date: Sat Feb 11 01:21:04 2017 -0700 lesson 3 done diff --git a/Problem Set 1.pdf b/Problem Set 1.pdf new file mode 100644 index 0000000..dfc4db3 Binary files /dev/null and b/Problem Set 1.pdf differ diff --git a/ps1_1_joseph_green.py b/ps1_1_joseph_green.py new file mode 100644 index 0000000..5188ef3 --- /dev/null +++ b/ps1_1_joseph_green.py @@ -0,0 +1,25 @@ +#When will user be 100 +#What is your name? +#How old are you? +#Hey USER you will be 100 in YEAR + +import time + +user = None +age = None +birthday = None + +user = input("What is your name? ") +age = input("How old are you? ") +birthday = input("Have you had your birthday yet this year? (y/n) ") + +if birthday == "y" or birthday == "n": + try: + age = int(age) + if birthday == "n": + age += 1 + print("Hey ", user, "you will be 100 in the year ", 100 - age + time.gmtime().tm_year) + except: + print("Please use only Arabic numerals for your age!!!") +else: + print("Please only enter a 'y' or an 'n'") diff --git a/ps1_2_joseph_green.py b/ps1_2_joseph_green.py new file mode 100644 index 0000000..30f9e10 --- /dev/null +++ b/ps1_2_joseph_green.py @@ -0,0 +1,19 @@ +#ask user for a number +#report even or odd + +number = None +result = None +evenOdd = None + +try: + number = int(input("Please enter a number: ")) + result = number % 2 + if result == 0: + evenOdd = "even" + else: + evenOdd = "odd" + + print(str(number) + ",is an " + evenOdd + " number") +except: + print("Only enter an integers!") + diff --git a/ps1_3_joseph_green.py b/ps1_3_joseph_green.py new file mode 100644 index 0000000..d60b3f4 --- /dev/null +++ b/ps1_3_joseph_green.py @@ -0,0 +1,53 @@ +# Two player Rock Paper Scissors game +# Congradulate winner +# Ask if players wish to play again + +players = ["",""] +quit = False +playersQuit = "y" +winner = "player " +tie = None + +while quit == False: + i = 0 + tie = None + winner = "player " + + while i <=1: #Is there no for (i=0; i<2; i++) equiv in python? + print ("\n" * 100) + players[i] = input("Player " + str(i + 1) + ", enter (R)ock, (P)aper, or (S)cissors:" ) + players[i] = players[i].lower() + + if players[i] == "r" or players[i] == "p" or players[i] == "s": + i += 1 + ## else, repeat question + + + + if players[0] == players[1]: + tie = True + print("We have a tie!!!") + + elif players[0] == "r" and players[1] == "p": + winner += "2" + elif players[0] == "r" and players[1] == "s": + winner += "1" + + elif players[0] == "s" and players[1] == "p": + winner += "1" + elif players[0] == "s" and players[1] == "r": + winner += "2" + + elif players[0] == "p" and players[1] == "s": + winner += "2" + elif players[0] == "p" and players[1] == "r": + winner += "1" + + if tie != True: + print("Congrats", winner, "You've won!") + + + playersQuit = input("Would you like to play again? (y/n): ") + + if playersQuit.lower() == "n": + quit = True diff --git a/ps1_4_joseph_green.py b/ps1_4_joseph_green.py new file mode 100644 index 0000000..e69de29