ads

Rock Paper and Scissors with Python Project for Beginner 2024

 In this article, I will learn how to make a Rock, Paper, Scissors game with Python. Our goal at Rock, Paper and Scissors is to create a command line game where the user has a choice between rock, paper and scissors and if the user wins, join and finally the user exits. game, the score is displayed to the user.

A game of rock, paper and scissors with Python

To create a game of Rock, Paper and Scissors with Python, select the user's choice, then compare the list of choices with the computer's choice obtained using the random module in Python, and the user wins. then the score will increase by 1:

 

random import

options = ["Rock", "Paper", "Scissors"]

computer = random.choice(choice);

player = error

cpu_score = 0

player_score = 0

True:

player = input("Rock, Paper, or Scissors?") capitalize()

## Rock, paper and scissors situation

if player == computer:

print ("Tie!")

elif player == "Stone":

if computer == "Paper":

print("You will lose!", computer, "cover", player)

cpu_score += 1

other

print("You're guilty!", player, "beat", computer)

player_score += 1

elif player == "Paper":

if computer == "Scissors":

print("You lost!", computer, "person", player)

cpu_score += 1

other

print ( "Sorry!" , player , "caps" , computer )

player_score += 1

elif player == "Scissors":

if computer == "Stone":

print ( "You will lose..." , computer , "beat" , player );

cpu_score += 1

other

print ( "Sorry!" , player , "person" , computer )

player_score += 1

elif player == 'End':

print("Final score: ")

print (f "CPU: {cpu_score}" )

print (f "Player: {player_score}" )

pause for a moment

 

 

Post a Comment

0 Comments