Re: Newbie: Help Figger Out My Problem

2005-06-29 Thread bruno modulix
[EMAIL PROTECTED] wrote: > Thanks to all who replied. I did not ask for other iterations of my > program. I asked what was wrong with it. Please understand that usenet is not a commercial support service. Everyone is free to answer how he likes. Or not to answer at all... -- bruno desthuilliers

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread ChuckDubya
Thanks to all who replied. I did not ask for other iterations of my program. I asked what was wrong with it. To those who did just that, explained what was wrong, thank you for answering my question. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread Casey Hawthorne
It may be shorter but it keeps the entire list in memory and has to iterate over the list twice! Does he/she need the entire list? import random heads = 0 flips = 100 for i in xrange(flips): if random.randint(0,1): heads += 1 print "Heads:%s" % heads print "Tails:%s" % (flips - heads) "D

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread Devan L
import random flips = 100 results = [random.randint(0,1) for i in range(flips)] heads = results.count(0) tails = results.count(1) print "Heads:%s" % heads print "Tails:%s" % tails I think this is more compact. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread Scott David Daniels
db wrote: > On Tue, 28 Jun 2005 00:23:30 -0700, ChuckDubya wrote: >>... if flips >= 99: >>print "Heads: " + heads >>print "Tails: " + tails >>print "Total: " + flips + "flips" >>raw_input("Press the enter key to exit.")... > > Your programm gives an error. You are trying to

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread bruno modulix
[EMAIL PROTECTED] wrote: > ##Coin Flip: randomly flips 100 "coins" and prints results > ##Original draft: june 27, 2005 > ##Chuck > > import random > heads = 0 > tails = 0 > flips = 0 > while flips < 99: > coin = random.randrange(0, 2) > if coin == 0: > heads = heads +

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread qwweeeit
Hi, About the error, you already got the answer from the "experts". Beeing almost a newbie, I tried instead an elaboration of your example, using lists. Furthermore I timed the two methods and to my surprise the "list method" takes longer: # Head_Tail.py import random, time nStart= time.time() #

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread db
On Tue, 28 Jun 2005 00:23:30 -0700, ChuckDubya wrote: > ##Coin Flip: randomly flips 100 "coins" and prints results > ##Original draft: june 27, 2005 > ##Chuck > > import random > heads = 0 > tails = 0 > flips = 0 > while flips < 99: > coin = random.randrange(0, 2) > if coin == 0:

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread Paul Rubin
[EMAIL PROTECTED] writes: > When I save and run this "program", I get a DOS window that flashes at > me and disappears. What's wrong with it? You can't just click the file.py icon and expect a program like that to do something reasonable. There are two ways to deal with it: 1) start a DOS box a

Newbie: Help Figger Out My Problem

2005-06-28 Thread ChuckDubya
##Coin Flip: randomly flips 100 "coins" and prints results ##Original draft: june 27, 2005 ##Chuck import random heads = 0 tails = 0 flips = 0 while flips < 99: coin = random.randrange(0, 2) if coin == 0: heads = heads + 1 else: tails = tails + 1