CS303E Assignment 7

Due: Monday, July 8 by 11 pm

File Name: rps.py  (Program name must match this exactly, including case of letters.)

Submit to Assignment 7 on Gradescope via Canvas

Purpose: To practice using variables, creating expressions,  conditional logic, loops, and user defined functions.

Limitations: You may only use the Python syntax and language features covered in the book chapters 1 - 5. Specifically you may not use lists or dictionaries. Import the random module. Use the seed(int) and randint(int, int) functions as necessary.

Starter file: rps.py (Download and alter this file to complete the program.)

Review the assignment guidelines.

Write a program that allows a player to play the game Rock - Paper - Scissors against a computer opponent.

Create programmer defined functions to remove redundancy and provide structure.  No function, including main itself, shall be more than 25 lines long NOT including the docstring at the start of the function or the blank lines before and after the function. Comments also do NOT count towards the lines of code limit.

I strongly recommend using the given rps.py file. It defines functions for you use. You must implement those functions and determine how to use them to complete the program. You are free to design and implement the program and functions yourself, but if you struggled with assignment 6 I recommend using the given design. You may, but are not required to add additional or alternative functions.

The suggested solution is a total of 122 lines including the header comment, function comments, and blank lines. It has a total of 6 functions including the main function. No function is more than 25 lines of code and all but 1 are less than 15 lines of code. This information is provided as reference.

Do not use global variables. You are limited to using local variable and parameters.

If the user sets the seed, your output shall match the given output exactly given the same initial seed. Be sure to make the user input for the seed an int.

Use the call random.randint(1, 3) to get the computer choice for each round and treat 1 as Rock, 2 as Paper, and 3 as Scissors.

The game Rock, Paper, Scissors is simple. There are two players. Each player secretly (or at the same time) chooses Rock, Paper, or Scissors.

The nine possible outcomes are

Computer Choice Human Choice Result
Rock Rock Draw
Rock Paper Human Wins
Rock Scissors Computer Wins
Paper Rock Computer Wins
Paper Paper Draw
Paper Scissors Human Wins
Scissors Rock Human Wins
Scissors Paper Computer Wins
Scissors Scissors Draw

Here is a file with multiple runs of the program. Given the same inputs and the same seed your output shall match this exactly. Note the output with "--- INITIAL INPUT ---" and "--- Round <Number> ---" are part of the required output.

 I strongly recommend you check your output and the expected output with a diff program such as https://www.diffchecker.com/.

Recall, you must  fill out the header for the assignment at the top of the program. Replace any items in <> with the proper information and  delete the <>.