Hello,
I'm new to python and I am trying to convert metres to feet and inches. I could't print out the right answer..
FEET_PER_METRE = 3
INCHES_PER_FOOT = 12
metre = int(input("Please enter a number in metre: "))
length_imp = FEET_PER_METRE * metre
length_metric = length_imp * INCHES_PER_FOOT
print("equals", length_imp, "feet", length_metric, "inches")
Thanks!
Metric to imperial 
0  Chanamon Chaiyakul · July 30, 2015 
Post a Reply 
Replies 
Oldest Newest Rating 
0 
Pavel Dimi
· July 30, 2015
I guess you mean something like this ?

0 
Chanamon Chaiyakul
· August 1, 2015
Thank you for your help Pavel! I'm still trying to understand this part of the code:
" remaining_inches_to_feet = length_in_feet_and_inches\ % int(length_in_feet_and_inches) length_in_inches = remaining_inches_to_feet * INCHES_PER_FOOT length_in_inches = round(length_in_inches, 2) length_in_feet = int(length_in_feet_and_inches) print("Equals {} feet {} inches".format(length_in_feet, length_in_inches)) " Can this part of the code be made any shorter or is this as short as it gets? Can I use other function instead of round() 
0 
Chanamon Chaiyakul
· August 1, 2015
I'm just having trouble understanding this particular line:
remaining_inches_to_feet = length_in_feet_and_inches\ % int(length_in_feet_and_inches) Thanks! 
0 
Pavel Dimi
· August 2, 2015
The
is pretty much when you have the feet and inches like 6.55 which is 6 feet and 0.55 of a feet you just get the remainder 0.55 by doinga moduls devision its like 6.55 devided by int(6.55) wihch is 6 so it is 6.55%6 whichi is 0.55 if you dont know modulous division look it up. And yes it can be written shorter but in the sense of making it a bit more logicali separated i wrote it like this. It is a simpe computiation. The round function is used just to drop some of the numbers like 6.66666666 is now 6.66 
0 
Halcyon Abraham Ramirez
· August 2, 2015
if you wanted a function here they are
if not then here is a simple version: 
0 
Chanamon Chaiyakul
· August 3, 2015
Thank you to both of you!

 1