Week 0, Problem 2: Rochambeau
[30
points; individual or pair]
A rock, paper, scissors program -- that never
loses...
This second problem asks you to practice
- creating new
python files (in this case, by copying old ones)
- writing a bit of
your own code (by altering another program, if you wish)
- textual input
and output in Python
The idea is this: alter the program in hw0pr1.py so that it invites the user to play a game
of "rock-paper-scissors." What's more, the program should make sure
that it always wins the game (taunting the graders who will be running
your program is optional).
Creating a new file named hw0pr2.py
- To create a new
file named hw0pr2.py,
first make sure you have hw0pr1.py (download
it again, if necessary), and then copy-and-paste it to a new file. Rename
that file to hw0pr2.py
- Do I really have
to use that name? Actually, no --
you can use whatever name you like for the homework assignment files, but
when you submit them, you DO have to have them named as specified
in the assignment. So, it's easiest to name them as the submission site is
expecting from the very beginning.
How the program should work?
- The program
should ask the user to choose rock, paper, or scissors. Then, it should
repeat back to the user their choice, it should "reveal" its own
choice, and then report the results. The program should always win -- of
course, it will be cheating because it will know and use the opponent's
input, but we will leave a true implementation of the game to next week.
Briefly, in the game of rock-paper-scissors,
rock defeats scissors, scissors defeat paper, and paper defeats rock.
- You may assume
that the user will input one of rock, paper, or scissors. (But feel free
to catch errors and report them, if you like!)
- You may write
the dialog however you like, but here's an example dialog if you'd like
one to follow. This is two distinct runs of the program:
>>>
Choose rock, paper, or scissors: scissors
You chose scissors - I chose rock
I win!
>>>
Choose rock, paper, or scissors: paper
You chose paper - I chose scissors
I win!
>>>
Submitting your hw0pr2.py file
- Once your
program plays a flawless game of rock-paper-scissors, submit it at
Canvas.
Be sure to indicate the partner you worked with (if any).
On to "picobot"
The third and fourth problems on this assignment
emphasize a very different way of thinking about computation. They don't use
python, but a simulation called picobot. We will discuss it in the first
week of EECS 110 classes.
Next
hw0pr3
Homework0