Python 3.7.5 Shell
File Edit Shell Debug Options Window Help
Python craps_perez.py - C:\Users\Perezi3\Documents\craps_perez.py (3.7.5)
(AMD64
Type File Edit Format Run Options Window Help
>>>
Python 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit
Type "help", "copyright", "credits" or "license()" for more information.
import random
def roll_dice():
# Simulate rolling two six-sided dice and return the sum
return random.randint(1, 6) + random.randint(1, 6)
def main():
total_games = 0 # Initialize the total number of games played
total_won = 0
games_won = 0
# Initialize the total amount of money won
# Initialize the number of games won
play_again = "y" # Initialize the variable to control if the
while play_again == "y":
total_games += 1 # Increment the total games count by 1
bet_amount = float(input("Enter your bet amount: ")) #C
dice_sum = roll_dice()
if dice_sum in {7, 11}:
# Roll the dice and get the sum
# User won on the first roll
play_again = input("You rolled a {} and won ${}. Do you want to play
games_won += 1 # Increment the games won count
total_won += bet_amount # Add the bet amount to the total winnings
elif dice_sum in {2, 3, 12}:
# User lost on the first roll
play_again = input("You rolled a {} and lost ${}. Do you want to pla
total_won -= bet_amount # Subtract the bet amount from the total wi
else:
# User didn't win or lose on the first roll, proceed to subsequent r
play_again = input("You rolled a {}. Press Enter to roll again: ".fo
point = dice_sum
dice_sum = roll_dice()
while dice_sum != point and dice_sum != 7:
# Continue rolling until the point or a 7 is rolled
Ln: 6 Col: 16