This is a simple rock paper scissor game in python. This game code uses the random and OS module of python.
This is a simple code for a rock paper scissor game using python. the game uses the Random module to generate the computer's choice.
We assign every move a specific value:- Rock-1 Paper-2 Scissor-3
The player first needs to enter their choice of the move by entering the corresponding value.
Once we obtain this value then we use 'random.randint(1,3)' to generate the computer's move.
Both of these values are then passed to a function to compare the two values. If the player wins the function returns 1. If the computer wins the function returns 2. If it results in a draw the function returns 0.
These values are used to keep track of the player's score. After every round, we ask the player whether he/she wants to continue. If the player wants to continue we clear the screen and the process repeats.
We use the OS module to clear the screen after every round.
Once the player wants to end the game the code displays the final score of the player and computer and prints whether the player won or lost. After this the code waits for the player to press the enter key before terminating execution.
Submitted by Archisman Bhattacharya (Archi651)
Download packets of source code on Coders Packet