Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This code should be in PYTHON please. Implement the class Car with the following

ID: 3833148 • Letter: T

Question

This code should be in PYTHON please.

Implement the class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon) and a certain amount of fuel in the gas tank. The efficiency should be specified upon instantiation, and the initial fuel level should be zero. Supply a method called drive that simulates driving the car for a certain distance, which reduces the fuel level in the gas tank. If the car is unable to drive the specified distance, this method should return False. Otherwise, drive should return True. Additionally, supply a method called get_gas_level to return the current fuel level and a method called add_gas to add fuel back to the tank. An example of these methods in use is as follows:

hybrid-car Car (50) 50 miles per gallon. hybrid-car add-gas (20) Add 20 gallons o fuel f if hybrid-car drive 100 Drive 100 miles print hybrid-car .get-gas-level Display remaining fuel else print "Not enough gas!"

Explanation / Answer

class car:
def __init__(self,e):
self.effi=e
self.fuel=0
  
def drive(self,dist):
if(dist/self.effi>self.fuel):
return False
self.fuel-=dist/self.effi
return True
  
def get_gas_level(self):
return self.fuel
  
def add_gas(self,gas):
self.fuel+=gas
  
  
  
#testing

hc=car(50)
hc.add_gas(20)
if hc.drive(100):
print (hc.get_gas_level())
else:
print ("not enough gas")