Advertisement
Atyeo

Class methods

Dec 9th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. class Car(object):
  2.     condition = "new"
  3.     def __init__(self, model, color, mpg):
  4.         self.model = model
  5.         self.color = color
  6.         self.mpg = mpg
  7.  
  8.     def displayCar(self, model, color, mpg):
  9.         self.mpg = str(self.mpg)
  10.         print "This is a " + self.color + " " + self.model + " with " + self.mpg + " MPG."
  11.  
  12. myCar = Car("DeLorean", "silver", 88)
  13. print myCar.displayCar()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement