Car Class
Problem Statement
Suggest Edit
Problem Statement
The first line of input contains a single integer representing noOfGear.
The second line of input contains a string without any preceding and trailing spaces, denoting the color of the car.
The third line of input contains a single Integer representing maxSpeed.
The first line of output prints the number of gears in the car
The second line of output prints the color of the car.
The third line of output prints the maximum speed of the car.
5
red
1000
noOfGear: 5
color: red
maxSpeed: 1000
When we call the printInfo function, all the info related to the car will be printed the same as the above format.
from sys import stdin class Car: def __init__(self,noOfGear,color): self.noOfGear=noOfGear self.color=color def printCarInfo(self): print('noOfGear: ',noOfGear) print('color: ',color) #Write your constructor and printCarInfo method here. class RaceCar(Car): def __init__(self,noOfGear,color,maxSpeed): super().__init__(noOfGear,color) self.maxSpeed=maxSpeed def printRaceCarInfo(self): print('noOfGear: ',self.noOfGear) print('color: ',self.color) print('maxSpeed: ',self.maxSpeed) #Write your constructor and printRaceCarInfo method here. c=RaceCar(input(),input(),input()) c.printRaceCarInfo()
Comments
Post a Comment