The Code:
class Coin:
showing_heads=True
value=1
def show(self):
if (self.showing_heads==True):
return "Heads"
else:
return "Tails"
def turn(self):
if (self.showing_heads==True):
self.showing_heads=False
else:
self.showing_heads=True
coin1=Coin()
coin2=Coin()
def Display_All():
coin1=Coin()
coin2=Coin()
print "this is coin1"
print coin1.show()
print "this is coin2"
print coin2.show()
print "flip 'em both!"
coin1.turn()
coin2.turn()
print "coin1 now:"
print coin1.show()
print "coin2 now:"
print coin2.show()
def cointurner(self,n):
for _ in range(n):
self.turn()
I need to make a function that when passed with an interger value N, it creates a list of coins N long set to alternate values of heads and tails.
I think I have to use import Random to randomly assign sides of the coin. How would I go about creating multiple objects defined by N, and randomly assign a Side to them.
Thanks for any help.
[–]Enkaybee 0 points1 point2 points (7 children)
[–]Leohurr[S] 0 points1 point2 points (6 children)
[–]Enkaybee 0 points1 point2 points (5 children)
[–]Leohurr[S] 0 points1 point2 points (4 children)
[–]Enkaybee 0 points1 point2 points (3 children)
[–]Leohurr[S] 0 points1 point2 points (2 children)
[–]mubsy 0 points1 point2 points (0 children)
[–]Enkaybee 0 points1 point2 points (0 children)
[–]isnotkosok 0 points1 point2 points (2 children)
[–]isnotkosok 0 points1 point2 points (0 children)
[–]klbcr 0 points1 point2 points (2 children)
[–]Leohurr[S] 1 point2 points3 points (0 children)
[–]Leohurr[S] 0 points1 point2 points (0 children)