4. Implement a class, Car, which represents a car and can simulate its fuel usage. The fuel
efficiency should be specified when the object is created. The class should contain the following.
Constructor - init_(self, efficiency) Instance Variables - fuelEfficiency fuel efficiency (measured
in km/ litres); float - fuel amount of gas in tank (litres) with an initial value of zero; float
Methods - drive (distance) -simulates driving the car for certain distance, reducing the fuel level
in the gas tank based on the fuel efficiency - getGaslevel() - returns the current fuel level -
addGas (amount) adds amount to instance variable fuel

4. Implement a class, Car, which represents a car and can simulate it.pdf

  • 1.
    4. Implement aclass, Car, which represents a car and can simulate its fuel usage. The fuel efficiency should be specified when the object is created. The class should contain the following. Constructor - init_(self, efficiency) Instance Variables - fuelEfficiency fuel efficiency (measured in km/ litres); float - fuel amount of gas in tank (litres) with an initial value of zero; float Methods - drive (distance) -simulates driving the car for certain distance, reducing the fuel level in the gas tank based on the fuel efficiency - getGaslevel() - returns the current fuel level - addGas (amount) adds amount to instance variable fuel