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, fuel = {self.fuel}, odometer = {self.odometer}".format( self=my_car)) limo = Car(100) limo.add_fuel(20) print("Limo's fuel = ", limo.fuel) limo.drive(115) print("limo's odometer reading: ", limo.odometer)
def main(): """Demo test code to show how to use car class.""" my_car = Car("Sedan", 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) limo = Car("Limo", 100) limo.add_fuel(20) print("The Limo has {} units of fuel".format(limo.fuel)) limo.drive(115) print("The Limo's ODO reads {}".format(limo.odometer)) print("Car {}, {}".format(my_car.fuel, my_car.odometer)) print("Car {self.fuel}, {self.odometer}".format(self=my_car)) print("Car has {self.fuel} units of fuel".format(self=my_car)) print(limo) print(my_car)
def main(): """Demo test code to show how to use car class.""" my_car = Car(180, name="Prius") 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, name="Limo") limo.add_fuel(20) print("Amount of fuel in Limo: {self.fuel}".format(self=limo)) limo.drive(115) print(limo)
def main(): """Demo test code to show how to use car class.""" my_car = Car("Ferrari", 180) my_car.drive(30) print("Fuel =", my_car.fuel) print("Odometer =", 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("Lamborghini", 100) limo.add_fuel(20) print("Limo's fuel = {}".format(limo.fuel)) limo.drive(115) print("Limo's odometer = {}".format(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) print('Limo Fuel is:', limo.fuel) limo.drive(115) print('Limo travel distance is:', 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("car fuel =", my_car.fuel) print("limo 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) print(limo)
def main(): """Demo test code to show how to use car class.""" my_car = Car("My car", 319) my_car.drive(277) 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("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("{} fuel = {}".format(limo.name, limo.fuel)) limo.drive(115) print("{} odometer = {}".format(limo.name, limo.odometer)) print(limo)
def main(): """Demo test code to show how to use car class.""" limo = Car(100, "Limo") # Add a car object with 100 units of fuel limo.add_fuel(20) # Add 20 more units of fuel to the new car print("Limo fuel = {}".format(limo.fuel)) # Print the amount of fuel in the limo limo.drive(115) # Drive limo 115 km print("Limo odo = {}".format(limo.odometer)) # Print the odometer of the limo print(limo) my_car = Car(180, "Beast Wagon") 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(fuel=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(fuel=100, name="Limo") print(limo) 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("The Red Rocket", 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("{} {}, {}".format(my_car.name, my_car.fuel, my_car.odometer)) print("{self.name} {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) print(limo)
def main(): """Demo test code to show how to use car class.""" my_car = Car("Subaru", 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) print(my_car) print("{}, {}, {}".format(my_car.name, my_car.fuel, my_car.odometer)) print("{self.name} {self.fuel}, {self.odometer}".format(self=my_car)) limo = Car("Limo", 100) limo.add_fuel(20) print(f"{limo.name} has {limo.fuel}L of fuel") limo.drive(115) print( "{self.name} odometer reading is {self.odometer}km".format(self=limo)) 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('Limosine', 100) limo.add_fuel(20) print('limo fuel = {}'.format(limo.fuel)) limo.drive(115) print('limo odo = {self.odometer}'.format(self=limo)) print(limo) print(limo.name)
def main(): """Demo test code to show how to use car class.""" my_car = Car("Lindsay's 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.fuel) limo.drive(115) print("Limo Odometer = ", limo.odometer) print("Limo Odometer: {self.odometer} Km".format(self=my_car)) print(limo)
def main(): """Demo test code to show how to use car class.""" 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)) print("Limousine:") limo_car = Car('Limousine', 100) limo_car.add_fuel(20) print('fuel =', limo_car.fuel) limo_car.drive(115) print("odo = ", limo_car.odometer) print(limo_car)
def main(): """Demo test code to show how to use car class.""" my_car = Car("herbie", 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)) name = input("Enter name of car: ") limo = Car(name, 100) limo.add_fuel(20) print("fuel =", limo.fuel) limo.drive(115) print("ode =", 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)) # Modifications limo = Car(100,"My car") limo.add_fuel(20) print("Amount of Fuel =", limo.fuel) limo.drive(115) print("Odometer =", limo.odometer) print(limo)
def main(): """Demo test code to show how to use car class.""" my_car = Car("Ferrari", 180) # Add name to the constructor 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)) """Task 1: Create a new Car object called "limo" that is initialised with 100 units of fuel.""" limo = Car("Limo", 100) # Initialise car object and add name to the constructor limo.add_fuel(20) print(limo.fuel) limo.drive(115) print(limo.odometer) print(limo)
def main(): """Demo test code to show how to use car class.""" print("Car Details") my_car = Car("Car", 180) my_car.drive(30) print("fuel =", my_car.fuel) print("odo =", my_car.odometer) #print("Car {}, {}".format(my_car.fuel, my_car.odometer)) #print("Car {self.fuel}, {self.odometer}".format(self=my_car)) print(my_car) print("\nLimo Details") limo = Car("Limo", 100) limo.add_fuel(20) print("The amount of fuel in the limo is {}".format(limo.fuel)) limo.drive(115) print("The ododmeter of the limo is {}".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)) # Modifications limo = Car("Limo", 00) limo.add_fuel(20) print("Limo fuel: {self.fuel}".format(self=limo)) limo.drive(115) print("Limo odo: {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)) print() limo = Car("Limo", 100) limo.add_fuel(20) print("Fuel in limo is: ", limo.fuel) limo.drive(115) print("Odometer reading for limo is: ", limo.odometer) print(str(limo))
def main(): """Demo test code to show how to use car class.""" my_car = Car(180, "My Car") 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(100, "Limo") limo.add_fuel(20) print("Fuel =", limo.fuel) limo.drive(115) print("Odometer Reading =", 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 Task car1 = Car('Limo', 100) car1.add_fuel(20) print('The limo has {}kms of fuel left'.format(car1.fuel)) car1.drive(115) print('The limo has {}kms clocked on the odometer'.format(car1.odometer)) print(car1)
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("New car added is: ", 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's Fuel: ", limo.fuel) limo.drive(115) print("Limo's Odometer: ", limo.odometer) print(limo)
def main(): print("Let's drive!") name = input("Enter you car name: ") car = Car(name, 100) print(car) menu_choice = display_menu() while True: if menu_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? ")) if car.fuel > distance: car.drive(distance) print("The car drove {}km.\n".format(distance)) else: print("The car drove {}km and ran out of fuel.\n".format( car.fuel)) car.drive(distance) elif menu_choice == "r": amount = int( input( "How many units of fuel do you want to add to the car? ")) while amount < 0: print("Fuel amount must be >= 0") amount = int( input( "How many units of fuel do you want to add to the car? " )) while amount >= 0: print("Added {} units of fuel.\n".format(amount)) break car.add_fuel(amount) elif menu_choice == "q": print("\nGood bye {}'s driver.".format(name)) break else: print("Invalid choice\n") print(car) menu_choice = display_menu()
def main(): print("Let's Drive!") car_name = input("Enter your car name :") car = Car(car_name, 100) print(car) print(MENU) choice = input("Enter your choice :") while choice != "q": if choice == "d": km_drive = int(input("How many km do you wish to drive? \n>>> ")) while km_drive < 0: print("Distance must be >= 0") km_drive = int( input("How many km do you wish to drive? \n>>> ")) distance = car.drive(km_drive) if car.fuel == 0: print( "The car drove {}km and ran out of fuel".format(distance)) else: print("The car drove {}km".format(distance)) elif choice == "r": refuel = int( input( "How many units of fuel do you want to add to the car? \n>>> " )) while refuel < 0: print("Fuel amount must be >= 0") refuel = int( input( "How many units of fuel do you want to add to the car? \n>>> " )) car.add_fuel(refuel) print(" Added {} units of fuel.".format(refuel)) else: print("Invalid choice") print("") print(car) print(MENU) choice = input("Enter your choice :") print("Good bye The {}'s driver.".format(car.name)) sys.exit()
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 has {self.fuel}L fuel left, with {self.odometer}km on the odometer" .format(self=my_car)) limo = Car("Limo", 100) limo.add_fuel(20) print("fuel =", limo.fuel) limo.drive(115) print("odo =", limo.odometer) print(str(limo))
def main(): """Demo test code to show how to use car class.""" 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)) """Added code for practical work""" name = input("PLease enter your name") limo = Car(name, 100) limo.add_fuel(20) print("Limo {}".format(limo.fuel)) limo.drive(115) print("Limo Odometer: {}".format(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)) # print(my_car.fuel) limo = Car('limo', 100) # limo.car_model('limo') limo.add_fuel(20) print('fuel =', limo.fuel) limo.drive(115) print('odo =', limo.odometer) print(limo)
def main(): """Demo test code to show how to use Car class. Create a new Car object called 'limo'""" my_car = Car('my_car', 180) my_car.drive(30) limo = Car('limo', 100) # limo initialised at 100 units of fuel limo.add_fuel(20) # 20 units of fuel added to limo limo.drive(115) # limo driven 115km print("fuel =", my_car.fuel) print("fuel =", limo.fuel) print("odo =", my_car.odometer) print("odo =", limo.odometer) print(my_car) print(limo) print("{} {}, {}".format(my_car.name, my_car.fuel, my_car.odometer)) print("{self.name} {self.fuel}, {self.odometer}".format(self=my_car)) print("{self.name} {self.fuel}, {self.odometer}".format(self=limo))