Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
22 views
Computer Application
Computer technology
Uploaded by
pavi2004g
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Computer application For Later
Download
Save
Save Computer application For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
22 views
Computer Application
Computer technology
Uploaded by
pavi2004g
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Computer application For Later
Carousel Previous
Carousel Next
Save
Save Computer application For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
BEASANT TECHNOLOGIES A Project reportes On “ROCK PAPER SCISSORS” For the course PYTHON PROGRAMMIN NG LANGUAGE 2 ssn y - PAVITHRA G SUBMITTED TO COORDINATOR GOWTHAMI INBA @ scanned with OKEN ScannerCONCEPT OF ROCK paper scissior Python program to implement Rock Paper Scissors game python is a multipurpose language any one can do anything with it python can also be used for game development.let's create a simple command-line Rock-paper-scissior game without using any external game, user gets the first chance pick the option between Rock,Paper,and Scissors.After the computer select from the remaining two choices(randomly),the 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 BASIC ROCK PAPER SCISSORS PYTHON PROGRAM To understand the program below, you should have a basic idea About the following python concepts: > Python Random module > python loops Play a single game of rock paper scissors in python Using the description and rules above,you can make a game of Rock paper scissors. before you dive in you're going to need to import The module you ‘Il use to simulate the computer's choices: Import random Awesome! Now you're able to use the different tools inside random To randomize the computer's actions in the game. Now what? Since You need to be able to choose their action . @ scanned with OKEN ScannerSOURCE CODE: Ty 3 x te Yor totems oe Bee auael £/ M4) ZIG 8 Pik 6/9 9\clm| 2l@ 1 Fore. and 2 print(*\relcone to Rock, Paper, Scissors!") 3 player-eine = 2 gahite Troet, + Po ptayer = inevecrintnter » choice (rock, paper, sctasors)! ") + | Gholees = Cerock"y spupersy sactsors"] + | Soputer = candonchoice(chosces) + | prinecf"\nvou chose (player), computer chose (comuter)") Bf af player = computers 2 princ(foBoth players selected (player). Te 4s a tie!*) Bb elit player = reece 1 conuter = "aeissorst . print("Rock aneshes scissors. You wit") * player wtnert " eset prine(*Paper covers rock, You lose.) Bh ati player i 4 contr 2 print("Paper covers rock. You win") i Player wine IM tset te prine("Setssors cut t Computer xine = rine(scieere cate papers You win") a player wiaecl m eset Print(“Rock anashes scissors. You Lose") fe emptor ie ss | prinecs\nvou have *este(ptayerwins)+* wins") se | prinetthe conuter has "+str(computer wins) wins a8 input("\nPlay again? (yes/no): ") 3 ower) ie prine(*Thank ls Break letras cats 1/8 tal Sd n= Cee = LED Une CRE HS 5 Penton @ scanned with OKEN ScannerDESCRIPTION CODE: Step 1: Open a text editor Step 2: Use the import statement import random The import statement loads module contents for later access and use. When an import statement is executed, the standard built-in _import_( function is called. The random module is a built-in module to generate random variables. We are going to use it to make computer choose a random value among rock, paper, and scissors each game we play. Step 3: Print introduction line print("Welcome to Rock, Paper, Scissors! \n") Make sure to use double quotes because strings must be enclosed in double quotes for the data to be recognized as a string, not a number or variable name. A backslash n (\n) is called a new line and used inside the print statement to create a new line as its name indicates. Step 4: Set win counters player_wins =0 computer_wins = 0 Assign a value of 0 to win counter variables. Step 5: Use While statement while True: player = input("Enter a choice (rock, paper, scissors): ") choices = ["rock", "paper", "scissors"] @ scanned with OKEN Scannercomputer = random.choice(choices) print(f"\nYou chose {player}, computer chose {computer}.") While True means loop forever. In other words, the while loop will run as long as the While condition is True. You can force the loop to end by using the break statement. Create an input variable where players can enter a value among rock, paper, scissors. Create a list containing the rock, paper, scissors values with brackets. We will call the list “choices”. Then, we are going to use the random module here. Create a random.choice variable. The choice() function here is used to randomly select an item from a list. Print the game status information .The fwith curly braces is called f-string,and it lets you include The value python expression inside a string. Step 6: Use if statement If player==computer: Print(“both players selected{player}.it is a tie!”) Elif player=="rock”: If computer =="scissiors”: Print(“Rock smashes scissord.You win!”) Player_wins+1 Else: Print(“paper covers rock.you lose.”) Computer_wins+=1 @ scanned with OKEN Scannerprint("Paper covers rock. You win!") player_wins+=1 else: print("Scissors cuts paper. You lose.") computer_wins+=1 elif player == "scissors": if computer == "paper": print("Scissors cuts paper. You win!") player_wins+=1 else: print("Rock smashes scissors. You lose.") computer_wins+=1 Note that an if block can go under another if block. Step 7: Print the win counters print("You have "+str(player_wins)+" wins") print("The computer has "+str(computer_wins)+" wins") The str() function converts the specified value into a string. Instead of the str() function, you can use f-strings as follows: print(f"You have {player_wins} wins") print(f"The computer has {computer_wins} wins") @ scanned with OKEN ScannerStep 8: Ask to quit or play again repeat = input(""\nPlay again? (yes/no): ") if repeat.lower() != "yes": print("Thanks for playing!") break Create a repeat variable where players can enter a value between yes or no. The lower() method returns the lowercase string from the given string. The exclamation mark with an equal sign (!=) is called not equal to operator. If players enter any value other than yes, the while statement stops operating because of the following break statement. The break statement terminates the current loop. It can be used in both while and for loops. Congratulations! You've just built a rock-paper-scissors game in Python. Below is the entire code: Below is the entire code: import random print("Welcome to Rock, Paper, Scissors!\n") player_wins =0 computer_wins=0 while True: player=input(“Enter a choice(rock,paper,scissors):”) choices=[“rock”,”paper”,”scissors”] computer=random.choice(choices) @ scanned with OKEN Scannerprint(“f’\nYou choose{player},computer choose{computer}.”) if player == computer: print(f"Both players selected {player}. It is a tie!") © if player == "rock": if computer == "scissors": rint("Rock smashes scissors. You win!") p player_wins+=1 else: p rint("Paper covers rock. You lose.") computer_wins+=1 e if player if computer == rint("Paper covers rock. You win!") p player_wins+=1 else: p rint("Scissors cuts paper. You lose.") computer_wins+=1 © if player == "scissors": if computer == "paper": print("Scissors cuts paper. You win!") player_wins+=1 else: @ scanned with OKEN Scannerprint("Rock smashes scissors. You lose.") computer_wins+=1 print("You have "+str(player_wins)+" wins") print('The computer has "+str(computer_wins)+" wins") repeat = input("\nPlay again? (yes/no): ") if repeat.lower() != "yes": print ("Thanks for playing!") Break @ scanned with OKEN ScannerOUTPUT: Scanned with OKEN ScannerCONCLUSION: We have learned what a rock, paper and scissors game is and the rules to play this game. We also learnt how to create a simple rock paper scissor game in Python. While this game in python may seem basic, it’s a great starting point for learning programming concepts like conditional statements, functions, and modules. As you become more comfortable with Python, you can add more features to the game, such as keeping score, allowing inputs from the users that are not case sensitive and allowing the user to play multiple rounds. With a little creativity, you can create a fun and engaging game that people will enjoy playing.Coding for kids has many beneficial advantages that clevelop cognitive abilities, enhance communication and entrepreneurship skills, and stimulate creativity. Kids can learn how to create different games using @ scanned with OKEN Scanner
You might also like
Python Game Design - Rock Paper Scissors
PDF
No ratings yet
Python Game Design - Rock Paper Scissors
7 pages
Python Game Design - Rock Paper Scissors
PDF
No ratings yet
Python Game Design - Rock Paper Scissors
7 pages
Python project
PDF
No ratings yet
Python project
4 pages
pyp
PDF
No ratings yet
pyp
6 pages
Rock Paper Scissor Game in Python
PDF
No ratings yet
Rock Paper Scissor Game in Python
12 pages
Computer Project
PDF
No ratings yet
Computer Project
16 pages
Rock_Paper_Scissors_Game_Presentation
PDF
No ratings yet
Rock_Paper_Scissors_Game_Presentation
9 pages
The.boys(Ccs)
PDF
No ratings yet
The.boys(Ccs)
11 pages
Python Project
PDF
No ratings yet
Python Project
9 pages
COMPUTER SCIENCE PROJECT
PDF
No ratings yet
COMPUTER SCIENCE PROJECT
5 pages
PDF python
PDF
No ratings yet
PDF python
2 pages
Your First Python Game - Rock, Paper, Scissors - Python - The Hello World Program PDF
PDF
No ratings yet
Your First Python Game - Rock, Paper, Scissors - Python - The Hello World Program PDF
3 pages
Mathematical Game
PDF
No ratings yet
Mathematical Game
4 pages
Rock_Paper_Scissors_Mini_Project_Report_With_Flowchart (1)
PDF
No ratings yet
Rock_Paper_Scissors_Mini_Project_Report_With_Flowchart (1)
5 pages
Computer Investigatory Project
PDF
No ratings yet
Computer Investigatory Project
16 pages
Devesh Uniyal
PDF
No ratings yet
Devesh Uniyal
7 pages
Cs Project
PDF
No ratings yet
Cs Project
15 pages
MiniProject (1)
PDF
No ratings yet
MiniProject (1)
18 pages
Rock-1
PDF
No ratings yet
Rock-1
9 pages
SRTHK
PDF
No ratings yet
SRTHK
3 pages
Cs Project
PDF
No ratings yet
Cs Project
13 pages
Rock Paper Scissors
PDF
No ratings yet
Rock Paper Scissors
7 pages
Rock Paper Scissor Python Code
PDF
No ratings yet
Rock Paper Scissor Python Code
2 pages
Rock, Paper, Scissors
PDF
No ratings yet
Rock, Paper, Scissors
9 pages
Jogos Python (Inglês)
PDF
No ratings yet
Jogos Python (Inglês)
6 pages
Priyanka Ai
PDF
No ratings yet
Priyanka Ai
16 pages
Awiten_PIT 2-Game-Scissor, Rock, Paper Activity_IT1R3
PDF
No ratings yet
Awiten_PIT 2-Game-Scissor, Rock, Paper Activity_IT1R3
4 pages
Rock Scissor Paper code
PDF
No ratings yet
Rock Scissor Paper code
1 page
Imran RPS
PDF
No ratings yet
Imran RPS
1 page
PYTHON MICRO
PDF
No ratings yet
PYTHON MICRO
10 pages
Rock Paper Scissors Program
PDF
No ratings yet
Rock Paper Scissors Program
2 pages
Python Programming
PDF
No ratings yet
Python Programming
15 pages
Class 11 CS Project
PDF
No ratings yet
Class 11 CS Project
14 pages
ROCK PAPER
PDF
No ratings yet
ROCK PAPER
12 pages
Python
PDF
No ratings yet
Python
2 pages
Mini Project
PDF
No ratings yet
Mini Project
3 pages
Name: Arjun Singh Enrolment No.: A12405218004 Class: 5CSE13X
PDF
No ratings yet
Name: Arjun Singh Enrolment No.: A12405218004 Class: 5CSE13X
3 pages
From Random Import Randint
PDF
No ratings yet
From Random Import Randint
2 pages
Piedra, Papel, Tijeras _ Proyectos Raspberry Pi
PDF
No ratings yet
Piedra, Papel, Tijeras _ Proyectos Raspberry Pi
10 pages
Assign2 (T&T)
PDF
No ratings yet
Assign2 (T&T)
8 pages
Rock, Paper, Scissors-2
PDF
No ratings yet
Rock, Paper, Scissors-2
1 page
rock paper scissor
PDF
No ratings yet
rock paper scissor
2 pages
Rock, Paper and Scissor Report
PDF
100% (2)
Rock, Paper and Scissor Report
9 pages
python rock, paper, scissor code
PDF
No ratings yet
python rock, paper, scissor code
2 pages
Rock, Paper and Scissors Using Python and Tkinter Module: Bachelor of Technology IN Computer Science and Engineering
PDF
No ratings yet
Rock, Paper and Scissors Using Python and Tkinter Module: Bachelor of Technology IN Computer Science and Engineering
13 pages
STONE
PDF
No ratings yet
STONE
5 pages
Mini Projects
PDF
No ratings yet
Mini Projects
19 pages
Python Game Rspls
PDF
No ratings yet
Python Game Rspls
10 pages
Python Examples
PDF
No ratings yet
Python Examples
7 pages
Document (2)
PDF
No ratings yet
Document (2)
8 pages
Rock Paper Sccissor Game
PDF
No ratings yet
Rock Paper Sccissor Game
6 pages
MINI PROJECT (Stone, Paper, Scissor)
PDF
No ratings yet
MINI PROJECT (Stone, Paper, Scissor)
7 pages
CS106A - Springresh
PDF
No ratings yet
CS106A - Springresh
1 page
Python-2 Unit-6 Random
PDF
No ratings yet
Python-2 Unit-6 Random
14 pages
Computer Science Project
PDF
No ratings yet
Computer Science Project
11 pages
Project Report (1)
PDF
No ratings yet
Project Report (1)
13 pages
Synopsis of Rock
PDF
No ratings yet
Synopsis of Rock
3 pages
Rock, Paper & Scissor: Presented By:-Sneha Tripathi Shivani Srivastava Saksham Jaiswal
PDF
No ratings yet
Rock, Paper & Scissor: Presented By:-Sneha Tripathi Shivani Srivastava Saksham Jaiswal
14 pages