python英寸和厘米互换_将厘米转换为英寸的Python程序

python英寸和厘米互换

There are many problems where we have to calculate the distance in inches at the end but initially, the measurements are given in centimeters. So for such type of problems, the solution is converting the initial parameters into inches and then performing operations on it and another option is to perform operations in centimeters and then convert the final answer from centimeters to inches.

存在许多问题,我们必须最后计算以英寸为单位的距离,但是最初,测量单位是厘米。 因此,对于此类问题,解决方案是将初始参数转换为英寸,然后对其执行操作,另一种选择是以厘米为单位执行操作,然后将最终答案从厘米转换为英寸

So, here in this article, we are going to write a Python code for converting the centimeters into inches.

因此,在本文的此处,我们将编写用于将厘米转换为inch的Python代码

Key: 1 inch = 2.54 cms

键: 1英寸= 2.54厘米

Example:

例:

    Input:
    Centimeter: 245

    Output:
    Inches: 96.45669291338582    

Python code to convert Centimeter to Inches

Python代码将厘米转换为英寸

# Python program to convert Centimeter to Inches 
# taking input
num = float(input("Enter the distance measured in centimeter : "))

# converting from cms to inches
""" 1 inch = 2.54 centimeters"""
inc = num/2.54 

# printing the result
print("Distance in inch : ", inc)

Output

输出量

First run:
Enter the distance measured in centimeter : 245
Distance in inch :  96.45669291338582

Second run:
Enter the distance measured in centimeter : 54
Distance in inch :  21.25984251968504 

Third run:
Enter the distance measured in centimeter : 2.54
Distance in inch :  1.0


翻译自: https://www.includehelp.com/python/program-to-convert-centimeter-to-inches.aspx

python英寸和厘米互换

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值