Question: liberty bell slot machine part 2 finish the missing function and have it produce the correct sample output It cost 5 cents to play and
liberty bell slot machine part
finish the missing function and have it produce the correct sample output
It cost cents to play and the payouts worked as follows:
three Liberty Bells: cents
three hearts: cents
three diamonds: cents
three spades: cents
three horseshoes: cents
two horseshoes and any other one symbol: cents
all other combinations: nothing
sample output:
Program : Liberty Bell Slot Machine Simulation
Part : Testing Known Spins
REEL REEL REEL PAYOUT
bell bell bell
heart heart heart
diamond diamond diamond
spade spade spade
horseshoe horseshoe horseshoe
horseshoe horseshoe heart
horseshoe diamond horseshoe
spade horseshoe horseshoe
heart heart horseshoe
bell diamond spade
Part : Simulating Spins
For every $ spent, you can expect to win $
missing codefunction:
import random
DIAMOND
HEART
SPADE
HORSESHOE
LIBERTYBELL
def convertreel:
if reel DIAMOND:
return "diamond"
elif reel HEART:
return "heart"
elif reel SPADE:
return "spade"
elif reel HORSESHOE:
return "horseshoe"
elif reel LIBERTYBELL:
return "bell"
else:
return "error!"
def testknownspinreel reel reel:
message fconvertreel:convertreel:convertreel:spinpayoutreel reel reel:d
printmessage
def testknownspins:
print::::formatREEL "REEL "REEL "PAYOUT"
print::::format
testknownspinLIBERTYBELL, LIBERTYBELL, LIBERTYBELL
testknownspinHEART HEART, HEART
testknownspinDIAMOND DIAMOND, DIAMOND
testknownspinSPADE SPADE, SPADE
testknownspinHORSESHOE HORSESHOE, HORSESHOE
testknownspinHORSESHOE HORSESHOE, HEART
testknownspinHORSESHOE DIAMOND, HORSESHOE
testknownspinSPADE HORSESHOE, HORSESHOE
testknownspinHEART HEART, HORSESHOE
testknownspinLIBERTYBELL, DIAMOND, SPADE
def simulatehowmany:
totalwinnings
for in rangehowmany:
reel random.randint
reel random.randint
reel random.randint
totalwinnings spinpayoutreel reel reel
printfExpected winnings after howmany spins: $totalwinnings howmany:f
def main:
printProgram : Liberty Bell Slot Machine Simulation"
printPart : Testing Known Spins"
testknownspins
print Part : Simulating Spins"
simulate
if namemain:
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
