[Tutor] Sum of Scores

Tony Noyeaux tnoyeaux at msn.com
Thu Jul 26 15:49:07 CEST 2007


The projects are moving along.
 
I've created a very simplistic cricket game to learn a few things.
 
The user is asked whether to play Aggressive or Defensively.
 
Once they pick... a random is picked based on their choice,.. and various scores happen until they get out.
 
Ignore the realism at this point,.. just getting the basic mechanics working first.
 
Works fine no problem.
 
I want to be able to calculate in the program,.. the total score,.. either at each successive score,... or when they finally get out. Not sure how to do that at this point.
 
So the output would look something like this.
 
You Hit a 2, you now have scored 2 runs
You hit a 4, you now have scored 6 runs
You hit a "Out", you are dismissed for 6 runs total.
 
After i get this worked out.. will tweak the actual formulas for the randoms, maybe put in multiple outs etc,.. changeable strategy at each out etc, and high scores list towards the end.
 
First things first,... and the project at hand.
 
How do i ... post the totals... as listed above, to the working code below.
 
 
Thanks as always
 
Tony Noyeaux
 
---------------------------------------------------------------------------------
import random
score = Nonestrat = raw_input("Will you play (a)aggressive or (b)defensive?")if strat == "a": while score != "Out":  score = random.choice(["1","2","3","4","4","6","6","Out","Out","Out","Out"])   print scoreelse: while score != "Out":  score = random.choice(["1","1","2","2","3","4","6","Out"])  print "You hit a "+score
----------------------------------------------------------------------------------
_________________________________________________________________
PC Magazine’s 2007 editors’ choice for best web mail—award-winning Windows Live Hotmail.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HMWL_mini_pcmag_0707
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070726/ae8aeb9e/attachment.htm 


More information about the Tutor mailing list