当前位置: 首页>>代码示例>>Python>>正文


Python Car.drive方法代码示例

本文整理汇总了Python中car.Car.drive方法的典型用法代码示例。如果您正苦于以下问题:Python Car.drive方法的具体用法?Python Car.drive怎么用?Python Car.drive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在car.Car的用法示例。


在下文中一共展示了Car.drive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: limo

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def limo():
    limo=Car(100,"limo")
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
    print(limo)
开发者ID:alvinyeonata,项目名称:CP1404,代码行数:9,代码来源:usedcars.py

示例2: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    limo = Car(100,  "abc")
    limo.add_fuel(20)
    print("fuel = ", limo.fuel)
    limo.drive(115)
    print("odometer = ", limo.odometer)
    print(limo)
开发者ID:rohitchahal,项目名称:classes,代码行数:9,代码来源:modifiedcars.py

示例3: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    limo = Car("limo", 180)
    limo.add_fuel(30)
    limo.drive(115)

    print("limo odometer", limo.odometer)
    print("limo fuel:", limo.fuel)
    print("{}, fuel={}, odometer={}".format(limo.name, limo.fuel, limo.odometer))
开发者ID:MatthewChilcott,项目名称:1404_pracs,代码行数:10,代码来源:usedcars.py

示例4: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car(180, "Bus")
    bus.drive(30)
    print(bus)

    limo = Car(100,"Limo")
    limo.add_fuel(20)
    limo.drive(115)
    print(limo)
开发者ID:NathanaelNeria,项目名称:workshop1404,代码行数:11,代码来源:usedcars.py

示例5: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car("bus",180)
    bus.drive(30)
    print(bus)

    limo = Car("limo", 100)
    limo.add_fuel(20)
    limo.drive(115)
    print(limo)
开发者ID:HariDharmawan,项目名称:CP1404_Practical,代码行数:11,代码来源:usedcars.py

示例6: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car(180)
    bus.drive(30)
    print("bus fuel =", bus.fuel)
    print("bus odo =", bus.odometer)
    print(bus)
    limbo = Car(100)
    limbo.fuel += 20
    print("limbo fuel =", limbo.fuel)
    limbo.drive(115)
    print("limbo obo =", limbo.odometer)
开发者ID:AlexCSilva,项目名称:CP1404-Practicals-2016,代码行数:13,代码来源:usedcars.py

示例7: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car("Bus", 180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)
    limo = Car("Limo", 100)
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
开发者ID:LukeRibbons,项目名称:Workshops,代码行数:13,代码来源:usedcars.py

示例8: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    # bus = Car(180)
    # bus.drive(30)
    # print("fuel =", bus.fuel)
    # print("odo =", bus.odometer)
    # print(bus)

    limo = Car(100)
    limo.add_fuel(20)
    print("limo's fuel = {}".format(limo.fuel))
    limo.drive(115)
    print("limo's odometer = {}".format(limo.odometer))
开发者ID:alvinyeonata,项目名称:CP1404-1,代码行数:14,代码来源:usedcars.py

示例9: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car(180, "bus")
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(100, "limo")
    limo.add_fuel(20)
    print("fuel=", limo.fuel)
    limo.drive(115)
    print("odometer=", limo.odometer)
    print(limo)
开发者ID:fadnihdr,项目名称:CP1404_workshopW8,代码行数:15,代码来源:usedcar.py

示例10: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car(180,'Bus')
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(100,'Limo')
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
    print(limo)
开发者ID:charliekristiawan,项目名称:CP1404-Workshop,代码行数:15,代码来源:usedcars.py

示例11: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car(180, "Bus")
    bus.drive(30)
    # print("fuel =", bus.fuel)
    # print("odo =", bus.odometer)
    print(bus)

    limo = Car(100, "Limo")
    limo.add_fuel(20)
    # print("fuel = ", limo.fuel)
    limo.drive(115)
    # print("fuel after drive = ", limo.fuel)
    # print("odo = ", limo.odometer)
    print(limo)
开发者ID:KyeCook,项目名称:Classes_Workshop8,代码行数:16,代码来源:usedCars.py

示例12: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    # create an instance of a Car with an initial fuel value of 100
    car = Car(100)
    
    print("Let's drive!")
    print(car)
    print(MENU)
    choice = input("Enter your choice: ").lower()
    while choice != "q":
        if choice == "d":
            distanceToDrive = int(input("How many km do you wish to drive? "))
            distanceDriven = car.drive(distanceToDrive)
            print("The car drove " + str(distanceDriven) + "km", end="")
            if car.getFuel() == 0:
                print(" and ran out of fuel", end="")
            print(".")
        elif choice == "r":
            fuelToAdd = int(input("How many units of fuel do you want to add to the car? "))
            while fuelToAdd < 0:
                print("Fuel amount must be >= 0")
                fuelToAdd = int(input("How many units of fuel do you want to add to the car? "))
            car.addFuel(fuelToAdd)
            print("Added", fuelToAdd, "units of fuel.")
        else:
            print("Invalid choice")
        print()
        print(car)
        print(MENU)
        choice = input("Enter your choice: ").lower()
    print("\nGood bye!")
开发者ID:AlexCSilva,项目名称:CP1200Practicals2015,代码行数:32,代码来源:prac10Classes.py

示例13: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car(100)
    bus.drive(40)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(1500)
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    print("odo =", limo.odometer)
    print(limo)

    limo2 = Car(19)
    limo2.drive(115)
    print("odo =", limo2.odometer)
    print(limo2)
开发者ID:JacobNegri,项目名称:prac_7,代码行数:19,代码来源:usedcars.py

示例14: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    bus = Car(180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)
开发者ID:ParisWei,项目名称:1404workshop,代码行数:8,代码来源:workshop7.usedcars.py

示例15: main

# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import drive [as 别名]
def main():
    limo = Car(100)
    limo.fuel += 20
    limo.drive(115)
    print(limo)
开发者ID:DevanKula,项目名称:CP5632_Workshops,代码行数:7,代码来源:usedcar2.0.py


注:本文中的car.Car.drive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。