Homework 7: Rock-Paper-Scissors
Objective: To play the rock-paper-scissors game.
This program should play the rock-paper-scissors game, which is where the player picks either
rock, paper, or scissors, the computer does the same, and then one of the following happen:
- Rock breaks scissors
- Paper covers rock
- Scissors cut paper
- There is a tie (both players picked the same thing)
If the user enters invalid input, your program should say so, otherwise it will output one of the above
results. You should randomly generate a number to determine the computer's move.
Here is some sample output:
[cpersiko@fog cs110a]$ python3 rps.py.txt
Please enter your move: Paper, Rock, or Scissors: Paper
Computer's move is Paper
Tie with Paper!
[cpersiko@fog cs110a]$ python3 rps.py.txt
Please enter your move: Paper, Rock, or Scissors: paper
Computer's move is Scissors
Computer Wins! Scissors cut Paper!!
[cpersiko@fog cs110a]$ python3 rps.py.txt
Please enter your move: Paper, Rock, or Scissors: scissors
Computer's move is Scissors
Tie with Scissors!
[cpersiko@fog cs110a]$ python3 rps.py.txt
Please enter your move: Paper, Rock, or Scissors: Scissor
Computer's move is Paper
You Win! Scissors Cut Paper!!
[cpersiko@fog cs110a]$ python3 rps.py.txt
Please enter your move: Paper, Rock, or Scissors: rock
Computer's move is Paper
Computer Wins! Paper Covers Rock!!
[cpersiko@fog cs110a]$ python3 rps.py.txt
Please enter your move: Paper, Rock, or Scissors: r
Computer's move is Scissors
Invalid move!!
[cpersiko@fog cs110a]$
Here are the rules:
- Your program should accept input of upper-case and/or lower-case letters. You can
use the string's .lower() function to convert it to lower case, for example:
if user_move.lower() == 'rock':
- Your program should accept "scissor" or "scissors" (with or without the s,
upper or lower case) as meaning the same thing.
- Your program should have at least 2 functions, including a main() function
(no global variables or global code other than a call to main within an if-statement)
- You should use at least one multi-way if-statement (using "elif").
- You should use at least one logical "and" or "or" in your program
- You should always output who won (unless there's a tie).
- The output should show a variety of test cases such as above.
- Every function (except main) needs to have a comment in a triple-quoted string at the beginning, briefly explaining what it does.
- As with every assignment, you must write all the code yourself. Do not copy any code other people have written. If you use any Python features we haven't covered in class then the graders will search the internet for that code, to make sure you didn't copy it from a web site.
- Make sure to put a comment at the top of your program with your name, the name of this assignment and class (110A Homework 7), and a brief description of what the program does.