Python is a multipurpose language and one can do literally anything with it. Python can also be used for game development. Let’s create a simple command line Rock-Paper-Scissor game without using any external game libraries like PyGame.
In this game, user gets the first chance to pick the option among Rock, paper and scissor. After that computer select from remaining two choices(randomly), then winner is decided as per the rules.
Winning Rules as follows : Rock vs paper-> paper wins Rock vs scissor-> Rock wins paper vs scissor-> scissor wins.
In this game, randint() inbuilt function is used for generating random integer value within the given range.
Below is the implementation :
winning Rules of the Rock paper and scissor game as follows: rock vs paper->paper wins rock vs scissors->rock wins paper vs scissors->scissors wins Enter choice 1. Rock 2. paper 3. scissor User turn: 1 User choice is: Rock Now its computer turn....... computer choice is: paper Rock V/s paper paper wins =>computer wins do you want to play again? N
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.