#------------------------------------------------------------ #Student: Austin Wells #Class: CIS122 #Date: 6/5/2015 #Program Title: Chapter 14 Programming Excercise 2.py #(Car class) #Program Description: This function solves Ackermann's Function # ------------------------------------------------------------ class Car: def __init__(self, yearModel, make): self.yearModel = yearModel self.make = make self.speed = 0 def getYear(self): return self.year def getMake (self): return self.make def getSpeed (self): return self.speed def accelerate(self): self.speed += 5 def brake(self): self.speed -= 5 def userInput (inputStr): input = raw_input (inputStr) print(input + "\n") return input def main(): car = Car(userInput ("Please enter the year model of the car: "),userInput("Please enter the make of the car: ")) for i in range (0,5): car.accelerate() print (car.getSpeed ()) for n in range (0,5): car.brake() print (car.getSpeed()) main ()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question