Skip to content

Instantly share code, notes, and snippets.

@jherrlin
Created December 10, 2015 16:35
Show Gist options
  • Save jherrlin/41bdaf25fae274210a97 to your computer and use it in GitHub Desktop.
Save jherrlin/41bdaf25fae274210a97 to your computer and use it in GitHub Desktop.
class Car(object):
def __init__(self, color, gears): # This is the constructor with 2 arguments as input
self.color = color # This is object attribute
self.gears = gears
print('Color is : {}'.format(self.color)) # Prints when constructor is called
print('Number of gears: {}'.format(self.gears))
car1 = Car('Yellow', 5) # Create a new instance of Car
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment