def golimo(): limo = Car("Limo", 100) limo.add_fuel(20) print("Current fuel is {}".format(limo.fuel)) limo.drive(115) print("Odo is {}".format(limo.odometer)) print(limo)
def main(): limo = Car(100, "abc") limo.add_fuel(20) print("fuel = ", limo.fuel) limo.drive(115) print("odometer = ", limo.odometer) print(limo)
def main(): limo = Car(100, "abc") limo.add_fuel(20) print("fuel = ", limo.fuel) limo.drive(115) print("odometer = ", limo.odometer) print(limo)
def limo(): limo=Car(100,"limo") limo.add_fuel(20) print("fuel =", limo.fuel) limo.drive(115) print("odo =", limo.odometer) print(limo)
def main(): limo = Car('limo', 100) limo.add_fuel(20) print(limo.fuel) limo.drive(115) print(limo.odometer) print(limo)
def limo(): limo = Car(100, "limo") limo.add_fuel(20) print("fuel =", limo.fuel) limo.drive(115) print("odo =", limo.odometer) print(limo)
def main(fuel=None): """Demo test code to show how to use car class.""" my_car = Car(180) my_car.drive(30) my_car.car_name = "Ford GT" # -----------------------------------------------------------------# limo = Car(100) # add a limo car, with 100 fuel limo.car_name = "Chrysler 300 Limo" # -----------------------------------------------------------------# print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) # -----------------------------------------------------------------# print("fuel =", limo.fuel) print("odo =", limo.odometer) # print the Car limo's details print(limo) # -----------------------------------------------------------------# limo.add_fuel(20) # add 20 fuel to the limo using add_fuel method # -----------------------------------------------------------------# print("fuel =", limo.fuel) # -----------------------------------------------------------------# limo.drive(115) # drive the car 155km print("fuel =", limo.fuel) # display the fuel and odometer print("odo =", limo.odometer) print(limo) # -----------------------------------------------------------------# # -----------------------------------------------------------------# print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car))
def the_good_stuff(): car_limo = Car("Limo", 100) print(car_limo) car_limo.add_fuel(20) print(car_limo) car_limo.drive(115) print(car_limo)
def main(): """Demo test code to show how to use car class.""" my_car = Car(180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) print( "---------------------------------------------------------------------------" ) limo = Car( "Limo", 100 ) # Create a new Car object called "limo" that is initialised with 100 units of fuel. limo.add_fuel( 20 ) # Add 20 more units of fuel to this new car object using the add method. print("Limo's fuel = ", limo.fuel) # Print the amount of fuel in the car. limo.drive(115) # Attempt to drive the car 115km using the drive method. print("Limo's odometer: ", limo.odometer) # Print the car's odometer reading. print(limo)
def main(): print("Let's drive!") car_name = input("Enter your car name: ") car = Car(car_name) choice = "A" while choice != "Q": print(car) choice = input( "Menu \n (D)rive \n (R)efuel \n (Q)uit \nEnter your choice: " ).upper() if choice == "D": validated = False while not validated: distance = input("How many km do you wish to drive?: ") validated = validate_number_positive(distance) distance = int(distance) car.drive(distance) elif choice == "R": validated = False while not validated: fuel = input( "How many units of fuel do you want to add to the car?: ") validated = validate_number_positive(fuel) fuel = int(fuel) car.add_fuel(fuel) print("Goodbye {}'s driver".format(car_name))
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))
def limo(): my_limo = Car(100) my_limo.add_fuel(20) print("fuel =", my_limo.fuel) my_limo.drive(115) print("odo =", my_limo.odometer) print("Limo") print(my_limo)
def main(): bus = Car(180, "Bus") bus.drive(30) print(bus) limo = Car(100,"Limo") limo.add_fuel(20) limo.drive(115) print(limo)
def main(): bus = Car("bus", 180) bus.drive(30) print(bus) limo = Car("limo", 100) limo.add_fuel(20) limo.drive(115) print(limo)
def main(): bus = Car("bus",180) bus.drive(30) print(bus) limo = Car("limo", 100) limo.add_fuel(20) limo.drive(115) print(limo)
def main(): bus = Car(180, 'bus') bus.add_fuel(20) bus.drive(30) print(bus) limo = Car(120, "limo") limo.drive(115) print(limo)
def main(): my_car = Car("limo", 100) my_car.add_fuel(20) my_car.drive(100) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car))
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)
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)
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('fuel=', limo.fuel) limo.drive(115) print(limo.odometer)
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))
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))
def main(): """Demo test code to show how to use car class.""" my_car = Car(180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) my_limo = Car(100) my_limo.add_fuel(20) print("Limo has {} units of fuel left".format(my_limo.fuel)) my_limo.drive(115) print("Limo's odometer is {}".format(my_limo.odometer))
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)
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)
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)
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)
def main(): bus = Car(180, "Bus") bus.drive(30) print("fuel =", bus.fuel) print("odo =", bus.odometer) print(bus) print('') #adds a blank space between bus and limo limo = Car(100, "Limo") 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.""" my_car = Car(180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) limo = Car(100, "limo") limo.add_fuel(20) limo.drive(115) print("\n", limo)
def main(): """Demo test code to show how to use car class.""" limo = Car("Car", 100) limo.add_fuel(20) print("The car has fuel:", limo.fuel) limo.drive(115) print(limo.odometer) my_car = Car("Car", 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car))
def main(): """Demo test code to show how to use car class.""" my_car = Car(180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) limo = Car("limo", 100) # print('{}'.format(limo.name)) limo.add_fuel(20) print("the amount of fuel in the car is {}".format(limo.fuel)) limo.drive(115) print(" the car's odometer reading is {}".format(limo.odometer))
def main(): my_car = Car(180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) limo = Car("Limo", 100) limo.add_fuel(20) print(limo.fuel) limo.drive(115) print(limo.odometer)
def main(): """Demo test code to show how to use car class.""" # my_car = Car(180, "Porsche") # my_car.drive(30) # print("fuel =", my_car.fuel) # print("odo =", my_car.odometer) # print(my_car) # # print("Car {}, {}".format(my_car.fuel, my_car.odometer)) # print("Car {self.fuel}, {self.odometer}".format(self=my_car)) """"" Demo Limo Car """ limo = Car(100, "Porsche") limo.add_fuel(20) print("The amount of fuel in the car : {} ".format(limo.fuel)) limo.drive(115) print("The car's odometer : {}".format(limo.odometer)) print(limo)
def main(): """Demo test code to show how to use car class.""" my_car = Car("My Car", 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) Limo = Car("Limo", 100) Limo.add_fuel(20) Limo.drive(115) print("Limo Fuel: {}".format(Limo.fuel)) print("Limo Distance: {}".format(Limo.odometer)) print(Limo)
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)
def main(): """Demo test code to show how to use car class.""" my_car = Car('my car', 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) limo = Car('limo', 100) limo.add_fuel(20) print('Limo {self.fuel}'.format(self=limo)) limo.drive(115) print('limo {self.odometer}'.format(self=limo)) print(limo)
def main(): """Demo test code to show how to use car class.""" my_car = Car("My Car", 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) limo = Car("Limo", 100) limo.add_fuel(20) print("Limo fuel = {}".format(limo.fuel)) limo.drive(115) print("Limo's odometer after driving = {}".format(limo.odometer)) print("Limo's fuel after driving = {}".format(limo.fuel)) print(limo)
def main(): """Demo test code to show how to use car class.""" my_car = Car("Lamborghini", 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) limo = Car("Ferrari", 100) limo.add_fuel(20) limo.drive(115) print(limo.fuel) print(my_car.odometer) print(limo)
def main(): print("Let's drive!") name = input("Enter your car name:") car = Car(name, 100) print(car) print("""Menu: d) drive r) refuel q) quit""") choice = input("Enter your choice:").lower() while choice != "q": if choice == "d": distance = int(input("How many km do you wish to drive? ")) while distance < 0: print("Distance must be >= 0") distance = int(input("How many km do you wish to drive? ")) distance = car.drive(distance) if distance < car.fuel: print("The car drove {}km.".format(distance)) else: print( "The car drove {}km and ran out of fuel.".format(distance)) elif choice == "r": fuel_added = int( input("How many units of fuel do you want to add to the car?")) while fuel_added < 0: print("Fuel amount must be >= 0") fuel_added = int( input( "How many units of fuel do you want to add to the car?" )) car.add_fuel(fuel_added) print("Added {} units of fuel.".format(fuel_added)) else: print("Invalid choice") print() print(car) print("""Menu: d) drive r) refuel q) quit""") choice = input("Enter your choice: ").lower() print() print("Good bye {}'s driver.".format(car.name))
def main(): """Demo test code to show how to use car class.""" my_car = Car("mazda", 80) my_car.drive(30) limo = Car("ford", 100) limo.add_fuel(20) print("fuel = ", limo.fuel) limo.drive(115) print("odometer reading = ", limo.odometer) print(limo) print("make = {}, fuel = {}, odometer reading = {}".format( limo.name, limo.fuel, limo.odometer)) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car))