搜档网
当前位置:搜档网 › linux下的python小程序

linux下的python小程序

linux下的python小程序

linux下的python小程序——三角形面积

#!/usr/bin/python

##file of sanjiaoxing mianji

import math

a = int(raw_input('please enter side a:'))

b = int(raw_input('please enter side b:'))

c = int(raw_input('please enter side c:'))

if a + b <= c or b + c <= a or a + c <= b:

?????? ?out = str(a)+','+str(b)+','+str(c)+" can't make a triangle" else:

?????? ?p = (a + b + c )/2.0

?????? ?s =math.sqrt(p * (p - a) * (p - b) * (p - c)) ??????? out = "the area of this trangle is%.2f " % s

print out

?

使用海伦公式,给初学者参考,我也是初学者......

相关主题