# Class notes for Monday, February 13, 2006

import random

# This program tests the behavior of the random number generator

def randomtest():

    # how many trials to perform?
    trials = input("Enter number of trials: ")

    # initialize our list of digit totals
    counts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

    # generate random digits and keep track of their totals
    for i in range(trials):
        digit = random.randrange(10)
        counts[digit] = counts[digit] + 1

    print "raw counts:"
    print counts

    # print out the percentages
    for i in range(len(counts)):
        value = counts[i]
        percent = float(value) / trials * 100
        print "The percentage of %d is %.2f%%" % (i, percent)

