> #assigning variables to track the amount of times heads or tails comes up
> heads=0
> tails=1
>
> AG> Why not make both zero, after all there have been no flips so far!
Hi Alan,
There is confusion here about the role of these variables. Despite what
the comment says, I assume that 'heads' and
Yes I am going through the Michael Dawson book. Also, I am working from
the Alan Gauld book to reinforce my attempts at learning python.
Norman
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
tutor@python.org
Subject: Re: [Tutor] new user question about while loops
As Danny says, try breaking the problem into chunks and solving
each bit separately. I'll provide a few comments on your code in
the meantime but try the "evolving soluition" approach too.
#assigning variables
Thank you for posting your code. That really helps us see where you are
and therefore how to help.
I encourage you to "desk check" your code: pretend you are the
computer: write down the values of variables and expressions as things
change. Evaluate each statement to see what it does.
Example:
he
This may not be up to the standard of the more experienced programmer
but here is my effort. An added bit is the ability to go on using the
code until you are fed up.
#To check the computers odds and evens
import random
anothergo = "y"
while(anothergo != "n"):
oddsevens = random.randrange(2
As Danny says, try breaking the problem into chunks and solving
each bit separately. I'll provide a few comments on your code in
the meantime but try the "evolving soluition" approach too.
#assigning variables to track the amount of times heads or tails comes up
heads=0
tails=1
AG> Why not make b
Hello,
I'm not so sure about your problem, but
probably this code can help
sumHead, sumTail = 0,0
listHeadTime = [] listTailTime = [] for i in range(100): time_start = time.clock() coin = random.randint(0,1) # 0 head, 1 tail time_stop = time.clock()
> > My goal, create a program that flips a coin 100 times, at the end it
> > says the number of times it flipped heads and flipped tails.
>
> Do you might if we simplify the problem slightly? Say that you're only
> flipping the coin two times. Can you write code to say how many times
> it flip
On Tue, 25 Oct 2005, Nick Eberle wrote:
> My goal, create a program that flips a coin 100 times, at the end it
> says the number of times it flipped heads and flipped tails.
Hi Nick,
Do you might if we simplify the problem slightly? Say that you're only
flipping the coin two times. Can you
10:58 PM
To: Nick Eberle; tutor@python.org
Subject: Re: [Tutor] new user question about while loops
At 10:53 PM 10/25/2005, Nick Eberle wrote:
Content-class:
urn:content-classes:message
Content-Type: multipart/alternative;
boundary="_=_NextPart_001_01C5D9F1.A836CF4F&q
> I understand the format of while loops, but is it possible to use the
> random.randrange function in them?
>
> My goal, create a program that flips a coin 100 times, at the end it
> says the number of times it flipped heads and flipped tails.
I am also trying to learn python and came across
tutor@python.orgSubject: Re: [Tutor]
new user question about while loops
At 10:53 PM 10/25/2005, Nick Eberle wrote:
Content-class:
urn:content-classes:messageContent-Type:
multipart/alternative;boundary="_=_NextPart_001_01C5D9F1.A836CF4F&quo
At 10:53 PM 10/25/2005, Nick Eberle wrote:
Content-class:
urn:content-classes:message
Content-Type: multipart/alternative;
boundary="_=_NextPart_001_01C5D9F1.A836CF4F"
Sorry for potential double post, error with first send
--
Sorry for potential double post, error with first send
--
Hello all,
I had a new question about python. I am pretty much
in tutorial learning stages, but attempting to create sample programs not in my
book to learn how to cons
14 matches
Mail list logo