Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class Car:
  2.  
  3. #A class to store car details
  4. def __init__(self, engineSize, colour, make):
  5. self.engineSize = engineSize
  6. self.colour = colour
  7. self.make = make
  8. self.model = ''
  9.  
  10. def getModel(self):
  11. if self.make == "Ford":
  12. model = "Fiesta"
  13. elif self.make == "VW":
  14. model = "Polo"
  15. elif self.make == "Renault":
  16. model = "Clio"
  17. else:
  18. model = "Old heap"
  19. return (model)
  20.  
  21.  
  22. # newCar is an instance of Car
  23. engineSize = input("What is engine size?")
  24. colour = input("What is colour?")
  25. make = input("What is make?")
  26. newCar = Car(engineSize, colour, make)
  27. print("Engine size; ", newCar.engineSize)
  28. print("Colour: ", newCar.colour)
  29. print("Make: ", newCar.make)
  30.  
  31. newCar.model = newCar.getModel()
  32. print("Your model is", newCar.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement