Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python 3.6 I have this code so far; import random craps=set([2,3,12]) naturals=set([7,11]) def roll_two_dices(): pass def print_lose(): pass def print_win(): pass def print_point(p): pass

image text in transcribed

In python 3.6

I have this code so far;

import random

craps=set([2,3,12]) naturals=set([7,11])

def roll_two_dices(): pass

def print_lose(): pass

def print_win(): pass

def print_point(p): pass

def is_craps(n): pass

def is_naturals(n): pass

# ATTENTION! # You shouldn't need to edit the function below

def play_craps(): point=-1 while True: n1,n2=roll_two_dices() sumn=n1+n2 print ('You rolled %d + %d = %d'%(n1,n2,sumn)) #initial points obtained here if point==-1: #At the initialisation of point == -1 (see line 29) if is_craps(sumn): #if the sum is in the set of craps print_lose() #then it is an immediate loss return 0 elif is_naturals(sumn): #if the sum is in the set of naturals print_win() #then it is an immediate win return 1 point=sumn print_point(point) else: if sumn==7: print_lose() return 0 elif sumn==point: print_win() return 1 #goal of the game is to keep rolling dice until the sum == points obtained

Game: Craps: Craps is a popular dice game played in casinos. Write a program allowing you to play a variation of the game. This is how the game would be played: a) For the first round, rol two dice. Each die has six faces, and each face reflects a value from 1 to 6. Check the sum of the two dice. i. If the sum is 2, 3 or 12 (called craps), you lose ii. If the sum is 7 or 11 (called natural), you win iii. If the sum is another value (i.e. 4,5,6,8,9, or 10), you earn points equal to the sum obtained. b) Continue to roll the dice until the sum of both dice is either a 7 or the points obtained in the first round i. If 7 is rolled, you lose ii. If the sum obtained is equal to the points you obtained in the first round, you win iii For other sums, continue to roll the dice Your program acts as a single player, and should print the output you see below when the various conditions are met. The function play_craps should return 0 if you lose and if you win. The main program is given here, together with the sub functions you will need to define. Hint: if you are usu how to start, take a look at the main function play craps and see how the sub functions are being called by the main function, to get a better idea of what is required of each sub function import random craps-set ([2,3,12]) naturals-set (17,11]) def ro11 tuo dicesO) #Write here def print lose O def print in) def print point (p): Write here Write here Write here def is.craps (n): Write here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions