Question: look at the TODO comments add in the requested functionality do not modify existing code only add code where there are the TODO comments -------------------

look at the TODO comments

add in the requested functionality do not modify existing code only add code where there are the TODO comments

-------------------

class Car: def __init__(self,*x): if len(x)!=3: raise Exception("NOT CREATED CORRECTLY") self.mpg=x[0] self.tankCapacity = x[1] self.currGas = x[2]

def travelMiles(self, miles): possDist = self.mpg*self.currGas if possDist < miles: print("YOU BROKE DOWN...OUT OF GAS") self.currGas = 0 else: self.currGas -= miles / self.mpg print("You traveled {} miles".format(miles))

# TODO: Add in refuel car function, that fills the tank to capacity

def __str__(self): return "Car ({}) {}/{} gallons".format(self.mpg,self.currGas,self.tankCapacity)

def main(): pass # TODO ADD CODE HERE # Ask the user for the tank size of their car and its mpg rating, create an instance of that car and make sure the tank is full (DO NOT USE REFUEL FUNCTION, initialize as full) # Travel 5 miles # Print out the car in the format: Car () currentfuel/capacity example: "Car (30) 7/18 gallons" # Refuel Tank # Travel 1000 miles # Print out the car in the format: Car () currentfuel/capacity example: "Car (30) 7/18 gallons"

if __name__=="__main__": main()

------------------------

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!