Code a Couple of Minigames on Python Project
Question Description
I’m working on a computer science exercise and need a sample draft to help me learn.
Unformatted Attachment Preview
# NOTE: leave the functions here, at the top
def flip_coin():
# TODO: implement this function
# get a random int between 0 and 1
# if the number is 0, return “Coin flip: Tails”
# if the number is 1, return “Coin flip: Heads”
# delete this next line:
return 0
def roll_d6():
# TODO: implement this function
# get a random int between 1 and 6
# return “D6 roll: [that number]”
# delete this next line:
return 0
def roll_d20():
# TODO: implement this function
# get a random int between 1 and 20
# return “D20 roll: [that number]”
# delete this next line:
return 0
def pick_card():
# TODO: implement this function
# get a random number between 0 and 3
# [card suit]: 0=spades, 1=hearts, 2=diamonds, 3=clubs
# then get a random number between 1 and 13
# [card value]: 1=Ace, 11=Jack, 12=Queen, 13=King, 2-10 are normal (no
translation)
# return “Your card: [card value] of [card suit]”
# delete this next line:
return 0
# NOTE: leave the user interaction here, at the bottom
# TODO: put the following lines into a loop, to allow the user to repeat until
they quit
print(‘Welcome to the game center!nHere are your options:’)
print(‘t1) Flip a coinnt2) Pick a random playing card’)
print(‘t3) Roll a 6-sided dicent4) Roll a 20-sided dice’)
choice = input(‘What would you like to do? ‘)
# TODO: based on what the user selects, call the appropriate function above
(print the result)
Purchase answer to see full
attachment
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."