Python-100-Days/Day01-15/code/Day03/conversion.py

17 lines
411 B
Python
Raw Normal View History

2018-03-02 00:09:06 +08:00
"""
英制单位英寸和公制单位厘米互换
Version: 0.1
Author: 骆昊
Date: 2018-02-28
"""
value = float(input('请输入长度: '))
unit = input('请输入单位: ')
if unit == 'in' or unit == '英寸':
2019-05-03 21:17:36 +08:00
print('%f英寸 = %f厘米' % (value, value * 2.54))
2018-03-02 00:09:06 +08:00
elif unit == 'cm' or unit == '厘米':
2019-05-03 21:17:36 +08:00
print('%f厘米 = %f英寸' % (value, value / 2.54))
2018-03-02 00:09:06 +08:00
else:
2019-05-03 21:17:36 +08:00
print('请输入有效的单位')