[Tutor] I'm new to Python too
D Rizdek
danrieder312 at gmail.com
Sun Mar 22 08:18:21 EDT 2020
Arthur C.
I'm new to Python too and signed up to be able to post email questions, so
I get email questions. I probably deleted one of your earlier questions
and all I have is the rsp from Alan.
I copied your program and got it to work run...ie no error messages...but
it just loops continually.
How did you envision r being updated within the while loop? It is
initialized at the beginning in the r=random stmt, but not in the while
loop. I assume you want to keep checking to see when a 6 is "rolled" and
use how long it took...how many loops to calculate some sort of
probability, right? I inserted an r=random.randint(1,6) so it keeps
generating new "rolls" of a die and checks if it is a 6 each time.
Why do you think P would ever actually == .306? That is the only way it
will break out of the while loop. Maybe that is why it just keeps
looping...it is almost certain it will run for a long time before it
happens to produce exactly .306. And so what if it did?
How does the program keep track of P from one loop to the next? Wouldn't
you need to do something like that then use that to estimate some sort of
probability?
Dan
.
More information about the Tutor
mailing list