fork download
  1. class Coin(object):
  2. def __init__(self):
  3. self.showing_heads = True
  4. self.value = 1
  5.  
  6. def show(self):
  7. return "Heads" if self.showing_heads else "Tails"
  8.  
  9. def turn(self):
  10. self.showing_heads = not self.showing_heads
  11.  
  12. def display_all():
  13. coin1=Coin()
  14. coin2=Coin()
  15. print "this is coin1"
  16. print coin1.show()
  17. print "this is coin2"
  18. print coin2.show()
  19. print "flip 'em both!"
  20. coin1.turn()
  21. coin2.turn()
  22. print "coin1 now:"
  23. print coin1.show()
  24. print "coin2 now:"
  25. print coin2.show()
  26.  
  27. if __name__ == "__main__":
  28. display_all()
  29.  
  30.  
Success #stdin #stdout 0.08s 8888KB
stdin
Standard input is empty
stdout
this is coin1
Heads
this is coin2
Heads
flip 'em both!
coin1 now:
Tails
coin2 now:
Tails