How do I write the main program for the following exercise? (I have the module r
ID: 3689630 • Letter: H
Question
How do I write the main program for the following exercise? (I have the module ready)
slotMachine = [0,0,0]
winnings = 0
#drawings = [["____ "," / ", " / ", " / "], [" / ", " | ", " / ", " / "],[" / ","| | ", "| | ", "/__ "],[" / ", "/ ", " / ", " / "],[" ", " ** ", " ", "__/ "]]
drawings = [["____ "," / "," / "," / "," "],
[" / "," | ","| | ","/ "," ** "],
[" / "," / ","| | "," / "," "],
[" / "," / ","/__ "," / ","__/ "]]
def spinOneWheel ():
import random
diceRoll = random.randint (1,21)
#print (diceRoll) #debug
if diceRoll == 20:
wheelRoll = int(1)
elif diceRoll == 18 or diceRoll == 19:
wheelRoll = int(2)
elif diceRoll == 14 or diceRoll == 15 or diceRoll == 16 or diceRoll == 17:
wheelRoll = int(3)
elif diceRoll == 8 or diceRoll == 9 or diceRoll == 10 or diceRoll == 11 or diceRoll == 12 or diceRoll == 13:
wheelRoll = int(4)
else:
wheelRoll = int(5)
return wheelRoll
#print (wheelRoll) #debug
#spinWheels
#parameters: no parameters given
#returns: no value
#purpose: call the function spinOneWheel 3 times.
def spinWheels ():
for k in range (0,3):
symbol = spinOneWheel ()
slotMachine[k] = symbol
## for k in range (0, 4):
## if 1 in slotMachine:
## ind = slotMachine.index(1)
## slotMachine[ind] = "seven"
## elif 2 in slotMachine:
## ind = slotMachine.index(2)
## slotMachine[ind] = "cherry"
## elif 3 in slotMachine:
## ind = slotMachine.index(3)
## slotMachine[ind] = "bell"
## elif 4 in slotMachine:
## ind = slotMachine.index(4)
## slotMachine[ind] = "diamond"
## elif 5 in slotMachine:
## ind = slotMachine.index(5)
## slotMachine[ind] = "smiley"
#print (slotMachine) #debug
#determineWinnings
#parameters: no parameters given
#returns: the variable winnings
#purpose: determine the number of tokens the player has won
def determineWinnings ():
if slotMachine == [1,1,1]:
winnings = 2
elif slotMachine == [2,2,2]:
winnings = 5
elif slotMachine == [3,3,3]:
winnings = 10
elif slotMachine == [4,4,4]:
winnings = 100
elif slotMachine == [5,5,5]:
winnings = 1000
else:
winnings = 0
return winnings
#setSlotMachine
#parameters: variables A, B, C
#returns: no value
#purpose: insert values into the list slotMachine
def setSlotMachine (A, B, C):
slotMachine [0] = A
slotMachine [1] = B
slotMachine [2] = C
print (slotMachine)
#displaySlotMachine
#params: no params given
#returns: ASCII art of the symbol
#purpose: draw the result of the slot machine.
def displaySlotMachine ():
symbol1= slotMachine [0]
symbol2= slotMachine [1]
symbol3= slotMachine [2]
print (drawings [0][symbol1-1],drawings[0][symbol2-1],drawings[0][symbol3-1])
print (drawings [1][symbol1-1],drawings[1][symbol2-1],drawings[1][symbol3-1])
print (drawings [2][symbol1-1],drawings[2][symbol2-1],drawings[2][symbol3-1])
print (drawings [3][symbol1-1],drawings[3][symbol2-1],drawings[3][symbol3-1])
#drawings = [["____ "," / "," / "," / "," "],
#[" / "," | ","| | ","/ "," ** "],
#[" / "," / ","| | "," / "," "],
#[" / "," / ","/__ "," / ","__/ "]]
Explanation / Answer
Design for Casino slot machines:
Winning Combination
Chance of Winning Combination
Amount Won
Average Amount spent before Win
Average Player loses and Casino gains
Triple Smiley
1/8 = 0.0125%
1000
8000
7000
Triple Diamond
10 / 8 = 1.25%
100
2500
2400
Triple Bell
100 / 8 = 12.5%
10
112.5
92.5
Triple Cherry
200 / 8 = 25%
5
20
15
Triple Seven
500 / 8 = 62.5%
2
3.2
1.2
Winning Combination
Chance of Winning Combination
Amount Won
Average Amount spent before Win
Average Player loses and Casino gains
Triple Smiley
1/8 = 0.0125%
1000
8000
7000
Triple Diamond
10 / 8 = 1.25%
100
2500
2400
Triple Bell
100 / 8 = 12.5%
10
112.5
92.5
Triple Cherry
200 / 8 = 25%
5
20
15
Triple Seven
500 / 8 = 62.5%
2
3.2
1.2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.