MIS 301 Programming Assignment 3
By Tanishka Bansal
Programming Code: import random def spin_slots():
slot1 = random.randint(0, 8)
slot2 = random.randint(0, 8)
slot3 = random.randint(0, 8)
print(f"Display: {slot1} {slot2} {slot3}")
if slot1 == slot2 == slot3:
print("JACKPOT!")
return 10
elif slot1 == slot2 or slot1 == slot3 or slot2 == slot3:
print("NICE MATCH!")
return 3
return 0
def main():
tokens = int(input("Enter the number of tokens you are starting with: "))
print(f"Tokens = {tokens}")
print()
while tokens > 0:
tokens -= 1
tokens += spin_slots()
print(f"Tokens = {tokens}")
print()
if input("To spin again, hit carriage return; otherwise type any other character: "):
break
print()
if tokens <= 0:
print("Final tokens = 0")
print("Sorry, you are out of tokens!")
else:
print(f"Final tokens = {tokens}")
if __name__ == "__main__":
main()
Code Screenshot: