首页 > 代码库 > 20170417定义函数

20170417定义函数

技术分享

1.def fahrenheit_converter(C):
fahrenheit = C * 9/5 +32
return str(fahrenheit) + ‘°F‘ """摄氏度转华氏度"""
C2F = fahrenheit_converter(35)
print(C2F)
2.def kilogram_to_gram(kg):
gram = kg*1000
return str(gram) + ‘g‘"""千克转克"""
print(kilogram_to_gram(20))
3.def right_bevel(a,b):
bevel = (a**2 + b**2)**(1/2)
return ‘The right triangle third side\‘s length is ‘ + str(bevel) + ‘cm‘
print(right_bevel(3,4))
print(right_bevel(a=3,b=4))#已知直边求斜边

20170417定义函数