Question: python code problem Question #9: (15 points) Part A (10 points). Write a class Coin that represents a coin with two sides (heads and tails)
python code problem

Question #9: (15 points) Part A (10 points). Write a class Coin that represents a coin with two sides ("heads" and tails") and keeps track of how many times it lands with each side up when flipped. Your class should include the following two functions: 1. a constructor that initializes two instances variables heads and tails to both be zero. These instance variables will represent the number of times the coin was flipped and either heads or tails was face up, respectively. a function flip that randomly chooses one side of the coin to be face up after flipping the coin, increments the count for the chosen side, and returns the string "heads" if the coin landed with heads up or returns "tails" if the coin landed with tails up. 2. Part B (5 points): write some code that creates a new Coin object, calls flip 30 times, then prints the number of times heads was facing up, and finally prints how many times tails was facing up. One example output might be: Heads was up 16 times Tails was up 14 times
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
