I am creating a game with coinflips. When all 100 coins are finished flipping I would like to calculate the percentage. The code provided below however, will either display "hp" or "tp" as 100 even though its obviously not 100%.
import random
flips=100
heads=0
tails=0
while flips!=0:
coinflip=random.randint(0,1)
if coinflip==0:
heads+=1
elif coinflip==1:
tails+=1
flips-=1
print "Heads - "+str(heads)
print "Tails - "+str(tails)
print "-----------"
hp=float((tails/heads)*100)
tp=float((heads/tails)*100)
I might be the way python processes things? or maybe I'm just stupid and cant do math.