import numpy as np dice=["H","T"] n=0 for i in range(1000): x=np.random.choice(dice) if x=="H": n=n+1 p1=100*n/1000 print(p1)