Question: in python program The United States measures weights in pounds and ounces, where 1 pound == 16 ounces. Write a class Weight to support the

in python program The United States measures weights in pounds and ounces, where 1 pound == 16 ounces. Write a class Weight to support the following operations: print(Weight(1, 0)) # prints 1.0 pounds 0.0 ounces print(Weight(1, 16)) # prints 2.0 pounds 0.0 ounces print(Weight(0, 37)) # prints 2 pounds 5 ounce w1 = Weight(1, 12) w2 = Weight(2, 11) print(w1 + w2) # prints 4 pounds 7 ounces Hints: define __str__(self) and __add__(self, other) methods 13 % 12 == 1(mod) 25 // 12 == 2 (floor division)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!