更新
This commit is contained in:
23
Python-100-Days/Day01-15/Day03/triangle.py
Normal file
23
Python-100-Days/Day01-15/Day03/triangle.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
|
||||
判断输入的边长能否构成三角形
|
||||
如果能则计算出三角形的周长和面积
|
||||
|
||||
Version: 0.1
|
||||
Author: 骆昊
|
||||
Date: 2018-02-28
|
||||
|
||||
"""
|
||||
|
||||
import math
|
||||
|
||||
a = float(input('a = '))
|
||||
b = float(input('b = '))
|
||||
c = float(input('c = '))
|
||||
if a + b > c and a + c > b and b + c > a:
|
||||
print('周长: %f' % (a + b + c))
|
||||
p = (a + b + c) / 2
|
||||
area = math.sqrt(p * (p - a) * (p - b) * (p - c))
|
||||
print('面积: %f' % (area))
|
||||
else:
|
||||
print('不能构成三角形')
|
||||
Reference in New Issue
Block a user