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))
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)
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)
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)
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)
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))
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))
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))
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)
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)
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" # 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" # Note that Car's __init__ function sets the fuel in one of two ways: using the value passed in or the default # You should test both of these test_car = Car(fuel=10) assert test_car.fuel == 10, "Car does not set fuel correctly" test_car = Car() assert test_car.fuel == 0, "Car does not set fuel correctly"
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" # TODO: 1. fix the repeat_string function above so that it passes the test # 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" # TODO: 2. write assert statements to show if Car sets the fuel correctly # Note that Car's __init__ function sets the fuel in one of two ways: using the value passed in or the default # You should test both of these test_car = Car(fuel=10) assert test_car.fuel == 10, "Car does not set fuel correctly"
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 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" # Note that Car's __init__ function sets the fuel in one of two ways: using the value passed in or the default # You should test both of these test_car = Car(fuel=10) assert test_car.fuel == 10 test_car = Car() assert test_car.fuel == 0 assert get_sentence('hello') == 'Hello.' assert get_sentence('It is an ex parrot.') == 'It is an ex parrot.' assert get_sentence('this is a phrase') == 'This is a phrase.'
def main(): limo = Car("Limo", 100) limo.add_fuel(20) limo.drive(115) print("fuel =",limo.fuel,"\nodo =", limo.odometer) print(limo)
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" # TODO: 1. fix the repeat_string function above so that it passes the test assert repeat_string1("yo", 2) == "yo-yo" # 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" # TODO: 2. write assert statements to show if Car sets the fuel correctly test_car = Car(fuel=10) assert test_car.fuel == 10 test_car.add_fuel(200) assert test_car.fuel == 210
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)
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)
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)
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
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))