mardi 8 décembre 2020

How to make an output 6 decimals?

Especially in this script because it's a little bit different.

import random    
from collections import Counter

mycoupon = [10, 4, 23, 15, 38, 47]

results = {k:0 for k in range(3, 4)}

for _ in range(100000):
    r = random.sample(range(1, 50), 6)
    draws = set(r)
    
    cc = Counter(mycoupon)
    dc = Counter(r)
    common = cc.keys() & dc.keys()
    counts = 0
    for cel in common:
        counts += min(cc[cel], dc[cel])

    
 
    if counts == 3:
        results[counts] += 1*100/100000

print(results)        

the output is

{3: 1.7289999999999204}

in this situation how to print out 1.7289999999999204 but only in 6 decimals?




Aucun commentaire:

Enregistrer un commentaire