你如何在Python中转换英寸和密斯之间的距离? [英] How do you convert distances between inches and mies in Python?
问题描述
我必须为我的任务做这个,但我需要帮助!我已经尝试输入我的信但是它不起作用请告诉我我做错了什么或者做不出来似乎无法弄明白。
这个程序将转换距离(英寸/英里)
Ehter(I)将英寸转换为里程
输入(M)将里程转换为英寸
输入选择:我
输入转换距离:115
115.0英寸相当于0.00181502英里。然后
此程序将转换距离(英寸/英里)
输入(I)转换为里程
输入(M)将里程转换为英寸
输入选择:N
请输入'我'或'M':R
我尝试了什么:
这就是我所做的全部
tterinteger =我
d_ft = int(输入(输入(I)将英寸转换为英里:))
d_miles = d_ft / 5280.0
d_yards = d_ft / 3.0
print(以英寸为单位的距离为%i英寸。 %d_inches
print(码距离是%.2f码。%d_yards)
print(以英里为单位的距离是%.2英里。 %d_miles)
12345678
您要求以英寸为单位输入,并将其视为以英尺为单位进行处理。 。
试试这个:
d_inches = int(输入( < span class =code-string>输入英寸转换:))
d_ft = d_inches / 12 。 0
d_miles = d_ft / 5280 。 0
d_yards = d_ft / 3 。 0
print ( 以英寸为单位的距离为%i英寸。 %d_inches)
print ( 以英尺为单位的距离是%.1f英尺。%d_ft)
print ( 码数距离为.2f码。%d_yards)
print ( 以英里为单位的距离是%.6英里。%d_miles)集团kquote>
这是转换的乘法表集。重复小数由小数结尾处的 - 表示
英寸英尺码数
_____ ________ _______ ___________
1 0.0833- 0.0277- 0.000015782
12 1 0.33- 0.000189394
36 3 1 0.0005681-
63360 5280 1760 1
Hi I have to do this for my assignment but I need help!. I have tried entering the letter I but it doesn't work please tell me what am doing wrong or didn't do cant seem to figure it out.
This program will convert distances (Inches/Miles)
Ehter (I) to convert Inches to miles
Enter (M) to convert Miles to Inches
Enter selection: I
Enter distance to convert: 115
115.0 Inches equals 0.00181502 Miles. then
This program will convert distances (inches/miles)
enter (I) to convert to Miles
enter (M) to convert miles to inches
enter selection: N
Please enter 'I' or 'M': R
What I have tried:
this is all I have done
tterinteger = I
d_ft = int(input("Enter (I) to convert Inches to Miles: "))
d_miles = d_ft / 5280.0
d_yards = d_ft / 3.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)
12345678解决方案You are asking for an input in inches, and treating it as if it was in feet...
Try this:
d_inches = int(input("Enter Inches to convert: ")) d_ft = d_inches / 12.0 d_miles = d_ft / 5280.0 d_yards = d_ft / 3.0 print("The distance in inches is %i inches." % d_inches) print("The distance in feet is %.1f feet." % d_ft) print("The distance in yards is %.2f yards." % d_yards) print("The distance in miles is %.6f miles." % d_miles)
Here is the multiplication table set for conversions. Repeating decimals are signified by a - at the end of the decimal
inch feet yard mile _____ ________ _______ ___________ 1 0.0833- 0.0277- 0.000015782 12 1 0.33- 0.000189394 36 3 1 0.0005681- 63360 5280 1760 1
这篇关于你如何在Python中转换英寸和密斯之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!