Tall

Report a typo

Our height doesn't stay the same throughout our lives: we grow tall while we're kids and grow smaller in the later stages of our lives. Below you can see a class Person with such instance attributes as name and height (in centimeters).

Your task is to add methods for updating the height of a person: __iadd__() and __isub__() for adding and subtracting centimeters from the value of height.

Tip: Don't forget that all magic methods for augmented assignment have something very peculiar about them!

Write a program in Python 3
class Person:
def __init__(self, name, height):
self.name = name
self.height = height

# define your methods here
___

Create a free account to access the full topic