In variable y
I want to call only the second value i.e age
while keeping the first value (height
) as the default. How do I do that?
class person():
def __init__(self, height=130, age=20):
self.height = height
self.age = age
def convert_height(self):
return self.height / 10
def find_birth_year(self, p_year):
return p_year - self.age
x = person(170)
y = person(, 32) # How to have default value for height here?
print(x.height, x.age)
print(y.height, y.age)
print(x.convert_height(), x.find_birth_year(2020))
print(y.convert_height(), y.find_birth_year(2020))