0% found this document useful (0 votes)
763 views

Slot Machine Game in Python

This document contains the code for a slot machine game. The game initializes the player with 100 credits and allows them to choose between playing the slots for 25, 50, or 100 credits per turn. When playing, a random number is generated to determine if the player wins or loses their wager. If the player runs out of credits, additional funds are provided to continue play up to 6 times. The player can also check their current credit balance or exit the game at any time.

Uploaded by

Neil Mande
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
763 views

Slot Machine Game in Python

This document contains the code for a slot machine game. The game initializes the player with 100 credits and allows them to choose between playing the slots for 25, 50, or 100 credits per turn. When playing, a random number is generated to determine if the player wins or loses their wager. If the player runs out of credits, additional funds are provided to continue play up to 6 times. The player can also check their current credit balance or exit the game at any time.

Uploaded by

Neil Mande
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import time

import random

print('Welcome to the slot machine app!')

credit = 100
print('You have 100 credits!')
print('Each turn would cost 25, 50 or 100 credits.')

credit0 = 1

while (1 == 1):
choice = int(input('1 for trying at the slots, 2 for checking the credits, 3
for exiting the game: '))
if (choice >= 4):
print('Add the correct value!')

if (choice ==1):
while (1 == 1):
print('1 for 25 at stake, 2 for 50 at stake, 3 for 100 at stake.')

slotchoice = int(input('Which slot would you like to try?(Press 4 to go


back to main menu): '))
if (slotchoice >= 5):
print('Add the correct value!')
if (slotchoice == 1):
if (credit0 == 6):
print('Sorry, we cannot add any more credits :(')
continue
if (credit <= 24):
print('Oh no! You are out of or do not have enough credits!
Here is another 25 to keep you going!')
credit = credit + 25
credit0 = credit0 + 1
continue
number = random.randint(1,3)
credit = credit - 25
if (number == 2 or number == 3):
print('Sorry, you lost. 25 credits lost.')
continue
if (number == 1):
print('Lucky, you won! 25 credits added!')
credit = credit + 25
continue
if (slotchoice == 2):
if (credit0 == 6):
print('Sorry, we cannot add any more credits :(')
continue
if (credit <= 49):
print('Oh no! You are out of or do not have enough credits!
Here is another 50 to keep you going!')
credit = credit + 50
credit0 = credit0 + 1
continue
number = random.randint(1,3)
credit = credit - 50
if (number == 2 or number == 3):
print('Sorry, you lost. 50 credits lost.')
continue
if (number == 1):
print('Lucky, you won! 50 credits added!')
credit = credit + 50
continue
if (slotchoice == 3):
if (credit0 == 6):
print('Sorry, we cannot add any more credits :(')
continue
if (credit <= 99):
print('Oh no! You are out of credits! Here is another 100 to
keep you going!')
credit = credit + 100
credit0 = credit0 + 1
continue
number = random.randint(1,3)
credit = credit - 100
if (number == 2 or number == 3):
print('Sorry, you lost. 100 credits lost.')
continue
if (number == 1):
print('Lucky, you won! 100 credits added!')
credit = credit + 100
continue
if (slotchoice == 4):
break
if (choice == 2):
time.sleep(2)
print(credit)
if (choice == 3):
print('Goodbye! See you next time!')
time.sleep(2)
break

You might also like