- import MyTriangle
-
- s1 = float(input("请输入边长1:"))
- s2 = float(input("请输入边长2:"))
- s3 = float(input("请输入边长3:"))
-
- r = MyTriangle.isvalid(s1, s2, s3)
- if r:
- a = MyTriangle.area(s1, s2, s3)
- print("面积为:", a)
- else:
- print("不是一个有效的三角形")
-
- print(MyTriangle)
- def isvalid(s1,s2,s3):
- return s1 +s2>s3 and s1+ s3>s2 and s1 < s2+s3
-
-
- def area(s1,s2,s3):
- p = (s1+s2+s3)/2
- s = (p*(p-s1)*(p-s2)*(p-s3))**0.5
- return s
结果
主程序
- def reverse(number):
- return int(str(number)[::-1])
-
-
- u = int(input("请输入一个整数: "))
-
- r = reverse(u)
- print("该整数的反向数为:", r)
结果