soru 2

Anonymous
python
11/19/2021 5:47 PM
508 B
18
Indexable
import random
def flippingCoin(times):
    i, head, tails = 0, 0, 0

    while i < times: 
        side = random.randint(0,1) #0 means head, 1 means tails
        if(side == 0):
            head += 1
        else:
            tails += 1
        i += 1
    print('Head count: %d \nTails count: %d' % (head, tails))

flipTime = int(input("Enter flip time: "))
flippingCoin(flipTime)
Editor is loading...