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