Python Classes

After doing the project on python classes, I modified the code which I did in the lesson. In this modified code, the user will be able to give an input and will get the desired result.
The code is mentioned below.

class Car(object):
condition = “new”
def init(self,color,brand,mpg):
self.color = color
self.brand = brand
self.mpg = mpg
def display_car(self):
print(“This is a %s %s of %s MPG” %(self.color, self.brand, self.mpg))
def sec_alternate(self):
self.condition = “used”
class Electric_Car(Car):
def init(self,color,brand,mpg,battery_type):
self.color = color
self.brand = brand
self.mpg = mpg
self.battery_type = battery_type
def display_car(self):
print(“This is a %s %s of %s MPG of the battery type %s.” % (self.color, self.brand, self.mpg,self.battery_type))
def selections():
color = input(“Choose a color:”)
brand = input(“Choose a brand:”)
mpg = input(“Choose the mpg:”)
battery_type = input(“Select the battery_type:”)


(sorry no intendation, I don’ t know how to do it )
The above code is the modified version of the code in this webpage: .*

I will be very thankful if I get suggestions and feedbacks about this code.


Floors me how this is still not fixed to match the movie, “Back to the Future”. The escape speed was 88 MPH, which would have made this lesson fun and more meaningful. As it stands, all meaning is lost because the connection was never established.

1 Like

I don’t get what you are saying. It would be better if you give a better a better explanation of it.

Hi @jyotishkaaich,

For advice on formatting posted code so that its indentation is visible, see How to ask good questions (and get good answers).

The semicolon within this line breaks it into two statements:


Was that line intended as an assignment statement?

The DeLorean

For the context of the car in this Codecademy course, see the video Back To The Future [1985] - The DeLorean.

Thanks to @mtf for bringing this up.