Generation

generate functionWed, 08 Mar 2023

Upgrade the code so that a roll of 000, 007, 017, 027, 037, 047, 057, 067, 077, 087, 097, 010, 020, 030, 040, 050, 060, 070, 080, 090 will drop 1 dollar for i in range(trials): num = np.random.randint(1, 1000) if num == 777: money += 200; successes += 1 elif num == 999: money += 100; successes += 1 elif num == 555: money += 50; successes += 1 elif num == 333: money += 15; successes += 1 elif num == 111: money += 10; successes += 1 elif ends77(num) == True: money += 5; successes += 1 elif ends7(num) == True: money += 3; successes += 1 elif ends00(num) == True: money += 2; successes += 1 elif ends0(num) == True: money += 1; successes += 1 else: money -= 1

def ends77(num): return num % 100 == 77 def ends7(num): return num % 10 == 7 def ends00(num): return num % 100 == 0 def ends0(num): return num % 10 == 0

Questions about programming?Chat with your personal AI assistant