Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Car:
- #A class to store car details
- def __init__(self, engineSize, colour, make):
- self.engineSize = engineSize
- self.colour = colour
- self.make = make
- self.model = ''
- def getModel(self):
- if self.make == "Ford":
- model = "Fiesta"
- elif self.make == "VW":
- model = "Polo"
- elif self.make == "Renault":
- model = "Clio"
- else:
- model = "Old heap"
- return (model)
- # newCar is an instance of Car
- engineSize = input("What is engine size?")
- colour = input("What is colour?")
- make = input("What is make?")
- newCar = Car(engineSize, colour, make)
- print("Engine size; ", newCar.engineSize)
- print("Colour: ", newCar.colour)
- print("Make: ", newCar.make)
- newCar.model = newCar.getModel()
- print("Your model is", newCar.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement