Okay, just to let you know, I am a certified noob, so I'm not really sure what to do. Here's what I"m supposed to do. Write a function three_heads that stimulates flipping a coin repeatedly printing what is seen (H for heads, T for tails). When 3 heads are flipped in a row, a message is printed. Here is a sample output:
T
H
T
H
H
H
Three Heads in a row!
This isn't homework, but a review question that we didn't go over in class. Just want to satisfy my curious mind. Any possible answers? Thanks.
I'm thinking that it should be like:
But now I'm stuck. Any ideas? Not asking for solution, just help/hints.
T
H
T
H
H
H
Three Heads in a row!
This isn't homework, but a review question that we didn't go over in class. Just want to satisfy my curious mind. Any possible answers? Thanks.
I'm thinking that it should be like:
Code:
# random chooses Heads or tails
from random import*
def three_heads():
while(True):
possiblity=ranint(1,2)
if (possibilty==1):
print ("H")
elif (possibility==2):
print ("T")
But now I'm stuck. Any ideas? Not asking for solution, just help/hints.
Comment