CSC 226

CSC 226 logo

Software Design and Implementation


A2: On python conditionals

Assignment A2 should be complete individually or in a pair.  However, if you work in a pair, you must work together the whole time, and you must describe your roles in your program's comments.

Rock-Paper-Scissors is a game which is played between two people.If you do not already know who to play, the game is described in detail at http://en.wikipedia.org/wiki/Rock-paper-scissors.

We are going to create a variant of this came called Rock-Paper-Scissors-Spock-Lizard, which was created because the authors did not like all of the ties which occur in Rock-Paper-Scissors.  This game is described in detail at http://en.wikipedia.org/wiki/Rock-paper-scissors-lizard-Spock

Basically, the user will choose one of rock, paper, scissors, spock, lizard, and the computer will choose one of these.

rock paper scissors spock lizardThe rules of rock-paper-scissors-spock-lizard are:
  • Scissors cut paper
  • Paper covers rock
  • Rock crushes lizard
  • Lizard poisons Spock
  • Spock smashes scissors
  • Scissors decapitate lizard
  • Lizard eats paper
  • Paper disproves Spock
  • Spock vaporizes rock
  • Rock crushes scissors
Create a python program in which you invite the user to play a game of rock-paper-scissors-spock-lizard.

Download  yourusername-A2-three.py. Remember that you might have to right-click to download the python file. This program contains many ideas you will need for this assignment, so run it and look carefully at the various parts of the code. Then make modifications since you will need the random library as well as the if, elif, else  structure. To make this program work correctly, you will need a bunch of elifs.  You may also want to nest your if statements, so the example shows that.
  1. Name your program yourusername-A2-rps.py.
  2. Your program should invite the user to play.
  3. Your program must repeat the choice the user made. You may assume the user will type her/his choice correctly.  Note that case matters in python, so we recommend using lower case. Also, since we are using Python 2.7.6, you must use the raw_input command to get user input.
  4. Your program must reveal the choice that the computer makes.
  5. Your program must print out who won that round (or whether it was a tie, or some other outcome...)
  6. Your program must include a large comment block at the top with your name, username, assignment number, purpose and acknowledgements.
  7. Your program must have explanatory comments in the code itself.  Usually, these are added only where code might be confusing.  When we are exploring a new construct in python, that would be a good place to add a comment.
  8. Optionally--please only do this after you finish the above, feel free to play around and add new fun parts to your program. For example, you could consider writing a second program which cheats.  If you do this, please submit both versions.  :)
  9. Upload yourusername-A2-rps.py to Moodle after correcting the filename.

Note that submitted files with incorrect filenames may not receive full credit because it makes grading more difficult for us and the TAs, so please check filenames carefully!


Copyright © 2016 | http://cs.berea.edu/courses/CSC226/ | Licensed under a Creative Commons Attribution-Share Alike 3.0 United States License