#Robert Nool #Car Class #Start class car: def __init__(self, year, make, speed): self.__year = year self.__make = make self.__speed = 0 def get_year(self): return self.year def get_make (self): return self.__make def get_speed (self): return self.__speed def accelerate(self): self.__speed += 5 def brake(self): self.__speed -= 5 year = int(input()) make = raw_input() speed = 0 myCar = car(year, make, speed) print 'What year was your vehicle manufactured?' print year print 'Enter the make of your vehicle:' print make for accel in range(1,6): myCar.accelerate() print '\nAccelaration test {}: {}'. format(accel, myCar.get_speed()) for decel in range(1,6): myCar.brake() print '\nBreak test {}: {}'. format(decel ,myCar.get_speed()) #End
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