您的位置 首页 知识分享

Python – 级别:询问

1 级任务 1) 华氏度到摄氏度转换 f=int(input("enter the no. &quo…

Python - 级别:询问

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中文网其它相关文章!

本文来自网络,不代表甲倪知识立场,转载请注明出处:http://www.spjiani.cn/wp/5869.html

作者: nijia

发表评论

您的电子邮箱地址不会被公开。

联系我们

联系我们

0898-88881688

在线咨询: QQ交谈

邮箱: email@wangzhan.com

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部