Skip to content

Instantly share code, notes, and snippets.

@deontologician
Created May 31, 2014 23:02
Show Gist options
  • Save deontologician/64de3460512aa2055a6a to your computer and use it in GitHub Desktop.
Save deontologician/64de3460512aa2055a6a to your computer and use it in GitHub Desktop.
{
"name": "Marmaduke",
"breed": "Mastif",
"jumping_height": 0.5,
"color": "brown",
}
def make_dog(name, breed, jumping_height, color='brown'):
return {
"name": name,
"breed": breed,
"jumping_height": jumping_height,
"color": color
}
def print_dog(dog):
print("Name:", dog['name'], "Breed:", dog['breed'])
def print_cat(cat):
print(...)
def jump(dog):
print(dog['name'], "jumped",
dog['jumping_height'], "feet in the air")
{
"name": "Marmaduke",
"breed": "Mastif",
"jumping_height": 0.5,
"color": "brown",
}
class Dog(object):
def __init__(self, name, breed, jumping_height, color='brown'):
self.name = name
self.breed = breed
self.jumping_height = jumping_height
self.color = color
def print(self):
print("Name:", dog.name, "Breed:", dog.breed)
def jump(self):
print(self.name, "jumped",
self.jumping_height, "feet in the air")
print_dog(dog)
dog.print()
words = declaration.split()
word_lengths = [len(word) for word in words]
counts = {}
for length in word_lengths:
counts[length] += 1
# extra stuff here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment