0% found this document useful (0 votes)
70 views

Urok 3

The document defines a game function that plays a round of rock-paper-scissors between a player and computer. The function takes the player's choice and a result dictionary as parameters. It randomly generates the computer's choice, compares the choices to determine a winner, updates the result scores accordingly, and prints out the choices, winner, and running scores.

Uploaded by

Степан
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

Urok 3

The document defines a game function that plays a round of rock-paper-scissors between a player and computer. The function takes the player's choice and a result dictionary as parameters. It randomly generates the computer's choice, compares the choices to determine a winner, updates the result scores accordingly, and prints out the choices, winner, and running scores.

Uploaded by

Степан
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import random

def game(choice, result):


print("")
print("===== Start Game rock, paper, scissors =====")
computer_choice = random.choice("rps")
print("--------------------------------------------")
print("Your select – ",
str.capitalize(choice))
print("Computer select —",
str.capitalize(computer_choice))
if str.lower(choice) == computer_choice:
print("Result of game – Draw")
print("Score, Computer", result["computer"], "—", result["player"],
"Player")
elif str.lower(choice) == "r" and computer_choice == "p":
result["computer"]+=1
print("------ Computer Wins ------")
print("Score, Computer", result["computer"],"—", result["player"],
"Player")
elif str.lower(choice) == "r" and computer_choice == "s":
result["player"]+=1
print("------Player Wins------")
print("Score, Computer", result["computer"],"—", result["player"],
"Player")
elif str.lower(choice) == "p" and computer_choice == "s":
result["computer"] += 1
print("------Computer Wins------")
print("Score, Computer", result["computer"],"—", result["player"],
"Player")
elif str.lower(choice) == "p" and computer_choice == "r":
result["player"] += 1
print("------Player Wins------")
print("Score, Computer", result["computer"],"—", result["player"],
"Player")
elif str.lower(choice) == "s" and computer_choice == "r":
result["computer"] += 1
print("------Computer Wins------")
print("Score, Computer", result["computer"],"—", result["player"],
"Player")
elif str.lower(choice) == "s" and computer_choice == "p":
result["player"] += 1
print("------Player Wins------")
print("Score, Computer", result["computer"],"—", result["player"],
"Player")

result = {"computer": 0, "player": 0}


choise = input("Select R/P/S – ")
game(choice=choise, result=result)

You might also like