[Tutor] python problem - help!!

Chris balderas at whtvcable.com
Mon Sep 24 00:18:28 CEST 2007


I need your help!

 

I have this problem that I can’t seem to figure out.  Can you help?  The
problem is listed below, and below it is my code that I have so far.

 

----------------------------------------------------------------------------
--------------------

Two hockey teams play eight times during the regular season. Team A wins
five times and Team B wins the other three times. They meet in the playoffs
in a best of seven series. Write a program that estimates the chances of
Team B winning the series. A sample run of the program might look like this:

.
Are team B's chances better in a 1 game "series", a 3 game series, a 5 game
series, or a 7 game series? What would team B's chances of winning a 51 game
series be?

 

----------------------------------------------------------------------------
-------------------

 

import random

SERIES = 1000

game = 0

series = 0

 

while series < SERIES:

    

    teamA = random.randint (1,8)

    teamB = random.randint (1,8)

    teams = teamA + teamB

 

    if random.randint(1,8) >= 5:

        'Team A' = team

    else:

        'Team B' = team

 

        game = game + 1

 

    series = series + 1

 

print 'In %2d simulated series %2d won %2d ' % (SERIES,team,game)

print 'so I estimate there is a',(game / 10.00),'% chance they will win the
series.'


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.487 / Virus Database: 269.13.25/1018 - Release Date: 9/19/2007
3:59 PM
 
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070923/1f3bbfdd/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 3680 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20070923/1f3bbfdd/attachment.gif 


More information about the Tutor mailing list