out = []
for item in x:
out.append(item**2)
print(out)
[item**2 for item in x]
def my_func(param1='default'):
"""
Docstring goes here.
"""
print(param1)
my_func
my_func()
my_func('new param')
my_func(param1='new param')
def square(x):
return x**2
out = square(2)
print(out)
def times2(var):
return var*2
times2(2)
lambda var: var*2
seq = [1,2,3,4,5]
map(times2,seq)
list(map(times2,seq))
list(map(lambda var: var*2,seq))
filter(lambda item: item%2 == 0,seq)
list(filter(lambda item: item%2 == 0,seq))
st = 'hello my name is Sam'
st.lower()
st.upper()
st.split()
tweet = 'Go Sports! #Sports'