Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am reeddunkle on github.
  • I am reeddunkle (https://keybase.io/reeddunkle) on keybase.
  • I have a public key ASCm2gw-AtqWXibjXoD53MAUkYJSEBVVE6526_lKxxUPgQo

To claim this, I am signing this object:

@reeddunkle
reeddunkle / Exercise5.py
Last active May 2, 2016 18:56
Custom Filter Method
def my_filter(function, iterable):
output = []
for item in iterable:
if function(item):
output.append(item)
return output
@reeddunkle
reeddunkle / startswith.sh
Last active May 4, 2016 19:11
Python startswith() method
>>> string = "Reed Dunkle"
>>> string.startswith('Reed D')
True
>>> string.startswith('Re')
True
>>> string.startswith('Reed W')
False
>>>
@reeddunkle
reeddunkle / tuples.sh
Last active May 4, 2016 19:10
Tuples Example
>>> tuple = ('fashion', 'nugget')
>>> tuple[0]
'fashion'
>>> tuple[1]
'nugget'
@reeddunkle
reeddunkle / Exercise6.py
Created May 2, 2016 18:59
Custom Filter Exercise
def my_filter(function, iterable):
output = []
for item in iterable:
if function(item):
output.append(item)
return output
@reeddunkle
reeddunkle / Exercise7.py
Last active May 4, 2016 20:07
Custom Map Method
def my_map(function, iterable):
output = []
for element in iterable:
result = function(element)
output.append(result)
return output
@reeddunkle
reeddunkle / Exercise8.py
Last active May 5, 2016 16:30
Custom Map Exercise
FILES = ["picture1", "georgi_paws_everywhere", "custom_wreath"]
def my_map(function, iterable):
output = []
for element in iterable:
result = function(element)
output.append(result)
@reeddunkle
reeddunkle / Exercise9.py
Last active May 5, 2016 16:50
Custom Map Exercise
NUMBERS = range(4)
NAMES = ['Rebecca', 'Georgi', 'Reed', 'Thom Yorke']
def my_map(function, iterable):
output = []
for element in iterable:
result = function(element)
@reeddunkle
reeddunkle / Exercise8-2.py
Created May 5, 2016 16:49
List Comprehension Map
FILES = ["picture1", "georgi_paws_everywhere", "custom_wreath"]
results = ["{}.jpg".format(file) for file in FILES]
print results
@reeddunkle
reeddunkle / Exercise9-2.py
Created May 5, 2016 17:42
List Comprehension Exercise
'''
This is hacky and ugly. It only works because both
lists are the same size, etc. etc.
Upon researching this, it seems that this is an example
when map() is actually way better and preferable.
There's also a function called zip() which does this,
but I haven't learned zip() yet.