Share on social networks!

“Rock, Paper, Scissors” with Python

Today we are going to teach you how to program the mythical rock, paper, scissors with a simple code.

Python is one of the most powerful and used languages today. He Master in Advanced Programming in Python will train you to be a programmer expert in areas as prominent and current as Big Data, Hacking, Machine Learning.

random method

We will use the random method so that it automatically generates the “play” of the machine.

program rock paper scissors in python

The code is very simpleOn the one hand, we generate a random number with random between 0 and 3 that will be the machine's move. Then with a simple menu we will make our choice and then we just have to consider all the options with the if conditional.

On the other hand, if we want to play several times, we will only have to enter a while loop in the game with the typical yes or no question at the end.

python rock paper scissors

So our complete code It would look like this:

rock paper scissors in python

Subscribe to our newsletter to stay up to date with all the news

EIP International Business School informs you that the data in this form will be processed by Mainjobs Internacional Educativa y Tecnológica, SA as the person responsible for this website. The purpose of collecting and processing personal data is to respond to the query made as well as to send information about the services of the data controller. Legitimation is the consent of the interested party.
You can exercise your rights of access, rectification, limitation and deletion of data in compliance@grupomainjobs.com as well as the right to file a claim with the supervisory authority. You can consult additional and detailed information on Data Protection in the Privacy Policy that you will find in our Web page

2 thoughts on ““Piedra, papel, tijera” con Python”

Leave a comment