Homework #1: Python

Due: Friday, January 27, 2006

You are to write a Python program that simulates the rolling of two six-sided dice 1,000 times. Your program should output the results of your simulation both textually and as a histogram of percentages for each possible roll. You may orient the histogram either horizontally or vertically.

When you design your solution, split the work of the simulation using function definitions (def). For now, you can use one file to hold all of your function definitions. For example:

# File: diceSimulation.py 
# Author: Tom Jones 
# Description: .... 

import random 

# myFunction1 performs ... 
def myFunction1(x): 
     roll = random.randint(1,6) 
     . . . 

# myFunction2 does ... 
def myFunction2(): 
     ... 

# main acts as ... 
def main(numberOfRolls): 
     ... 

main(1000) 



You are to hand in: