Skip to main content

Welcome to Coding 4 Programming

Addition of Two Binary Numbers | Function | Python

Stone / Rock Paper Scissor Game | Snake Water Gun Game | Random Function| Import | Python

Python Program or Project of Stone / Rock, Paper, Scissor (you can also modify it into Snake, Water, Gun Game) through Function, and using Module through Import and using Random Function, completely user Friendly without any type of Errors. 

  • Coding for the above Program.

  1. import random
  2. def winner():
  3.     win=True
  4.     if c=="r":
  5.         if p=="p":
  6.             return win
  7.         else:
  8.             win=False
  9.             return win
  10.     elif c=="p":
  11.         if p=="s":
  12.             return win
  13.         else:
  14.             win=False
  15.             return win
  16.     else:
  17.         if p=="r":
  18.             return win
  19.         else:
  20.             win=False
  21.             return win
  22. print("Welcome to Stone Paper Scissor Game!")
  23. print("Press 'r' for Stone/Rock")
  24. print("Press 'p' for Paper")
  25. print("Press 's' for Scissor")
  26. p=input("Enter your choice=")
  27. if p not in["r","p","s"]:
  28.     print("Wrong Input.")
  29.     exit()
  30. c=random.choice(["r","p","s"])
  31. print("Computer Selected",c)
  32. if p==c:
  33.     print("Game Draw")
  34. else:
  35.     w=winner()
  36.     if w:
  37.         print("Congrats... You Won the Game")
  38.     else:
  39.         print("Oops! You Loose the Game")
  • Output of the Temperature Conversion Program.

    Stone Paper Scissor Game
    Stone Paper Scissor Game



    Notes:

    • If you have any problem related to this program. Please do comment your Problem or Mail us.
    • For illustrating the any concept you can comment by line number.
    • Thank you! For more programs do regular visit to Coding 4 Programming.

    Comments

    Popular Posts