Beispiel #1
0
def main():

    limo = Car("Limo", 100)
    limo.add_fuel(20)
    limo.drive(115)
    print("fuel =",limo.fuel,"\nodo =", limo.odometer)
    print(limo)
Beispiel #2
0
def main():
    bus = Car(180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    print("Car {}, {}".format(bus.fuel, bus.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=bus))
Beispiel #3
0
def main():
    bus = Car(180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    print("Car {}, {}".format(bus.fuel, bus.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=bus))
Beispiel #4
0
def main():
    """Demo test code to show how to use car class."""
    bus = Car(180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    print("Car {}, {}".format(bus.fuel, bus.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=bus))
def main():
    bus = Car(180, 'bus')
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus.name)

    limo = Car(100, 'limo')
    limo.add_fuel(20)
    print("fuel: ", limo.fuel)
    limo.drive(115)
    print("odo: ", limo.odometer)
Beispiel #6
0
def main():
    limo = Car("Limo", 100)
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
    print(limo)
    bus = Car("bus", 180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)
Beispiel #7
0
def main():
    bus = Car(180, "Bus")
    bus.drive(30)

    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(150, "Limo")
    limo.drive(50)
    limo.add_fuel(20)
    print(limo)
Beispiel #8
0
def main():
    # car2 = Car("sports car", 200)
    # car2.drive(155)
    # print("fuel =", car2.fuel)
    # print("odo =", car2.odometer)

    limo = Car("Limo", 100)
    limo.add_fuel(20)
    limo.drive(115)
    print("fuel =", limo.fuel)
    print("odo =", limo.odometer)
    print(limo)
Beispiel #9
0
def main():
    bus = Car("bus", 180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car("limo", 120)
    limo.drive(115)
    print("fuel =", limo.fuel)
    print("odo =", limo.odometer)
    print(limo)
def main():
    """Demo test code to show how to use car class."""

    bus = Car('bus', 180)
    bus.drive(30)
    limo = Car('limo', 100)
    limo.add_fuel(20)
    limo.drive(115)
    # print("fuel =", bus.fuel, limo.fuel)
    # print("odo =", bus.odometer)
    print(bus)
    # print("{self.name} {self.fuel}, {self.odometer}".format(self=limo))
    print(limo)
Beispiel #11
0
def main():
    """Demo test code to show how to use car class."""
    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)
    print("Car {self.fuel}, {self.odometer}".format(self=limo))
Beispiel #12
0
def main():
    bus = Car(180)
    bus.name = "Bus"
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    limo = Car(100)
    limo.fuel += 20
    limo.name = "Limo"
    limo.drive(115)
    print("fuel =", limo.fuel)
    print("odo =", limo.odometer)
    print(limo)
Beispiel #13
0
def main():
    bus = Car("Bus", 180)
    bus.drive(30)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    print("Car {}, {}".format(bus.fuel, bus.odometer))
    print("{self.name}, {self.fuel}, {self.odometer}".format(self=bus))

    limo = Car("Limo", 100)
    limo.add_fuel(20)
    print("fuel = ", limo.fuel)
    limo.drive(115)
    print("{self.name}, {self.fuel}, {self.odometer}".format(self=limo))
Beispiel #14
0
def main():
    bus = Car(180)
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    print("Car {}, {}".format(bus.fuel, bus.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=bus))

    limo = Car("limo", 100)
    limo.add_fuel(20)
    print("fuel =", limo.fuel)
    limo.drive(115)
    print("odo =", limo.odometer)
    print(limo)
Beispiel #15
0
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("{self.name} {self.fuel}, {self.odometer}".format(self=bus))
    print("{self.name} {self.fuel}, {self.odometer}".format(self=limo))
Beispiel #16
0
def main():
    """Demo test code to show how to use car class."""
    # bus = Car(180)
    # bus.drive(30)
    # print("fuel =", bus.fuel)
    # print("odo =", bus.odometer)
    # print(bus)
    # print("Car {}, {}".format(bus.fuel, bus.odometer))
    # print("Car {self.fuel}, {self.odometer}".format(self=bus))
    limo = Car('Limo', 100)

    limo.fuel += 20
    print("{} has {self.fuel} fuel".format(limo.name, self=limo))
    limo.drive(115)
    print("{} has driven {self.odometer}".format(limo.name, self=limo))
    print(limo)
Beispiel #17
0
def main():
    """Demo test code to show how to use car class."""
    # bus = Car(180)
    # bus.drive(30)
    # print("fuel =", bus.fuel)
    # print("odo =", bus.odometer)
    # print(bus)
    #
    # print("Car {}, {}".format(bus.fuel, bus.odometer))
    # print("Car {self.fuel}, {self.odometer}".format(self=bus))

    limo = Car("name", 200)
    limo.add_fuel(20)
    limo.drive(115)
    # print("fuel =", limo.fuel)
    # print("odo =", limo.odometer)
    print(limo)
Beispiel #18
0
def main():
    """Demo test code to show how to use car class."""
    bus = Car(180)
    bus.drive(30)
    bus.name = "Bus 1"
    print("fuel =", bus.fuel)
    print("odo =", bus.odometer)
    print(bus)

    print("Car {}, {}".format(bus.fuel, bus.odometer))
    print("Car {self.fuel}, {self.odometer}".format(self=bus))

    limo = Car(100)
    limo.add_fuel(20)
    limo.name = "Limo 1"
    print("Limo fuel: {}".format(limo.fuel))
    limo.drive(115)
    print("Limo odo: {}".format(limo.odometer))
Beispiel #19
0
def run_tests():
    # assert test with no message - used to see if the function works properly
    assert repeat_string("Python", 1) == "Python"
    # the test below should fail
    assert repeat_string("hi", 2) == "hi hi"

    # Hint: "-".join(["yo", "yo"] -> "yo-yo"

    # assert test with custom message - used to see if Car's init method sets the odometer correctly
    # this should pass (no output)
    test_car = Car()
    assert test_car.odometer == 0, "Car does not set odometer correctly"
    assert test_car.fuel == 0

    test_car = Car(fuel=20)
    assert test_car.fuel == 20

    test_car.drive(15)
    assert test_car.odometer == 15