import random def count( n ): """ purpose: simulate n rolls of two dice. each time get their total """ result = 0 for i in range( 0, n ): # this loops through the values from 0 to n-1 (up to and not including n) dice1 = random.randrange(1, 7) dice2 = random.randrange(1, 7) roll = dice1 + dice2 if ( roll == 12 ): result = result + 1 return result # print(count(36)) # print(count(3600)) x = [3, 1, 4, 5] print("x=", x) x.append( 7 ) # append function returns None. Its purpose is to change the list itself print("x=", x) def g( items, n ): # contents of the list will be changed, so we return None. We return a list if we're creating a copy items.append( n ) return None g(x, 12) print("x=", x) def metric( d ): list1 = d.keys() list2 = d.values() result = True for k in list1: v1 = d.get( k ) # get the value v1 for key k. k : v1 v2 = d.get( v1 ) # get the value v2 for key v1 v1 : v2 if ( v2 != k ): # we want k : v1, and v1 : k. If this isn't true, then it's not symmetric result = False return result