Python Forum
Rock Paper Scissor GAME
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rock Paper Scissor GAME
#1
I learned basic python in 1 week and here is what i developed. It is a basic rock paper scissor game between user and computer. One who scores 5 points wins the game. It took me 30 minutes to complete this. Here is the code
import random
print ('WELCOME TO ROCK PAPER SCISSOR GAME\n\t\tDEVELOPED BY INAMULLAH9\n')
cscore=0
pscore=0
def score():
    global cscore
    global pscore
    global name
    print (name,'score :',pscore)
    print ('computer score: ',cscore)
print('PLEASE ENTER YOUR NAME')
name=input()
print(name, 'VS computer')
while True:
    if pscore == 5:
        print (name,'WIN THE MATCH')
        input()
        break
    elif cscore == 5:
        print ('Computer WINS THE MATCH')
        input()
        break
    print('Enter\n1 for ROCK \n2 for PAPER \n3 for SCISSOR')
    x=int(input())
    if x <1 or x>3:
        print('invalid choice\ntry again')
        continue
    p=random.randint(1,3)
    if p==1 and x==1:
        print ('rock vs rock')
    if p==2 and x==2:
        print ('paper vs paper')
    if p==3 and x==3:
        print ('scissor vs scissor')
    if p==1 and x==2:
        print ('rock vs paper')
    if p==2 and x==3:
        print ('paper vs scissor')
    if p==3 and x==1:
        print ('scissor vs rock')
    if p==2 and x==1:
        print ('paper vs rock')
    if p==3 and x==2:
        print ('scissor vs paper')
    if p==1 and x==3:
        print ('rock vs scissor')

    if x==1 and p==1 or x==2 and p==2 or x==3 and p==3:
        print('DRAW')
        score()
        continue
    elif x==1 and p==3 or x==2 and p == 1 or x==3 and p==2:
        print(name," Win")
        pscore+=1
        score()
        continue
    elif p==1 and x==3 or p==2 and x==1 or p==3 and x==2:
        print('Computer Win')
        cscore+=1
        score()
        continue 
Reply


Messages In This Thread
Rock Paper Scissor GAME - by inamullah9 - Aug-06-2019, 05:07 PM
RE: Rock Paper Scissor GAME - by ThomasL - Aug-10-2019, 10:14 AM
RE: Rock Paper Scissor GAME - by perfringo - Aug-11-2019, 08:27 AM
RE: Rock Paper Scissor GAME - by ichabod801 - Aug-11-2019, 12:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Another Rock, Paper, Scissors Yoriz 4 3,185 Jun-30-2020, 07:56 PM
Last Post: Yoriz
  The tkinter version of Rock Paper Scissors menator01 3 3,192 Jun-28-2020, 07:15 AM
Last Post: ndc85430
  My version of Rock Paper Scissors menator01 12 6,104 Jun-27-2020, 10:25 PM
Last Post: menator01
  PyQt5 Version of Rock, Paper, & Scissors menator01 8 3,674 Jun-06-2020, 12:15 PM
Last Post: pyzyx3qwerty
  Rock, Paper, Scissors foksikrasa 11 4,326 May-28-2020, 05:58 PM
Last Post: BitPythoner
  A CLI based Rock,Paper or Scissor game. Ablazesphere 7 4,524 Oct-28-2018, 07:25 AM
Last Post: Ablazesphere
  A basic Rock-paper-scissors game by me... Unlimiter 0 2,478 Dec-25-2017, 03:41 PM
Last Post: Unlimiter
  Basic Rock, Paper, Scissors CinnamonBeard 1 3,555 Dec-19-2017, 02:32 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020