You are on page 1of 16

COMPUTER INVESTIGATORY PROJECT

TOPIC : ROCK PAPER SCISSORS GAME

NAME : AMAANI.V
GRADE : 11
INSTITUTION : SHISHYA BEML PUBLIC
SCHOOL

1
ACKNOWLEDGEMENT

I would like to express my deep sense of thanks to my computer


teacher as well as principal Mrs. Tejaswini Sankeshwar who gave
me this golden opportunity to do this wonderful project on the
topic “Rock-Paper-Scissors game” which also helped me in
doing a lot of Research work and I came across so many new
things, I am really thankful to them.
Secondly, I would like to extend my heartful gratitude to parents
and friends who helped me a lot in finalizing this project within
the limited time frame!

2
CONTENTS

INTRODUCTION………………………………………………………………………………….1
SYSTEM OBJECTIVES & AIM OF THE PROJECT……………………………..2-4
LIBRARIES USED………………………………………………………………………………5
SOURCE CODE………………………………………………………………………………6-9
OUTPUT SCREENS……………………………………………………………………….10-11

3
INTRODUCTION

Rock paper scissors game is also known as stone paper


scissors. It is a hand game that is usually played between 2
people, each player can randomly form any one of three from
their hand.
A player who chooses rock will win by another player who
chooses scissors but lose by the player who chooses paper; a
player with paper will lose by the player with the scissors.
If both players choose the same then the game is tied. Rock
paper scissors game is mainly played among kids.
The purpose of the project is to create a simple command line
Rock-Paper-Scissor game using random, os, re modules and the
basic concept of python that can be played with the computer.

4
SYSTEM OBJECTIVES & AIM OF THE
PROJECT

The object of the rock-paper-scissor python project is to build a


game for a single player that plays with a computer, anywhere,
and anytime. This project is based on the rules that:
#Rock blunts scissors so rock wins
#Scissors cut the paper so scissors win
#Paper cover rock so paper wins

This project is build using random, os, re modules and the basic
concept of python.
In this python project, players have to choose any one from rock,
paper, and scissors. Then it will show the result of the game.
The core idea behind the game is that no one strategy can win
every time. Regardless of which “attack” you pick, you can either
win or lose (or tie in the case of both players picking the same
attack). Many game designs follow this pattern. This keeps
specific strategy which will win every time. It encourages
players to play dynamically.

5
PROJECT MODULES:
To implement this python rock paper scissors project we will use
the basic concept of python with random, os and re module.
» random module use to generate random numbers.
» os module in python provides functions for interacting with
the operating system. OS, comes under Python's standard
utility modules. This module provides a portable way of using
operating system dependent functionality. The *os* and *os.
path* modules include many functions to interact with the file
system.
» re module or regular expression is a special sequence of
characters that helps you match or find other strings or sets of
strings, using a specialized syntax held in a pattern. ...
The Python module re provides full support for Perl-like regular
expressions in Python. The re module raises the exception re.
To install the libraries, we can use the pip installer command on
the command prompt.
» Import required libraries: The first step is to import libraries.
Here, we required three modules so we need to import random,
os and re modules.
» Code for user choice: This code will let the user input their
choice of weapon, i.e., rock(r/R), paper(p/P) or scissor(s/S).

6
» Code for computer choice: This code will produce a random
weapon from the computer’s side. This will determine whether
we won or lost.

» Define functions: Functions like if, else, elif, while, etc are used.

SOFTWARE USED:
IDLE (Python 3.8 32-bit)
IDE – Spyder for project development

7
LIBRARIES USED

1. Random: This library helps us to generate random numbers


in Python by using random module. Python offers random
module that can generate random numbers. These are
pseudo-random number as the sequence of number
generated depends on the seed. If the seeding value is
same, the sequence will be the same.
2. os: This library contains OS module in python which
provides functions for interacting with the operating
system. OS, comes under Python's standard utility modules.
This module provides a portable way of using operating
system dependent functionality. The *os* and *os. path*
modules include many functions to interact with the file
system.
3. re: This library contains regular expression (or RE) which
specifies a set of strings that matches it; the functions in
this module let you check if a particular string matches a
given regular expression (or if a given regular
expression matches a particular string, which comes
down to the same thing).

8
SOURCE
CODE
9
10
""" Rock Paper Scissors
----------------------------------------
"""
import random
import os
import re
os.system('cls' if os.name=='nt' else 'clear')
while (1 < 2):
print ("\n")
print ("Rock, Paper, Scissors - Shoot!")
userChoice = input("Choose your weapon [R]ock], [P]aper, or
[S]cissors: ")
if not re.match("[SsRrPp]", userChoice):
print ("Please choose a letter:")
print ("[R]ock, [S]cissors or [P]aper.")
continue
# Echo the user's choice
print ("You chose: " + userChoice)
choices = ['R', 'P', 'S']

11
opponenetChoice = random.choice(choices)
print ("I chose: " + opponenetChoice)
if opponenetChoice == str.upper(userChoice):
print ("Tie! ")
#if opponenetChoice == str("R") and str.upper(userChoice)
== "P"
elif opponenetChoice == 'R' and userChoice.upper() == 'S':
print ("Scissors beats rock, I win! ")
continue
elif opponenetChoice == 'S' and userChoice.upper() == 'P':
print ("Scissors beats paper! I win! ")
continue
elif opponenetChoice == 'P' and userChoice.upper() == 'R':
print ("Paper beat rock, I win! ")
continue
else:
print ("You win!")

12
OUTPUT
SCREENS

13
14
BIBLIOGRAPHY
1. COMPUTER SCIENCE text book
By: SUMITA ARORA

2. data-flair.training

15
THANK YOU !

16

You might also like