首页 >后端开发 >Python教程 >Python - 级别:询问

Python - 级别:询问

Linda Hamilton
Linda Hamilton原创
2024-12-03 21:29:10192浏览

Python - Level : asks

1 级任务

1) 华氏度到摄氏度转换

f=int(input("Enter the no. "))

c=5/9*(f-32)

print("Fahrenheit to celsius",round(c))

输出:

Enter the no. 108
Fahrenheit to celsius 42

2) 摄氏度到华氏度转换

c=int(input("Enter the no. "))
f=c*(9/5)+32

print("celsius to fahrenheit",round(f))

输出:

Enter the no. 42
celsius to fahrenheit 108

3) 英尺到米的转换

#1 Feet = 0.3048 meters

feet=float(input("Enter the no. "))

meter=feet*0.3048

print("feet to meters",round(meter,1))

输出:

Enter the no. 15
feet to meters 4.6

4) 正方形的输入侧、输出区域

side=float(input("Enter the no. "))

area=side**2

print("Area of a square is ",area)

输出:

Enter the no. 5
Area of a square is  25.0

5) 输入-长、宽;输出-矩形面积

#Area of a Rectangle=length*breadth

length=float(input("Enter length of the rectangle. "))
breadth=float(input("Enter breadth of the rectangle. "))

area=length*breadth

print("Area of a rectangle is ",area)

输出:

Enter length of the rectangle. 5
Enter breadth of the rectangle. 10
Area of a rectangle is  50.0

6) 半径 - 圆的面积

#Area of circle = πr2

r=int(input("Enter the radius of circle: "))

area=3.14*(r**2)

print("Area of the circle is ",area)

输出:

Enter the radius of circle: 5
Area of the circle is  78.5

7) 美元 转换为 INR

#usd=Rs. 84.56

dollar=float(input("Enter currency in dollars: "))
usd=dollar*84.56

print("Currency in rupees is =",usd)

输出:

Enter currency in dollars: 500
Currency in rupees is = 42280.0

以上是Python - 级别:询问的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn