Python Programming - Summer 2013 - Nathan Hull

Assignment #3 - Due: Friday, July 19th

1.) Doubles!!

In games with two dice (such as Monopoly), rolling two 6-sided dice and getting the same side or number on both dice is called doubles. Write a program which first prompts the user for the number of sides to the dice (as "regular" dice have 6 sides, but D&D dice could have 10, 12, or 30 sides etc). Then you program should keep "rolling the dice" until it gets three sets of doubles. The program should tell the user how many "rolls" were required to get three sets of doubles with this pair of "dice"!

Sample input:

How many sides on your dice? 6? 10? 12? 30? 6

Sample output:

1. die number 1 is 5 and die number 2 is 3.
2. die number 1 is 2 and die number 2 is 4.
3. die number 1 is 1 and die number 2 is 1.
4. die number 1 is 3 and die number 2 is 3.
  You got a double (3).

. . .

Three sets of doubles! Finally! On try number 31!

This program should be named as follows: (for example,

2.) Factorials

Factorials are used in many applications in mathematics as the result grows very quickly. So while 5! = 120, 10! = 3,628,800. Factorials are used to calculate permutations for example: n! represents the number of ways to arrange n distinct objects into a sequence (which is something that Hindu scholars had figured out in the 12th century.) The notation n! was introduced by Christian Kramp in 1808. See or for more information!

Your program should prompt the user for a positive number (an integer) up to 15 and then use a while loop to print out the result.

Sample input:

Enter a number from 1 - 15: 5

Sample output:

The factorial of 5 - which is written as 5! is 120.

This program should be named as follows: (for example,

Submit all programs by posting the source file to Blackboard

Notes about your program: