Hello, @mtf ! Sorry, if my question is stupid or if I’m missing something, I just wanna make sure I got it correctly. For the next example/exercise, we have this example [ Medthods with Arguments > https://www.codecademy.com/paths/computer-science/tracks/cspath-python-objects/modules/cspath-python-classes/lessons/data-types/exercises/methods-with-arguments]:
class DistanceConverter: kms_in_a_mile = 1.609 def how_many_kms(self, miles): return miles * self.kms_in_a_mile converter = DistanceConverter() kms_in_5_miles = converter.how_many_kms(5) print(kms_in_5_miles) # prints "8.045"
1.) Should we not have
return self.miles * self.kms_in_a_mile?
DistanceConverter.miles are the same thing (since
kms_in_a_mile is actually an attribute/class variable of the class DistanceConverter)?
self.example is needed whenever we call elements outside the function/method but inside the class?
3.) Also, why is
class DistanceConverter not having
()? (is this a special case/scenario…?)
Thank you a lot!