0

why is it not working?

class vehicle : def __init__(self, nof, lenght) : self.nof = nof self.length = lenght def wcap(self): n = self.nof l = self.lenght return n * l * 100 class bus(vehicle) : def __init__(self, length): super().__init__(length ,length) class car(bus): def __init__(self, length): super().__init__(length, length) def maxpass(self) : a = self.lenght return a *3 class mc(vehicle) : def maxspeed(self): l = self.length n = self.nof return (l * n)**3 class bike(mc) : def intro(self): return "Bikes are mcs without the heavy engine!" a = car(1,2)

30th Apr 2022, 3:28 AM
Lenoname
11 ответов
+ 2
I am not sure why, but like this it runs without errors, class car(bus): def __init__(self, length): super().__init__(length) I think because class bus has only one argument, class car should init with only one.
30th Apr 2022, 7:09 AM
Paul
Paul - avatar
+ 6
Car takes one parameter Car inherits from bus. Bus init must be called with one parameters. Bus inherits from vehicle and vehicle init must be called with 2 parameters.
30th Apr 2022, 7:28 AM
Oma Falk
Oma Falk - avatar
+ 4
Car only takes one parameter, the length. You supply 2
30th Apr 2022, 5:06 AM
Slick
Slick - avatar
+ 3
You should put the code here. I have no idea what you're doing
30th Apr 2022, 6:32 AM
Slick
Slick - avatar
+ 3
Correct the spelling of length in the 2nd and 4th lines of your codes
1st May 2022, 8:43 PM
Sobola Gabriel
Sobola Gabriel - avatar
+ 1
Put it in Code Playground and run there. It will show the errors. Plus, link your code in the question. This way, others can test it and possible solutions.
30th Apr 2022, 11:58 AM
Emerson Prado
Emerson Prado - avatar
+ 1
Me too. Python code is not worked...
1st May 2022, 10:33 AM
Chris
0
Slick Got error with one also
30th Apr 2022, 6:27 AM
Lenoname
0
For “length” you keep misspelling until class bus(vehicle) :, and did you mean “not” for “nof”?
1st May 2022, 6:42 PM
THA
THA - avatar
0
Lenoname Understand that "Is not working" and "got error" describe the problem in a way that leaves everyone else in a position to only guess. Pls explain what is not right. Do you get errors? So pls tell which ones. The output is not as expected? Which are the expected and actual outputs? Also, include in your question a link to your code in Code Playground. It helps debugging. In short: don't make it so hard to help you.
1st May 2022, 7:13 PM
Emerson Prado
Emerson Prado - avatar