Rock Paper Scissors Challenges

After completing the code-along, attempt the challenges below.

Optional Practice: Bug Fixes

View these buggy Repl projects and try to fix them. Test the program and make sure that all outcomes are reachable.

1. Nicer Printing

While the program should be functional after the code-along, it does not have the best user experience. Update the code to make it a little easier to read for the user.

  1. Add an empty print statement under the "Welcome" message to make a new line under it
  2. Add another empty print statement above the final input in the while block
  3. Add another empty print statement at the bottom of the while block
  4. Add print statements above and below the battle output, adding a "box" using dashes

Run the program, and make sure it is a little more usable!

BONUS: ASCII Art

ASCII art is a graphic design technique that creates images from text characters. Utilize some ASCII art to make the program more exciting!

In Python, it is possible to create multiline strings, which can make ASCII art much easier. Instead of using a single double quote ( " ) to start and end a string, use three double quotes ( """ ).

For example, this code:

value = """this is a 
multiline
string"""
print(value)

will print this:

this is a 
multiline
string

An example of art for Rock Paper Scissors can be found here: https://gist.github.com/wynand1004/b5c521ea8392e9c6bfe101b025c39abe

2. Handling Invalid Input

At the moment, the program works if the user enters "R", "P", or "S". However, if the player enters anything else, no message is displayed. Make some updates so that this is properly handled.

  1. In the battle function, find the bottom of the block
  2. At the same level as the first if, add an else: clause
  3. In the else block, print a message saying "Invalid Selection"

Run the program, and verify that invalid input sees a proper response!

BONUS: Boxify Valid Battle

As it is, the "Invalid Selection" will display in the same "box" as the battle statement. Update the code so that the "box" dashes only appear for a legitimate battle.

3. Tracking Score

This challenge is a little more difficult. One nice feature for the program would be the ability to track a player's wins across multiple games.

  1. Find the battle function definition
  2. Find each print statement where the player wins
  3. Under each of those statements, with the same indentation level, add return True
    • This True indicates that the player won the battle
  4. For each other print statement, add return False directly beneath
  5. Above the while loop, create a new variable named score
  6. Set the value of the score variable to 0
  7. Within the while loop, find the battle function call
  8. Set the result of the battle call to a new variable: won
  9. Under the battle call, create an if statement
  10. Make the if statement check if won is True
  11. In the block of the if statement, increment the value of score by 1
  12. Under the if statement (outside the indented block), create a print
  13. Make the print statement print out the score variable
    • print("Score: " + str(score))

Run the program again, and verify that the score goes up with every victory!

4. More Moves

This challenge may be quite difficult. One variation of the game adds two additional move options: Spock and Lizard. This version was invented by Sam Kass and Karen Bryla, and later popularized by the CBS sitcom The Big Bang Theory.

The outcomes are as follows:

It adds this additional logic:

  • Rock vs. Spock - L
  • Rock vs. Lizard - W
  • Paper vs. Spock - W
  • Paper vs. Lizard - L
  • Scissors vs. Spock - L
  • Scissors vs. Lizard - W

Update the program so that it can handle these additional cases.

5. Hangman, Tic Tac Toe, or Something Else

Create a completely different console game using the same programming concepts from the Rock Paper Scissors game. Add some ASCII Art to make it fun.

results matching ""

    No results matching ""