けいさんかくりつ

4807 ワード

import random


class SelectBall(object):
    def __init__(self):
        self.run()

    def run(self):
        while True:
            numStr = input(" :")
            try:
                num = int(numStr)
            except ValueError as e:
                print(" ")
                continue
            else:
                break
        ball = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        for i in range(num):
            n = random.randint(1, 10)
            ball[n - 1] += 1
        for i in range(1, 11):
            print(" %d %f" % (i, ball[i - 1] * 1.0 / num))


sb = SelectBall()