''' DS2000 Fall 2024 Sample code from class - conditionals and random numbers Playing a game with rolling two dice - roll die #1 using random.randint(1, 6) - roll die #2 using random.randint(1, 6) - depending on outcome, Laney gets different amounts of $$ (could be negative, doesn't have to be) What are our conditions? - if roll1 < roll2 - if roll1 is the same as roll2 - if sum of roll1 + roll2 is greater than 6 - if roll1 == roll2 but they're greater than some minimum ''' import random def main(): # step one: initialize starting point for $$ # this is outside the for loop so it happens once money = 0 for i in range(50): # step one cont'd: gather data by rolling two dice and saving values # this is inside the for loop so we roll the dice over and over again roll1 = random.randint(1, 6) roll2 = random.randint(1, 6) # step two: computations. figure out how much $$ we added # to the pile from the current roll if roll1 < roll2: money = money + 2 elif roll1 == roll2: money = money + 9 if roll1 + roll2 >= 10: money = money + 20 # another computation - if we add the values together and > 6 if roll1 + roll2 > 6: money = money + 5 # step three: communicate. Report the dice values each time # (inside the for loop) print("Dice were", roll1, roll2) # step three cont'd: communicate the total amount of money # after all rounds are completed (outside the for loop so it # happens only once) print("And now we have... $", money, sep = "") main()