Question: Liberty Bell Slot Machine Simulation use the python code below to finish the missing functions import random # Constants that represent the result of spinning
Liberty Bell Slot Machine Simulation
use the python code below to finish the missing functions
import random
# Constants that represent the result of spinning a reel
DIAMOND
HEART
SPADE
HORSESHOE
LIBERTYBELL
#
# spinpayout
#
# reel: the symbol on the first reel, an integer constant
# reel: the symbol on the second reel, an integer constant
# reel: the symbol on the third reel, an integer constant
#
# Returns an integer, the payout of the spin
#
The missing spinpayout function goes here
#
# convert
#
# reel: the symbol on a reel, an integer constant
#
# Returns a string, the printing value of integer
#
def convertreel:
Convert the suit constants into suit strings.
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!"
#
# testknownspin
#
# reel: the symbol on the first reel, an integer constant
# reel: the symbol on the second reel, an integer constant
# reel: the symbol on the third reel, an integer constant
#
# Display a message that shows the spin and its payout
#
def testknownspinreel reel reel:
Print what happens with a specific spin.
message :formatconvertreel
message :formatconvertreel
message :formatconvertreel
message :dformatspinpayoutreel reel reel
printmessage
#
# testknownspins
#
# For testing purposes, evaluate a variety of known spins
#
def testknownspins:
Test various spin combinations to see if the payouts are correct.
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
#
# simulate
#
# howmany: the number of spins to take, an integer
#
# Simulate the Liberty Bell Slot Machine being played
# howmany times. Calculate and print the expected winnings.
#
The missing simulate function goes here
#
# main controls the main flow of logic
#
def main:
The main control function for Program
printProgram : Liberty Bell Slot Machine Simulation
print Part : Testing Known Spins
testknownspins
print
Part : Simulating Spins
simulate
#
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
