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 (
if __name__=="__main__": main()
------------------------
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started