Answer to Question #81708 in Python for Robert Ruiz

Question #81708
Write a program that inputs the length of two pieces of fabric in feet and inches (as whole numbers) and prints the total.

Enter the Feet for the first piece of fabric: 3
Enter the Inches for the first piece of fabric: 11

Enter the Feet for the second piece of fabric: 2
Enter the Inches for the second piece of fabric: 5
It displays:

Feet: 6 Inches: 4
HOW TO GET THE RIGHT CODE???

print ("Enter the Feet for the first piece of fabric: 11")
print ("Enter the Inches for the first piece of fabric: 11")
print ("Enter the Feet for the second piece of fabric: 5")
print ("Enter the Inches for the second piece of fabric: 5")
print ("Feet: 17 Inches: 4")
print ("Enter the Feet for the first piece of fabric: 4")
print ("Enter the Inches for the first piece of fabric: 5")
print ("Enter the Feet for the second piece of fabric: 7")
print ("Enter the Inches for the second piece of fabric: 6")
print ("Feet: 11 Inches: 11")
1
Expert's answer
2018-10-05T15:02:12-0400

a_ft = int(input("Enter the Feet for the first piece of fabric: "))

a_inc = int(input("Enter the Inches for the first piece of fabric: "))

b_ft = int(input("Enter the Feet for the second piece of fabric: "))

b_inc = int(input("Enter the Inches for the second piece of fabric: "))


sum_inc = a_inc + b_inc


# select the whole and the fractional part

inc_to_ft = sum_inc // 12

rem_from_div = sum_inc % 12


sum_ft = a_ft + b_ft + inc_to_ft


print("Feet: {} Inches: {}".format(sum_ft, rem_from_div))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS