我刚刚进入编程世界并获得了一个非常基本的练习,但我有点卡住,不知道接下来该做什么.问题是:给定3个数字确定它们是否可以形成三角形,如果是,则计算周长和面积,然后绘制三角形.我已经设法计算三角形的周长和面积(就是这样存在),但不知道如何使计算机从输入的任何值中绘制三角形.
这是代码:
import math
a = int(input("Enter your first number"))
b = int(input("Enter your second number"))
c = int(input("Enter your third number"))
if a+b>c and a+c>b and b+c>a:
print("The Triangle's Perimeter is:")
print(int(a+b+c))
print("The Area of the triangle is:")
print(int(math.sqrt((a+b+c)/2)*(((a+b+c)/2)-a)*(((a+b+c)/2)-b)*(((a+b+c)/2)-c)))
else:
print("The numbers do not form a triangle")
input("Press any key to continue")
Run Code Online (Sandbox Code Playgroud)
如果你们能让我了解如何完成这项任务,那会很高兴
python ×1