[Tutor] Rock, Paper, Scissors
wesley chun
wescpy at gmail.com
Fri Aug 11 19:42:32 CEST 2006
> This looks like a fun project to work on. From
> reading the description, I feel this would be pretty
> straight forward game to program. However, I have no
> idea how the computer would decide if it wanted a
> rock, paper, or a pair of scissors. Any hints?
christopher,
this is indeed a *great* exercise... i've been using it since i can't
remember when... i had it as an exercise in BASIC and Pascal when i
was in high school, then turned it into an exercise for my C and
Python courses. naturally it's also in Core Python.
others have said it and given code already, but this problem breaks
down into 3 discrete steps:
1. give values to R, P or S, i.e., an int, char, or some constant
2. have the user choose one via its constant
3. have the computer choose another -- you will need to randomly pick
one of the 3 constants
4. logic to determine who the "winner" is of if it is a draw
good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com
wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
More information about the Tutor
mailing list