Home / Expert Answers / Computer Science / class-duration-def-init-self-hours-minutes-self-hours-hours-self-minutes-minutes-def-pa221

(Solved): class Duration: def __init__(self, hours, minutes): self.hours = hours self.minutes = minutes def __ ...



class Duration: def __init__(self, hours, minutes): self.hours = hours self.minutes = minutes def __add__(self, other): if not isinstance(other, Duration): return 'oops' total_hours = self.hours + other.hours total_minutes = self.minutes + other.minutes if total_minutes >= 60: total_hours += 1 total_minutes -= 60 return Duration(total_hours, total_minutes) one_way_time = Duration(1, 49) round_trip_time = one_way_time + one_way_time print(one_way_time + 33) print(round_trip_time.hours, round_trip_time.minutes)



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe