From 2a20931c56da707c9849c169485d2d35fa0645f5 Mon Sep 17 00:00:00 2001 From: Guruji-D-Gr8 Date: Fri, 12 Oct 2018 23:29:16 +0530 Subject: [PATCH 1/7] added RockPaperScissors.py file --- RockPaperScissors.py | 117 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 RockPaperScissors.py diff --git a/RockPaperScissors.py b/RockPaperScissors.py new file mode 100644 index 0000000..ed6d907 --- /dev/null +++ b/RockPaperScissors.py @@ -0,0 +1,117 @@ +counter = 0 +global player1 +global player2 +global p1 +global p2 +p1 = 0 +p2 = 0 + +def rules(): + print('Rock smashes Scissor, Scissor cuts Paper, Paper covers Rock \n') + +def takeInputp1(): + global player1 + player1 = int(input('Player1 enter your choice: Rock[1], Paper[2], Scissor[3] \n')) + print('') + + if(player1>3 or player1<1): + print('Enter a number between 1 and 3\n') + takeInputp1() + +def takeInputp2(): + global player2 + player2 = int(input('Player2 enter your choice: Rock[1], Paper[2], Scissor[3]\n')) + if(player2>3 or player2<1): + print('Enter a number between 1 and 3\n') + takeInputp2() + +def compare(): + global p1 + global p2 + global player2 + global player1 + if(player1==1): + if(player2==2): + print('Player2 wins') + p2+=1 + if(player2==3): + print('Player1 wins') + p1+=1 + if(player2==1): + print("It's a draw!!!") + + if(player1==2): + if(player2==3): + print('Player2 wins') + p2+=1 + if(player2==1): + print('Player1 wins') + p1+=1 + if(player2==2): + print("It's a draw!!!") + + if(player1==3): + if(player2==1): + print('Player2 wins') + p2+=1 + if(player2==2): + print('Player1 wins') + p1+=1 + if(player2==3): + print("It's a draw!!!") + +def displayScore(): + global p1 + global p2 + print("Player1 score: {}, Player2 score: {} \n".format(p1, p2)) + +def playAgain(): + play = input('Do you want to play again, Yes[y] or No[n]\n') + if play in ['y', 'Yes','yes']: + mainfunc() + elif play in ['n','No','no']: + final() + quit() + else: + print('Please enter a valid input') + playAgain() + +def final(): + global p1 + global p2 + if(p1>p2): + print('Player1 is the overall winner') + displayScore() + elif(p2>p1): + print('Player2 is the overall winner') + displayScore() + else: + print("It's a draw") + displayScore() + + + +def mainfunc(): + global counter + if(counter==0): + rule = input('Would you like to know the rules, Yes[y] or N[n]\n') + if rule in ['y', 'Yes','yes']: + rules() + elif rule in ['n','No','no']: + pass + else: + print('Please enter a valid input') + main() + + takeInputp1() + takeInputp2() + + compare() + + displayScore() + + counter+=1 + + playAgain() + +mainfunc() \ No newline at end of file From 3d7d868af3ab344a680d5945b0f46d573e1b8c30 Mon Sep 17 00:00:00 2001 From: Yatharth Gupta Date: Sat, 27 Oct 2018 00:17:44 +0530 Subject: [PATCH 2/7] hello --- hello world.py.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 hello world.py.txt diff --git a/hello world.py.txt b/hello world.py.txt new file mode 100644 index 0000000..8eb74cf --- /dev/null +++ b/hello world.py.txt @@ -0,0 +1 @@ +print('Hello world') \ No newline at end of file From ae038669ecc21da29c2398f88dfe7fff20f473fb Mon Sep 17 00:00:00 2001 From: Yatharth Gupta Date: Sat, 27 Oct 2018 00:21:07 +0530 Subject: [PATCH 3/7] hello --- hello world.py.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hello world.py.txt b/hello world.py.txt index 8eb74cf..5f11119 100644 --- a/hello world.py.txt +++ b/hello world.py.txt @@ -1 +1,2 @@ -print('Hello world') \ No newline at end of file +print('Hello world') +print('What the hell') \ No newline at end of file From a775424e7351c80e68e3d215602df8f921896686 Mon Sep 17 00:00:00 2001 From: Yatharth Gupta Date: Sat, 27 Oct 2018 00:25:07 +0530 Subject: [PATCH 4/7] hello --- hello world.py.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hello world.py.txt b/hello world.py.txt index 5f11119..33a9582 100644 --- a/hello world.py.txt +++ b/hello world.py.txt @@ -1,2 +1,3 @@ print('Hello world') -print('What the hell') \ No newline at end of file +print('What the hell') +print('a') \ No newline at end of file From 60414d9890f5723640530a8615c0abe6474499ac Mon Sep 17 00:00:00 2001 From: Yatharth Gupta Date: Sat, 27 Oct 2018 00:28:49 +0530 Subject: [PATCH 5/7] hello --- hello world.py.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/hello world.py.txt b/hello world.py.txt index 33a9582..2253dbe 100644 --- a/hello world.py.txt +++ b/hello world.py.txt @@ -1,3 +1,4 @@ print('Hello world') print('What the hell') +print('a') print('a') \ No newline at end of file From eb7b0b8394b07f53dc1918f588e984959e6257a8 Mon Sep 17 00:00:00 2001 From: Yatharth Gupta Date: Sat, 27 Oct 2018 00:30:29 +0530 Subject: [PATCH 6/7] hello --- hello world.py.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/hello world.py.txt b/hello world.py.txt index 2253dbe..0a8fd1b 100644 --- a/hello world.py.txt +++ b/hello world.py.txt @@ -1,4 +1,5 @@ print('Hello world') print('What the hell') print('a') +print('a') print('a') \ No newline at end of file From 215bd1fedface418817c9e8e0f837e1aa23060b5 Mon Sep 17 00:00:00 2001 From: Yatharth Gupta Date: Sat, 27 Oct 2018 00:32:05 +0530 Subject: [PATCH 7/7] hello --- hello world.py.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/hello world.py.txt b/hello world.py.txt index 0a8fd1b..6d8a6ed 100644 --- a/hello world.py.txt +++ b/hello world.py.txt @@ -2,4 +2,5 @@ print('Hello world') print('What the hell') print('a') print('a') +print('a') print('a') \ No newline at end of file