The program simulates flipping a coin 100 times using Python's random module, and counts the number of times the coin lands on heads and tails.
So, each time the program runs, it simulates flipping a coin 100 times and prints the counts for heads and tails. The output will be the number of times the coin landed on heads and tails, respectively.
import random import itertools coin = { "heads": 0, "tails": 0, } s = list(coin.keys()) for i in range(100): res = random.choice(s) coin[res] += 1 print("Heads :", coin["heads"]) print("Tails :", coin["tails"])
Heads : 62 Tails : 38
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions