0% found this document useful (0 votes)
61 views

Cs Project

This document describes a Rock Paper Scissors game project created using Python. The project allows a user to play against a computer opponent. It uses the random module to randomly generate the computer's choice and determines a winner based on the standard Rock Paper Scissors rules. The code takes input from the user, makes a random selection for the computer, and prints out the results of each round, looping until the user chooses to quit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Cs Project

This document describes a Rock Paper Scissors game project created using Python. The project allows a user to play against a computer opponent. It uses the random module to randomly generate the computer's choice and determines a winner based on the standard Rock Paper Scissors rules. The code takes input from the user, makes a random selection for the computer, and prints out the results of each round, looping until the user chooses to quit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

INVESTIGATORY PROJECT IN COMPUTER SCIENCE

ROCK PAPER SCISSOR

SUBMITTED TO:

SUBMITTED BY:

Mrs. Lydia Sumana


Varun
Kommalapati

Senior Secondary teacher 11-B(Sci.)

Computer Science Department Session: 2022-23

NATIONAL PUBLIC SCHOOL


ITPL, BENGALURU
DEPARTMENT OF COMPUTER SCIENCE
CERTIFICATE
Certified that the work in this file is the bonafide
work of _________________________________ of
Grade XI ______________
Roll Number _______________________recorded
in the school laboratory during the academic year
2022-2023.
Date: 24/1/2023
Teacher in charge: Mrs. Lydia Sumana
External --------
Examiner :
School Seal
ACKNOWLEDGEMENT
In the accomplishment of this project, many people
have provided me with heart pledged support and I
want to thank all the people who have been
concerned with this project. I would like to thank my
Physics teacher Dr. Jaya who guided me to complete
the project.
Last but not least, I would like to thank my parents
and friends for their help and suggestions.
INDEX
• Introduction
o Working Environment
o Functions and modules
■ Hardware and Software Specifications
• Source Code
o Output
• Bibliography
INTRODUCTION OF THE PROJECT

In this project, I’ve made a Rock, Paper and Scissors


game in which you can play against the computer.
Rules: You and the computer both choose rock, paper or
scissors. The winner is decided by these rules:
o Rock blunts scissors
o Paper covers rock

o Scissors cut paper


WORKING
ENVIRONMENT
I’ve used a Dell laptop with an Intel i7 processor
by connecting it to another monitor and creating
an ergonomically supporting perfect environment
and also maintaining a proper sitting posture, an
appropriate eye-monitor distance and many
other conditions.

FUNCTIONS USED:
Input()

MODULES USED:
random module
HARDWARE AND SOFTWARE
SPECIFICATIONS
Hardware specifications: Intel core i7 processor,
8GB RAM, x64 based

Software specifications: Windows 11, Pycharm


community edition.
SOURCE CODE

# import random module

import random

# Print multiline instruction

# performstring concatenation of string

print("Winning Rules of the Rock paper scissor game as follows: \n"

+ "Rock vs paper->paper wins \n"

+ "Rock vs scissor->Rock wins \n"

+ "paper vs scissor->scissor wins \n")

while True:

print("Enter choice \n 1 for Rock, \n 2 for paper, and \n 3 for scissor \n")

# take the input from user

choice = int(input("User turn: "))

# OR is the short-circuit operator

# if any one of the condition is true


# then it return True value

# looping until user enter invalid input

while choice > 3 or choice < 1:

choice = int(input("enter valid input: "))

# initialize value of choice_name variable

# corresponding to the choice value

if choice == 1:

choice_name = 'Rock'

elif choice == 2:

choice_name = 'paper'

else:

choice_name = 'scissor'

# print user choice

print("user choice is: " + choice_name)

print("\nNow its computer turn.......")

# Computer chooses randomly any number

# among 1 , 2 and 3. Using randint method


# of random module

comp_choice = random.randint(1, 3)

# looping until comp_choice value

# is equal to the choice value

while comp_choice == choice:

comp_choice = random.randint(1, 3)

# initialize value of comp_choice_name

# variable corresponding to the choice value

if comp_choice == 1:

comp_choice_name = 'Rock'

elif comp_choice == 2:

comp_choice_name = 'paper'

else:

comp_choice_name = 'scissor'

print("Computer choice is: " + comp_choice_name)

print(choice_name + " V/s " + comp_choice_name)

# we need to check of a draw


if choice == comp_choice:

print("Draw=> ", end="")

result = Draw

# condition for winning

if ((choice == 1 and comp_choice == 2) or

(choice == 2 and comp_choice == 1)):

print("paper wins => ", end="")

result = "paper"

elif ((choice == 1 and comp_choice == 3) or

(choice == 3 and comp_choice == 1)):

print("Rock wins =>", end="")

result = "Rock"

else:

print("scissor wins =>", end="")

result = "scissor"

# Printing either user or computer wins or draw

if result == Draw:

print("<== Its a tie ==>")


if result == choice_name:

print("<== User wins ==>")

else:

print("<== Computer wins ==>")

print("Do you want to play again? (Y/N)")

ans = input().lower

# if user input n or N then condition is True

if ans == 'n':

break

# after coming out of the while loop

# print thanks for playing

print("\nThanks for playing")


OUTPUT

BIBLIOGRAPHY
github.com

You might also like