"""
List comprehensions can be nested, in which case they take on the following form:

http://www.u.arizona.edu/~erdmann/mse350/topics/list_comprehensions.html

[ expression-involving-loop-variables for outer-loop-variable in outer-sequence for inner-loop-variable in inner-sequence ]

results = []
for outer_loop_variable in outer_sequence:
    for inner_loop_variable in inner_sequence:
        results.append( expression_involving_loop_variables )

"""
###############################################################################



###############################################################################

possible_choices = []
for drink in ['water', 'tea', 'juice']:
       for food in ['ham', 'eggs', 'spam']:
             possible_choices.append([drink,food])

print "Possbile choinces" , possible_choices


# using nested list comprehension
possible_choices=[[drink,food] for drink in ['water', 'tea', 'juice'] for food in ['ham', 'eggs', 'spam']]
print "Possible Choice by nested list comprehension" , possible_choices

###############################################################################

# The above using zip function

sports=['cricket','football']
person = ['sachin','ronaldo']

print zip(sports,person)

sportperson = [ zip]

###############################################################################

for x in range(10):
    print x , 'raised to power', 2**x

#using map
result = list(map(lambda x: 2 ** x, range(terms)))

# display result
print("The total terms is:",terms)
for i in range(terms):
    print("2 raised to power",i,"is",result[i])

'''
Power of number

The total terms is: 10
2 raised to power 0 is 1
2 raised to power 1 is 2
2 raised to power 2 is 4
2 raised to power 3 is 8
2 raised to power 4 is 16
2 raised to power 5 is 32
2 raised to power 6 is 64
2 raised to power 7 is 128
2 raised to power 8 is 256
2 raised to power 9 is 512

'''
