In: Computer Science
For this problem, you will write a program in which the computer plays a dice game called Craps. You might need to explore some Python documentation on random() for this homework assignment.
PROVIDE A GRAPHICAL FLOWCHART as part of your submission for this solution
Rules:
The player rolls two six-sided dice. After rolling, the sum of what the dice show is calculated. If the sum is 7 or 11 on the first roll, the player wins. If the sum is 2, 3, or 12 on the first roll (called “craps”), you lose (the “house” wins). If the sum is 4, 5, 6, 8, 9, or 10 on the first roll, that sum becomes your “point”. To win, you must continue rolling the dice until you “make your point” (i.e., roll that same point value again). You lose by rolling a 7 before making your point.
Requirements:
When your program starts, give the player the option to “back
out” of playing.
After every roll, ask the player if they want to continue. If they quit, exit the program gracefully with a message indicating they quit
Print appropriate messages (and end the game properly) when the player wins or loses, based on the rules provided above.
AMAZING points: These final two points may be awarded if you’ve completed the rest of the assignment perfectly and dazzle us with...
You rolled 2 + 3 = 5
Your Point is 5
Do you want to continue or quit (Q to quit) c
You rolled 1 + 1 = 2
House Manager: “Don’t quit your day job.”
Do you want to continue or quit (Q to quit) c
You rolled 4 + 2 = 6
House Manager: “Are you nervous? You look like you're sweating or just took a shower!”
Do you want to continue or quit (Q to quit) c
You rolled 2 + 3 = 5
You win!
For this problem, you will write a program in which the computer plays a dice game called Craps. You might need to explore some Python documentation on random() for this homework assignment.
PROVIDE A GRAPHICAL FLOWCHART as part of your submission for this solution
Rules:
The player rolls two six-sided dice. After rolling, the sum of what the dice show is calculated. If the sum is 7 or 11 on the first roll, the player wins. If the sum is 2, 3, or 12 on the first roll (called “craps”), you lose (the “house” wins). If the sum is 4, 5, 6, 8, 9, or 10 on the first roll, that sum becomes your “point”. To win, you must continue rolling the dice until you “make your point” (i.e., roll that same point value again). You lose by rolling a 7 before making your point.
Requirements:
When your program starts, give the player the option to “back
out” of playing.
After every roll, ask the player if they want to continue. If they quit, exit the program gracefully with a message indicating they quit
Print appropriate messages (and end the game properly) when the player wins or loses, based on the rules provided above.
AMAZING points: These final two points may be awarded if you’ve completed the rest of the assignment perfectly and dazzle us with...
You rolled 2 + 3 = 5
Your Point is 5
Do you want to continue or quit (Q to quit) c
You rolled 1 + 1 = 2
House Manager: “Don’t quit your day job.”
Do you want to continue or quit (Q to quit) c
You rolled 4 + 2 = 6
House Manager: “Are you nervous? You look like you're sweating or just took a shower!”
Do you want to continue or quit (Q to quit) c
You rolled 2 + 3 = 5
You win!
For this problem, you will write a program in which the computer plays a dice game called Craps. You might need to explore some Python documentation on random() for this homework assignment.
PROVIDE A GRAPHICAL FLOWCHART as part of your submission for this solution
Rules:
The player rolls two six-sided dice. After rolling, the sum of what the dice show is calculated. If the sum is 7 or 11 on the first roll, the player wins. If the sum is 2, 3, or 12 on the first roll (called “craps”), you lose (the “house” wins). If the sum is 4, 5, 6, 8, 9, or 10 on the first roll, that sum becomes your “point”. To win, you must continue rolling the dice until you “make your point” (i.e., roll that same point value again). You lose by rolling a 7 before making your point.
Requirements:
When your program starts, give the player the option to “back
out” of playing.
After every roll, ask the player if they want to continue. If they quit, exit the program gracefully with a message indicating they quit
Print appropriate messages (and end the game properly) when the player wins or loses, based on the rules provided above.
AMAZING points: These final two points may be awarded if you’ve completed the rest of the assignment perfectly and dazzle us with...
You rolled 2 + 3 = 5
Your Point is 5
Do you want to continue or quit (Q to quit) c
You rolled 1 + 1 = 2
House Manager: “Don’t quit your day job.”
Do you want to continue or quit (Q to quit) c
You rolled 4 + 2 = 6
House Manager: “Are you nervous? You look like you're sweating or just took a shower!”
Do you want to continue or quit (Q to quit) c
You rolled 2 + 3 = 5
You win!
import random
wittyMessage= ["House Manager: Don’t quit your day job.", "House Manager: Are you nervous? You look like you're sweating or just took a shower!", "House Manager: “Are you nervous? You look like hungry, go have some dinner!”"]
def roll_die():
return random.randint(1,6)
def roll_dice():
d1, d2 = roll_die(), roll_die()
return d1, d2, (d1 + d2)
def main():
(dice1,dice2,roll) = roll_dice()
print('You rolled', dice1,'+',dice2,'=',roll)
if roll == 7 or roll == 10:
print('Natural, You win!')
elif roll == 2 or roll == 3 or roll == 12:
print('Craps! You lose!')
else:
print('You scored',
roll,'points')
mypoints = roll
playerInput=input('Do you want to
continue or quit (Q to quit or C to Continue)')
if playerInput == 'Q':
print('Thank you
for playing')
quit
if playerInput == 'C' :
reroll(mypoints)
def reroll(points):
dice1 = random.randint(1,6)
dice2 = random.randint(1,6)
total = dice1 + dice2
if total == points:
print('You rolled', dice1, '+',
dice2, '=', total)
print(random.choice(wittyMessage))
print('Congrats you win')
elif total == 7:
print('You rolled', dice1, '+',
dice2, '=', total)
print('Sorry you lose')
main()