In [1]:
l = [1,2,3]

In [20]:
type(l)


Out[20]:
dict

In [19]:
l = {"one":"1","two":"2","Three":3}
l["Three"]


Out[19]:
3

In [34]:
nums = [3,5,6,10,9,14,14,56,41]
def find_num_greater_than_five(num):
    if num > 5:
        print("The number {} is greater than 5".format(num))
    else:
        print("The Number {} is less than or equal to 5".format(num))

In [39]:
number1 = map(find_num_greater_than_five,nums)
for item in number1:
    print(item)


The Number 3 is less than or equal to 5
None
The Number 5 is less than or equal to 5
None
The number 6 is greater than 5
None
The number 10 is greater than 5
None
The number 9 is greater than 5
None
The number 14 is greater than 5
None
The number 14 is greater than 5
None
The number 56 is greater than 5
None
The number 41 is greater than 5
None

In [42]:
number1 = map(find_num_greater_than_five,nums)
for item in number1:
    print(item)


The Number 3 is less than or equal to 5
None
The Number 5 is less than or equal to 5
None
The number 6 is greater than 5
None
The number 10 is greater than 5
None
The number 9 is greater than 5
None
The number 14 is greater than 5
None
The number 14 is greater than 5
None
The number 56 is greater than 5
None
The number 41 is greater than 5
None

In [47]:
def square_num(num):
    return num**2

In [48]:
nums   = [2,4,6,8]

In [49]:
map(square_num,nums)


Out[49]:
<map at 0x104b1fac8>

In [50]:
list(map(square_num,nums))


Out[50]:
[4, 16, 36, 64]

In [52]:
list(map(lambda num:num**3,nums))


Out[52]:
[8, 64, 216, 512]

In [ ]:
people = ['Dr. Christopher Brooks', 'Dr. Kevyn Collins-Thompson', 'Dr. VG Vinod Vydiswaran', 'Dr. Daniel Romero']

def split_title_and_name(person):
    return person.split()[0] + ' ' + person.split()[-1]

#option 1
for person in people:
    print(split_title_and_name(person) == (lambda person:???))

#option 2
#list(map(split_title_and_name, people)) == list(map(???))

In [53]:
people = ['Dr. Christopher Brooks', 'Dr. Kevyn Collins-Thompson', 'Dr. VG Vinod Vydiswaran', 'Dr. Daniel Romero']

def split_title_and_name(person):
    return person.split()[0] + ' ' + person.split()[-1]
map(split_title_and_name,people)


Out[53]:
<map at 0x104b150b8>

In [54]:
list(map(split_title_and_name,people))


Out[54]:
['Dr. Brooks', 'Dr. Collins-Thompson', 'Dr. Vydiswaran', 'Dr. Romero']

In [55]:
people = ['Dr. Christopher Brooks', 'Dr. Kevyn Collins-Thompson', 'Dr. VG Vinod Vydiswaran', 'Dr. Daniel Romero']
#lambda person:person.split()[0] + ' ' + person.split()[-1]
list(map(lambda person:person.split()[0] + ' ' + person.split()[-1],people))


Out[55]:
['Dr. Brooks', 'Dr. Collins-Thompson', 'Dr. Vydiswaran', 'Dr. Romero']

In [56]:
def times_tables():
    lst = []
    for i in range(10):
        for j in range (10):
            lst.append(i*j)
    return lst
times_tables()
#times_tables() == [???]
[]


Out[56]:
[0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 1,
 2,
 3,
 4,
 5,
 6,
 7,
 8,
 9,
 0,
 2,
 4,
 6,
 8,
 10,
 12,
 14,
 16,
 18,
 0,
 3,
 6,
 9,
 12,
 15,
 18,
 21,
 24,
 27,
 0,
 4,
 8,
 12,
 16,
 20,
 24,
 28,
 32,
 36,
 0,
 5,
 10,
 15,
 20,
 25,
 30,
 35,
 40,
 45,
 0,
 6,
 12,
 18,
 24,
 30,
 36,
 42,
 48,
 54,
 0,
 7,
 14,
 21,
 28,
 35,
 42,
 49,
 56,
 63,
 0,
 8,
 16,
 24,
 32,
 40,
 48,
 56,
 64,
 72,
 0,
 9,
 18,
 27,
 36,
 45,
 54,
 63,
 72,
 81]

In [57]:
import googlemaps
from datetime import datetime

gmaps = googlemaps.Client(key='AIzaSyDbkVTmr6r64urBwdPCinoetVAg7nyhVSo')

# Geocoding an address
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')

# Look up an address with reverse geocoding
reverse_geocode_result = gmaps.reverse_geocode((40.714224, -73.961452))

# Request directions via public transit
now = datetime.now()
directions_result = gmaps.directions("Sydney Town Hall",
                                     "Parramatta, NSW",
                                     mode="transit",
                                     departure_time=now)


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-57-6f967a28c66c> in <module>()
----> 1 import googlemaps
      2 from datetime import datetime
      3 
      4 gmaps = googlemaps.Client(key='AIzaSyDbkVTmr6r64urBwdPCinoetVAg7nyhVSo')
      5 

ImportError: No module named 'googlemaps'

In [63]:
import googlemaps


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-63-80859df338b6> in <module>()
----> 1 import googlemaps

ImportError: No module named 'googlemaps'

In [ ]:
gmaps = googlemaps.Client(client_id=client_id, client_secret=client_secret)

# Geocoding and address
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')

# Look up an address with reverse geocoding
reverse_geocode_result = gmaps.reverse_geocode((40.714224, -73.961452))

# Request directions via public transit
now = datetime.now()
directions_result = gmaps.directions("Sydney Town Hall",
                                     "Parramatta, NSW",
                                     mode="transit",
                                     departure_time=now)