Question
PLEASE USE PYTHON AS A PROGRAMMING LANGUAGE. PLEASE USE SIMPLE COMMAND AS MUCH AS POSSBILE. In this exercise, you are going to practice using conditionals
PLEASE USE PYTHON AS A PROGRAMMING LANGUAGE. PLEASE USE SIMPLE COMMAND AS MUCH AS POSSBILE.
In this exercise, you are going to practice using conditionals (if, elif, else). You will write a small program that will determine the result of a rock, paper, scissors game, given Player 1 and Player 2s choices. Your program will printout the result. Here are the rules of the game:
1. First create a truth table for all the possible choices for player 1 and 2, and the outcome of the game. This will help you figure out how to code the game!
2.Create a new file rps.py that will generate the outcome of the rock, scissors, paper game. The program should ask the user for input and display the answer as follows:
Player 1? rock
Player 2? scissors
Player 1 wins.
The only valid inputs are rock, paper, and scissors. If the user enters anything else, your program should output This is not a valid object selection. Use the truth table you created to help with creating the conditions for your if statement(s). Read on to the next page before starting... Paper beats rock Scissors beats paper Rock beats scissors
Note If you have a long condition in your if statement, and you want to split it into multiple lines, you can either enclose the entire expression in parenthesis,
e.g. if (player1 == rock and player2 == scissors): print (Player 1 wins.)
Or, you can use the backslash symbol to indicate to Python that the next line is still part of the previous line of code,
e.g. if player1 == rock and \ player2 == scissors:
print (Player 1 wins.)
Please reference below example to solve the exercise.
name = input("What is your name? ")
city = input("What city do you live in? ")
state = input("What state is that in? ")
print ("Hello there! It is so great to meet you,")
# One way to do this is to print strings on separate lines
print (name)print ("from")print (city)print (state)
# We can also "glue together" pieces of a string by adding commas#
between them.
print (name, "from", city, state)
age = int(input("Pardon my rudeness, but how old are you? "))
# Notice that we can "glue together" two strings and one integer into
# one giant string.
print ("Wow! You look like you could be", int(age - (0.15*age)), "!!")
# int(argument) forces the argument to be an integer by rounding down.
# So, int(5.1) = 5 and int(5.9) = 5
Paper beats rock Scissors beats paper Rock beats scissors Player1 Rock Rock Player 2 Rock Scissors Result Tie Player 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started