【发布时间】:2014-03-13 08:17:15
【问题描述】:
对不起,我对编程有点陌生。基本上,我被分配到“分析”并生成一个三角形的图像,其中用户指定两条边的长度和它们之间的角度大小,程序运行并找到第三条边的长度以及两条边其他角度(使用余弦定律)。然后我必须有所有边长的文本输出,所有角度测量(可选),并以我的海龟的形式打印该区域,在图像中打印出“这是你的三角形 \n 它有一个 x 平方像素的区域”也是。 此外,三角形的质心必须位于 (0,0)。这是我目前所拥有的:
import math
from turtle import*
print("This program will draw a custom triangle.")
firstside=float(input("Enter length of first side (between 10 and 400 pixels): "))
secondside=float(input("Enter length of second side (between 10 and 400 pixels): "))
includedangle=float(input("Enter the measure of the included angle in degrees (between 1 and 179): "))
print("Side lengths and angle measures:\n")
solvedthirdside=float(math.sqrt(firstside**2+secondside**2-(2*firstside*secondside*math.cos(includedangle))))
cage=Screen(); #Create screen object named cage
cage.setup(500,500) #set screen size to 500x500 pixels
另外,我也在使用海龟图形。
我真的很挣扎。一些帮助将不胜感激! 请帮忙!谢谢!
【问题讨论】:
-
Python 语句不以分号结尾。
标签: python geometry turtle-graphics centroid