2.1
程序:
Celsius=eval(input("Enter a degree in Celsius:"))
#输入摄氏度的值Celsius
fahrenheit =(9/5)*Celsius + 32
#定义华氏温度fahrenheit
print(Celsius,"Celsius is",fahrenheit,"Fahrenheit")
结果:
Enter a degree in Celsius:43
43 Celsius is 109.4 Fahrenheit
2.2 读取半径和高来计算圆柱体底面面积和体积
设计:
area = radius * radius *∏
volume =area * length
程序:
radius,length = eval (input("Enter the radius and length of cylinder:" ))
#输入半径radius和高length
area = radius*radius*3.14
#定义面积公
最后
以上就是完美野狼最近收集整理的关于python程序语言设计-《python语言程序设计》_第二章编程题的全部内容,更多相关python程序语言设计-《python语言程序设计》_第二章编程题内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复