第1关:温度转换
# 请在此添加代码
########## Begin ##########
def convert(c):
f=1.8*c+32
return f
########## End ##########
C = eval(input( "input a number:" ))
F = convert( C )
print( "%.1f"%F )
第2关:求五边形的面积
# 请在此添加代码
from math import *
########## Begin ##########
# 计算三角形的面积
def ts(a,b,c):
s = (a + b + c) / 2
area = sqrt(s * (s - a) * (s - b) * (s - c))
return area
# 主函数
def main():
k1, k2, k3, k4, k5, k6, k7 = map(int, input().split(','))
a1 = k1
b1 = k2
c1 = k6
a2 = k3
b2 = k7
c2 = k6
a3 = k5
b3 = k4
c3 = k7
area = ts(a1, b1, c1) + ts(a2, b2, c2) + ts(a3, b3, c3)
print("area=%.5f" % area)
########## End ##########
main()
第3关:匿名函数应用
# 请在此添加代码
from math import *
文章出处登录后可见!
已经登录?立即刷新