# Helene Martin, Garfield High School # Simulates coin flips using random from random import * # This constant's value determines how many flips to make COUNT = 1000 # Initialize a 2-item list to hold count of heads and tails # To initialize a list of 50 items, use list_name = [0] * 50 flip_counts = [0, 0] for i in range(COUNT): flip = randint(0, 1) flip_counts[flip] += 1 # This is a new kind of for loop. It sets flip_count to the next value in the list flip_counts each time around until all values have been used. for flip_count in flip_counts: print flip_count