浙大版《Python 程序设计》题目集 第2章-12 输出三角形面积和周长 (15分)

import math
a,b,c = map(int,input().split())
if a+b<=c or a+c<=b or b+c<=a:
    print('These sides do not correspond to a valid triangle')
else:
    s = (a+b+c)/2
    area = math.sqrt(s*(s-a)*(s-b)*(s-c))
    print('area = {:.2f}; perimeter = {:.2f}'.format(area,a+b+c))
发布了33 篇原创文章 · 获赞 0 · 访问量 268

猜你喜欢

转载自blog.csdn.net/weixin_42229583/article/details/104573092