2018年1月9日 星期二

Python: Convert the distance (in feet) to inches, yards, and miles

Python: Convert the distance (in feet) to inches, yards, and miles

Python Basic: Exercise-61 with Solution

Write a Python program to convert the distance (in feet) to inches, yards, and miles.
Sample Solution :-
d_ft = int(input("Input distance in feet: "))
d_inches = d_ft * 12
d_yards = d_ft / 3.0
d_miles = d_ft / 5280.0

print("The distance in inches is %i inches." % d_inches)
print("The distance in yards is %.2f yards." % d_yards)
print("The distance in miles is %.2f miles." % d_miles)

========== RESTART: F:/Python_APSC/py-ex-basic-61.py ==============
Input distance in feet: 1245
The distance in inches is 14940 inches.
The distance in yards is 415.00 yards.
The distance in miles is 0.24 miles.
>>> 

沒有留言:

張貼留言

OPEN DATA AQI 空氣品質監測網 + NODE-RED

OPEN DATA AQI 空氣品質監測網 + NODE-RED  首頁 - 空氣品質監測網  https://airtw.moenv.gov.tw/ https://data.gov.tw/datasets/search?p=1&size=10&s=_score...