Question

EI E 237 Assignment 4: Python Program Due September 18, 2018 Description For this assignment, you will practice several basic Python programming skillis by writing a simple Python 3 program. This program will implement a text-based, 2-player rock-paper-scissors game (if you are unfamiliar with rock-paper-scissors, check out the Wikipedia article The program should give some brief instructions to the players. Next, it should prompt player for a choice, then prompt player 2 for a choice. If a player inputs something that isnt atn available choice, the program should not accept it and prompt the player to make another choice. It should repeat this process until one player has won 3 times. It should then congratulate the winning player on their victory and list each play they made throughout game, in order. This program will naturally require several fundamental programming con to be used. I will check for several specific concept s, listed in the next section cepts There is no minimum or maximum code length requirement for this project Please try to be concise, but also make sure the program does everything it needs to do. Also, please be sure to test your program with various scenarios to make sure each part of the description above is satisfied This is an individual assignment. That is, each person should turn in a separate program Concepts Your program must include at least one instance of the following Python features. Each feature should be used in such a way that it is essential to the program. That is, if it were to be removed, the program would not work correctly . The print function . The input function Python lists . An if conditional . A while loop A for loop What to turn in For this assignment, please submit your Python (py) file.If Blackboard will not let you submit the file directly, please submit it within a zip file. The rubric is on the following page
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Implemented the code as per the requirement. As python is tab specific, you may not get the formatted text while copying the code,
so I'm attaching the screenshots of the code for reference. Please make sure when you are executing the below code you have same format, especially tabs.

Please comment if any modification required.

Code:

====

print("Welcome to Rock-Paper-Scissors game!!!")
print("Instructions\nEach player should enter a choices from r,p and s where r for rock, p for paper and s for scissors.")
print("Other than these choices will lead for another prompt for the input")
print("Winning combinations: r & p - rock wins, p & s - s wins, r & s - s wiins")
print("Let's start the game..")

counter1 = 0
counter2 = 0
player1_game=[]
player2_game=[]
while(1):
inp1 = ' '
inp2 = ' '
while(1):
inp1 = input("\nPlayer1, Enter an input: ").rstrip()
if(inp1!='r' and inp1!='s' and inp1!='p'):
print("Invalid input. Please try again..")
continue
player1_game.append(inp1)
break
while(1):
inp2 = input("\nPlayer2, Enter an input: ").rstrip()
if(inp2!='r' and inp2!='s' and inp2!='p'):
print("Invalid input. Please try again..")
continue
player2_game.append(inp2)
break
if(inp1==inp2):
print("Inputs should be different")
continue
  
if(inp1=='r'):
if(inp2=='s'):
counter1+=1
else:
counter2+=1
elif(inp1=='s'):
if(inp2=='r'):
counter2+=1
else:
counter1+=1
elif(inp1=='p'):
if(inp2=='r'):
counter1+=1
else:
counter2+=1
  
if(counter1==3):
print("Player1 won the game")
break
elif(counter2==3):
print("Player2 won the game")
break
  
print("\nGame entries..")
for i in range(len(player1_game)):
print(player1_game[i]+" "+player2_game[i])

Code screenshots:

==============

1 print(Welcome to Rock-Paper-Scissors game!!!) 2 print(Instructions InEach player should enter a choices from r,p and s where r for rock, p for paper and s for scissors.) 3 print(Other than these choices will lead for another prompt for the input) 4 print(Winning combinations: r& p - rock wins, p & s- s wins, r & s -s wiins) 5 print(Lets start the game..) 6 7 counter! 8 counter2 9 player1_game-[] 10 player2 game-] 11 while(1): 12 13 14 15 16 17 18 19 20 inp2 while(1): inp1 - input(InPlayer1, Enter an input: ).rstrip() if (inp1!-r and inp1!-s and inp1!-p) print(Invalid input. Please try again..) continue player1_game.append (inp1) break while(1): inp2 input(InPlayer2, Enter an input: ).rstrip() if (inp2!-r and inp2!-s and inp2!-p) 23 print(Invalid input. Please try again..) continue 25 26 27 player2_game.append (inp2) break if(inp1--inp2) 29 print(Inputs should be different)

Output:

=======

Add a comment
Know the answer?
Add Answer to:
EI E 237 Assignment 4: Python Program Due September 18, 2018 Description For this assignment, you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember...

    Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember the rules: 1. Rock beats scissors 2. Scissors beats paper 3. Paper beats rock The program should ask the users for their names, then ask them for their picks (rock, paper or scissors). After that, the program should print the winner's name. Note, the players may pick the same thing, in this case the program should say it's tie. when the user input an...

  • IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors...

    IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....

  • (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against...

    (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. The...

  • Write a program in python that lets the user play the game Rock, Paper, Scissors against...

    Write a program in python that lets the user play the game Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...

  • Using python 3.7.3 Challenge: Rock, Paper, Scissors GamePDF Description: Create a menu-driven rock, paper, scissors game...

    Using python 3.7.3 Challenge: Rock, Paper, Scissors GamePDF Description: Create a menu-driven rock, paper, scissors game in Python 3 that a user plays against the computer with the ability to save and load a game and its associated play statistics. Purpose: The purpose of this challenge is to assess the developer’s ability to create an interactive application with data persistence in Python 3. Requirements: Create a Rock, Paper, Scissors game in Python named rps.py according to the requirements specified in...

  • In python language Write a program that lets the user play the game of Rock, Paper,...

    In python language Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: 1. When the program begins, a random number in the range of 1 and 3 is generated. 1 = Computer has chosen Rock 2 = Computer has chosen Paper 3 = Computer has chosen Scissors (Dont display the computer's choice yet) 2. The user enters his or her choice of “Rock”, “Paper", “Scissors" at...

  • Python please. I have a working one that doesn't keep track of w/l ratio, it may...

    Python please. I have a working one that doesn't keep track of w/l ratio, it may be helpful to see how others did the entire program and inserted that module. Write a modular program that let the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 thru 3 is generated but do not display the computer choice immediately. Number 1...

  • For this week’s assignment, we will be recreating the Rock, Paper, Scissors program using Object-...

    For this week’s assignment, we will be recreating the Rock, Paper, Scissors program using Object-Oriented Programming. You will be working with me on a team to build the program. I have already written my part of the program, and the Game.java file is attached. Your task will be to write a RockPaperScissors class that contains the following methods: getUserChoice: Has the user choose Rock, Paper, or Scissors. After validating the input, the method returns a String containing the user choice....

  • (c++ only)Write a program that lets the user play the game of Rock, Paper, Scissors against...

    (c++ only)Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, the user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard using a menu in a function, userChoice, that returns a character. Next, there should be a function, computerChoice, that generates the computer’s play. A random number in the range of 1 through 3 is generated. If the...

  • In JAVA Chapter 5Assignment(Rock, Paper, Scissors)–20pointsYour goal is towrite a program that lets the user play...

    In JAVA Chapter 5Assignment(Rock, Paper, Scissors)–20pointsYour goal is towrite a program that lets the user play the game of Rock, Paper, Scissors against the computer.Your program should have the following: •Make the name of the project RockPaperScissors•Write a method that generates a random number in the range of 1 through 3. The randomly generated number will determine if the computer chooses rock, paper, or scissors. If the number is 1, then the computer has chosen rock. If the number is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT