""" Felix Muzny DS 2000 Lecture 7 September 27, 2024 A program to go gambling (conditionals + a for loop) Updated: add a variable to track how much we won or lost over time for this version: 1. doubles win $200 2. otherwise, lose $100 """ import random def main(): print("lec 7 - casino w/ total tracker") # 1) initialize accumulator variable total_winnings = 0 for i in range(10): # secret code: # i = next value in sequence [0, 1, 2, 3, 4] # print("i:", i) # uncomment to see for yourself! # step 1 - roll dice die1 = random.randint(1, 6) die2 = random.randint(1, 6) # show the die so we can debug print("Die 1:", die1) print("Die 2:", die2) # Step 2 - do computation (and step 3 - communicate results) if die1 == die2 : print("you won $200!") # remember += is the same as # total_winnings = total_winnings + 200 # 2) update accumulator variable total_winnings += 200 else: print("you lost $100!") # 2) update accumulator variable total_winnings -= 100 print("Current total:", total_winnings) print() print("Total winnings:", total_winnings) main()