# Use a function from the random library to simulate rolling dice. Wr...

## Question

Use a function from the random library to simulate rolling dice. Write a function that rolls a single die and then use that function to build a program that let's the user play craps. The basic rules of craps are:

1. A player rolls two six-sided dice and adds the numbers rolled together.
2. On this first roll, a 7 or an 11 automatically wins, and a 2, 3, or 12 automatically loses, and play is over. If a 4, 5, 6, 8, 9, or 10 are rolled on this first roll, that number becomes the "point.”
3. The player continues to roll the two dice again until one of two things happens: either they roll the "point" again, in which case they win; or they roll a 7, in which case they lose.

Playing craps can include a number of variations on this game, and also typically involves betting on various outcomes.

Have some fun with different library functions by figuring out how to get Python to:

- Print out a calendar of the month you were born
- Tell you how many days it is until your next birthday
- What day of the week was the Declaration of Independence ratified by the Continental Congress? (write a program that prints out Monday, Tuesday, etc)

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import random

def roll_dice(n):
roll = [random.randint(1,6) for i in range(n)]
total = sum(roll)
print("Player rolls "+str(roll)+" = "+str(total))

print("*** CRAPS GAME ***")

total = roll_dice(2)
if total in [7, 11]:
print("Player automatically wins!")
elif total in [2, 3, 12]:
print("Player automatically loses!")
else:
point = total
while True:...

By purchasing this solution you'll be able to access the following files:
Solution.py.

\$50.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.