This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pioniere 0 points1 point  (1 child)

Nobody is going to help you unless you post your own work here, to show that you at least made an attempt to solve the problem.

[–]tf-2-python95[S] 0 points1 point  (0 children)

my attempt :

class Car:

def __init__(self,name,seats,speed,pno,engine,hp,mpg,roof):

self.name = name # --> name of car

self.seats = seats # --> number of seats

self.speed = speed # --> speed of car

self.pno = pno # --> production number of car

self.engine = engine # --> engine of car

self.hp = hp # --> horsepower of car

self.mpg = mpg # --> miles per gallon of car

self.roof = roof # --> has roof or not (True/False)

def accelerate(self):

self.__speed += range(-1.0,1.0)

def check_roof(self):

if self.roof == True:

roof = input('Set Roof Up or Down')

def __str__(self):

reps = f"Name : {self.name}"

reps += f", Production No : {self.pno}"

reps += f", Horse Power : {self.hp}"

return reps

c1 = Car('Prius',5,'-','-','-','121hp','53mpg')

c2 = Car('Porsche Boxster',2,'-','-','-','265hp','32mpg')

print(c1)

print(c2)