class Car():
def __init__(self,make,model,year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 20
def get_descriptive_name(self):
long_name = str(self.year) + ' ' + self.make + ' ' + self.model
return long_name.title()
def read_odometer(self):
print("This car has " + str(self.odometer_reading) + " miles on it")
def update_odometer(self,miles):
if miles >= self.odometer_reading:
self.odometer_reading = miles
else:
print("You can't roll back an odometer")
def increment_odometer(self,miles):
self.odometer_reading += miles
def fill_gas_tank(self):
print("you should fill_gas_tank")
class ElectricCar(Car):
def __init__(self,make, model, year):
super(
相关文章
- 10-10Python 虚拟环境virtualenv的安装和基本使用
- 10-10python-用底部编辑线,状态栏和滚动历史记录实现“控制台外壳”的最佳方法?
- 10-10LevelDB的错误处理和Status类
- 10-10python之路--模块和包
- 10-10Python-类和对象(__new__,__init__,classmethod)
- 10-10Python 中 plt 画柱状图和折线图
- 10-10在python中,将日志记录和ncurses转到单独的TTY
- 10-10****** 五十 ******、软设笔记【UML分析和意义】-类图、对象图、状态图、活动图、顺序图、协作图、构件图、部署图,动静态模式
- 10-10python入门17 类和对象
- 10-10python – map()和imap()如何在gevent.pool.Pool中工作?