Example #1
0
def main():
    playing = True
    while playing:
        flips = input_flips()
        flip_count = flip_the_coin(flips)
        show_results(flip_count)
        playing = play_again()
 def test_1_tails_results(self):
     show_results([1])
     self.assertEqual(sys.stdout.getvalue().strip(),
                      'Tails\n1 Flips: 0 Heads & 1 Tails')
 def test_1_heads_results(self):
     show_results([0])
     self.assertEqual(sys.stdout.getvalue().strip(),
                      'Heads\n1 Flips: 1 Heads & 0 Tails')
 def test_0_flips_results(self):
     show_results([])
     self.assertEqual(sys.stdout.getvalue().strip(),
                      '0 Flips: 0 Heads & 0 Tails')
 def test_2heads_2tails_results(self):
     show_results([0, 1, 0, 1])
     self.assertEqual(
         sys.stdout.getvalue().strip(),
         'Heads\nTails\nHeads\nTails\n4 Flips: 2 Heads & 2 Tails')