Advertisements
Advertisements
Question
Write a program to find sum of two distances with feet and inches.
Code Writing
Advertisements
Solution
Add feet and inches; if inches are 12 or more, convert them into feet.
feet1 = int(input("Enter first distance in feet: "))
inches1 = int(input("Enter first distance in inches: "))
feet2 = int(input("Enter second distance in feet: "))
inches2 = int(input("Enter second distance in inches: "))
feet = feet1 + feet2
inches = inches1 + inches2
if inches >= 12:
feet += inches // 12
inches %= 12
print("Sum of distances =", feet, "feet", inches, "inches")shaalaa.com
Is there an error in this question or solution?
