Rock Paper Scissor Game using Python

 Well, hello programmers, in this post you will know how we will create a Rock Paper Scissor Game using python.

As prerequisites, 

you need to import a random module, and don't worry it is beginner-friendly, so just copy the below code, and save it into a python file, and run the program and see the result.

 from random import randint  
 #create a list of play options  
 t = ["Rock", "Paper", "Scissors"]  
 #assign a random play to the computer  
 computer = t[randint(0,2)]  
 #set player to False  
 player = False  
 while player == False:  
 #set player to True  
   player = input("Rock, Paper, Scissors?")  
   if player == computer:  
     print("Tie!")  
   elif player == "Rock":  
     if computer == "Paper":  
       print("You lose!", computer, "covers", player)  
     else:  
       print("You win!", player, "smashes", computer)  
   elif player == "Paper":  
     if computer == "Scissors":  
       print("You lose!", computer, "cut", player)  
     else:  
       print("You win!", player, "covers", computer)  
   elif player == "Scissors":  
     if computer == "Rock":  
       print("You lose...", computer, "smashes", player)  
     else:  
       print("You win!", player, "cut", computer)  
   else:  
     print("That's not a valid play. Check your spelling!")  
   #player was set to True, but we want it to be False so the loop continues  
   player = False  
   computer = t[randint(0,2)]  
 #create a list of play options  
 t = ["Rock", "Paper", "Scissors"]  
 #assign a random play to the computer  
 computer = t[randint(0,2)]  
 #set player to False  
 player = False  
 while player == False:  
 #set player to True  
   player = input("Rock, Paper, Scissors?")  
   if player == computer:  
     print("Tie!")  
   elif player == "Rock":  
     if computer == "Paper":  
       print("You lose!", computer, "covers", player)  
     else:  
       print("You win!", player, "smashes", computer)  
   elif player == "Paper":  
     if computer == "Scissors":  
       print("You lose!", computer, "cut", player)  
     else:  
       print("You win!", player, "covers", computer)  
   elif player == "Scissors":  
     if computer == "Rock":  
       print("You lose...", computer, "smashes", player)  
     else:  
       print("You win!", player, "cut", computer)  
   else:  
     print("That's not a valid play. Check your spelling!")  
   #player was set to True, but we want it to be False so the loop continues  
   player = False  
   computer = t[randint(0,2)]  

And, guess what you will see something like the below picture.


2 Comments

If you have have any doubt please let me know

  1. Best Online Casino - Oklahoma Casino Guide
    Best Online Casino in Oklahoma: Baccarat. Casino 한게임 포커 클래식 Games, Specialties, Poker, Bingo, 벳인포해외배당흐름 Poker, Blackjack. Baccarat. 승인 전화 없는 꽁 머니 사이트 Welcome Bonus: 100% up to $10,000. 1xbet download Deposit Methods: Mastercard, 사설토토

    ReplyDelete
  2. Best 8 Casinos in Las Vegas, NV - Mapyro
    Las Vegas Casinos 김천 출장안마 in Las Vegas - 전라북도 출장샵 10 청주 출장안마 Mapyro® MGM Grand Las Vegas, The Strip, Harrah's, Planet Hollywood, Circus Circus Circus Circus Hotel, MGM Grand Las 안양 출장샵 Vegas. 메리트 카지노 먹튀

    ReplyDelete
Previous Post Next Post

Ads

Ads