Professional Documents
Culture Documents
Computer Investigatory Project Topic: Rock Paper Scissors Game
Computer Investigatory Project Topic: Rock Paper Scissors Game
NAME : AMAANI.V
GRADE : 11
INSTITUTION : SHISHYA BEML PUBLIC
SCHOOL
1
ACKNOWLEDGEMENT
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
4
SYSTEM OBJECTIVES & AIM OF THE
PROJECT
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
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