Question: USE PYTHON CODING class Coin: #This class lets us create Coin objects showing_heads=True #By default the coin shows heads value=1#By default the coin has the

USE PYTHON CODING

class Coin:

#This class lets us create Coin objects

showing_heads=True #By default the coin shows "heads"

value=1#By default the coin has the value 1p

def show(self):

#Returns a string to incicate which face of the coin is showing

if (self.showing_heads==True):

return "Heads"

else:

return "Tails"

def turn(self):

#Turns the coin over

self.showing_heads=not self.showing_heads

Using the code shown above as a base write a code to do the following:

- Create two coin objects coin1 and coin2

- Demonstrate that they are both show() Heads

- Demonstrate that if you turn() either of them they show Tails

- Add a new member function to Coin called setValue which sets value attribute of a coin

- Add a new member function to Coin called getValue which returns the value attribute of the coin as an integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!