×

Rock, Paper, Scissors

A game with a computer, implemented using Python

Purpose of the project:

I started this project to learn how to generate random numbers using the `random` module in Python, to improve my skills with functions, lists and loops, and to create an interactive game where the user can play against the computer. This allowed me to develop my skills in creating game algorithms, and to better understand how to implement game logic and handle user input.

Objective:

I achieved the goal by creating a game called "Rock, Paper, Scissors" where the user competes with the computer. The program generates a random choice for the computer and determines the winner after each round based on classic rules. The program allows you to play several times in a row in a loop, without restarting. It also implemented a function for checking the correctness of the input and the ability to exit the game by the command "exit".

Approach:

To solve the problem, I used the `random` module to generate a random selection of computers and a list to store the available actions - "rock", "paper", "scissors". I wrote a function to determine the winner using conditions, and also implemented a loop that allows the user to play multiple rounds without restarting the program. The score is updated after each round and displayed on the screen. The program also checks the user's input to ensure that there are no invalid values, and continues asking for input until a valid value is entered. I also added the ability to exit the game by entering "exit".

Project duration:

The project took me about 8 days, including coding, and testing the game.

My role:

I designed the entire game myself: I created the logic for determining the winner, used loops to repeat the game, added user input processing, and saved the total score to a file for later use. My role also included testing various scenarios and handling exceptions to ensure the program worked correctly even with invalid input. The project helped me better understand how lists, functions, and loops work in Python, as well as how data can be saved to files.

Other Works