From 0341677cc1026ee3d64f395496c8e89ee36f046b Mon Sep 17 00:00:00 2001 From: Jonathan Polina <69684393+jpolina@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:22:18 -0400 Subject: [PATCH 1/3] Added spock and lizard, input validation, and changed var1 to choice --- .DS_Store | Bin 0 -> 6148 bytes RockPaperScissors.py | 89 ++++++++++++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ced2d5a0054b3e9f2daebb2a3a633d24ffe73675 GIT binary patch literal 6148 zcmeHK%}(1u5S|U8tc5CaK!T$$m3oM(q@aRSRdUmC;7|$G6&#=f8%JQ(c%#@MqG>9> zM*9YRls-Wp2fqCwY688Xs;y?C-EU@gW~}`-@_L9!bcRWrs6j*$Lu1XubdTtDJ?==& zc@}{}*VxU}X`HDTwl2u>_cNf+u1+ak&>0nT=l2q8Pp^%bjZEX>QPFqj{3GsXX;HRX zKSgb!zW8WKO1Uf_%ManX8ii$44vS7SIMmi&RG!C9f3H+F)uVVn?TwBbt8Y|ZMrqy~ znB+9+A>`;F%@Z~1s9~NIrcP)VJkOKfabtZv-fll{`t6PFNz)&1ZMB;I=EjT3#FJ}J z+OKv`F0MX}KTp1VwPzvlM>VqI@D{#7nQrhh9ORkG&*0PX9=)R-dQDw=3w#E$k~ylr zBkEVGR*|9Tls?iPMbxJr4Jd@2Qh}d>RiI9vu4e0qwYfSlS(pK4fEjpr2HdMqEzlW75fb-0Z{H=q7MUps(-!^$E&5Mfh+HdVM5L%7aC z*mSH1F21s8(@B^oqmFyBa2<+pjfe0}IEla_&&&WbFw4M#H5>Z=-}!z2KbyoBGr$b| zR}6@HH|%z>C3m;p*_^&>eT)+fEjq5UI8A|Ku42UMt9Tv52>iZQfPurxB0LcO5HK|G K#0>mV25tbbV|hjZ literal 0 HcmV?d00001 diff --git a/RockPaperScissors.py b/RockPaperScissors.py index b7cc796..1ef86f5 100644 --- a/RockPaperScissors.py +++ b/RockPaperScissors.py @@ -1,44 +1,79 @@ ## # # Author: FX Coding Club -# Date 9/24/2020 +# Contributor: Jonathan Polina +# Date 9/27/2020 # +import random +# These are the possible choices in the game, using the randint function, the computer will be a choice based on the +# integer it chooses +list = ['rock', 'paper', 'scissors', 'spock', 'lizard'] +computerChoice = list[random.randint(0, 4)] +choiceIsValid = False +choice = '' +while not choiceIsValid: + choice = input("Please enter your choice: ") + choice = choice.lower() + # iterates through the options and switches choiceIsValid to true if a match is found + for i in list: + if choice == i: + choiceIsValid = True + if not choiceIsValid: + print("Your choice is not valid. Try again.") -# These are the possible choices in the game, using the randint function, the computer will be a choice based on the integer it chooses -list = ['rock', 'paper', 'scissors'] +# create the win and lose message functions +def win_message(): + print('You chose ' + choice + ' and the computer chose ' + computerChoice + '. You win!') -# Compare var1 and computerChoice to see who wins -# The following is all the comparisons if the computer chooses "Rock" -if computerChoice == 'rock' and var1 == 'scissors'): - print('You chose ' + var1 + ' and the computer chose ' + - computerChoice + ', The computer wins!') +def lose_message(): + print('You chose ' + choice + ' and the computer chose ' + computerChoice + '. The computer wins!') -elif computerChoice == 'rock' and var1 == 'paper'): - print('You chose ' + var1 + ' and the computer chose ' + - computerChoice + ', You win!') -# The following is all the comparisons if the computer chooses "Paper" -elif computerChoice == 'paper' and var1 == 'rock'): - print('You chose ' + var1 + ' and the computer chose ' + - computerChoice + ', The computer wins!') +# Compare choice and computerChoice to see who wins -elif computerChoice == 'paper' and var1 == 'scissors'): - print('You chose ' + var1 + ' and the computer chose ' + - computerChoice + ', You win!') +# The following is all the comparisons if the computer chooses "rock" +if computerChoice == 'rock': + if choice == 'spock' or choice == 'paper': + win_message() + elif choice == 'lizard' or choice == 'scissors': + lose_message() -# The following is all the comparisons if the computer chooses "Scissors" -elif computerChoice == 'scissors' and var1 == 'paper'): - print('You chose ' + var1 + ' and the computer chose ' + - computerChoice + ', The computer wins!') +# The following is all the comparisons if the computer chooses "paper" +elif computerChoice == 'paper': + if choice == 'lizard' or choice == 'scissors': + win_message() + elif choice == 'spock' or choice == 'rock': + lose_message() + + +# The following is all the comparisons if the computer chooses "scissors" +elif computerChoice == 'scissors': + if choice == 'spock' or choice == 'rock': + win_message() + elif choice == 'lizard' or choice == 'paper': + lose_message() + + +# The following is all the comparisons if the computer chooses "spock" +elif computerChoice == 'spock': + if choice == 'paper' or choice == 'lizard': + win_message() + elif choice == 'rock' or choice == 'scissors': + lose_message() + + +# The following is all the comparisons if the computer chooses "lizard" +elif computerChoice == 'lizard': + if choice == 'scissors' or choice == 'rock': + win_message() + elif choice == 'spock' or choice == 'paper': + lose_message() -elif computerChoice == 'scissors' and var1 == 'rock'): - print('You chose ' + var1 + ' and the computer chose ' + - computerChoice + ', You win!') # The case in which both the computer and the user chose the same one, and they tie -else: - print('You chose ' + var1 + ' and the computer chose ' + +if computerChoice == choice: + print('You chose ' + choice + ' and the computer chose ' + computerChoice + ', you tied!') From 6b91358a9f93259e55548b0e5a9e6e450424373c Mon Sep 17 00:00:00 2001 From: Jonathan Polina <69684393+jpolina@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:26:05 -0400 Subject: [PATCH 2/3] Changed contributer name to jpolina --- RockPaperScissors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RockPaperScissors.py b/RockPaperScissors.py index 1ef86f5..41a2d74 100644 --- a/RockPaperScissors.py +++ b/RockPaperScissors.py @@ -1,7 +1,7 @@ ## # # Author: FX Coding Club -# Contributor: Jonathan Polina +# Contributor: jpolina # Date 9/27/2020 # import random From d6e9be694c22d9c096cd28e578b7ca9f49e5410c Mon Sep 17 00:00:00 2001 From: Jonathan Polina <69684393+jpolina@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:33:47 -0400 Subject: [PATCH 3/3] Fixed the date --- RockPaperScissors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RockPaperScissors.py b/RockPaperScissors.py index 41a2d74..116bf75 100644 --- a/RockPaperScissors.py +++ b/RockPaperScissors.py @@ -2,7 +2,7 @@ # # Author: FX Coding Club # Contributor: jpolina -# Date 9/27/2020 +# Date: 10/27/2020 # import random