Question: Write a Python program that will flip 5 coins according to the following requirements: 1 . The program will use the following as the main
Write a Python program that will flip coins according to the following requirements:
The program will use the following as the main script:
from coin import Coin
def main:
coins
coin Coin "heads"
coin Coin "heads"
coin Coin "heads"
coin Coin "heads"
coin Coin "heads"
coins.appendcoin
coins.appendcoin
coins.appendcoin
coins.appendcoin
coins.appendcoin
for c in range:
coinscflip
for c in range:
printValue: coinscgetValue
printFace: coinscgetSide
if namemain:
main
Notice what the main script does:
It imports a Coin object.
It then declares an empty list called coins.
It creates five coins: a penny, a nickel, a dime, a quarter, and a fiftycent piece.
Each of the coins starts out heads up on the table.
It adds each of the coins to the coins list.
It then flips each coin in the list
It then prints the value and face of each coin in the list
What you need to do:
You need to create a coin.py script that contains a definition for a Coin object. Notice that at a minimum, you will need to create the following methods in your class definition:
ainit Constructs a new coin with the passed in value and side
b getSide Returns the side of the coin that is up
c flip Flips the coin so that a random heads or tails is up
d getValue Returns the value denomination of the coin
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
