登录后查看本帖详细内容!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
3.15: from turtle import* penup() goto(0,-100) pendown() circle(100) penup() goto(0,30) left(180) pendown() circle(30,steps=3) penup() goto(-40,50) pendown() dot(20,'black') penup() goto(40,50) pendown() dot(20,'black') penup() goto(0,-50) pendown() right(30) forward(60) penup() goto(0,-50) pendown() right(120) forward(60) hideturtle() done() 3.16: from turtle import* penup() goto(-200,0) right(180) pendown() circle(60,steps=3) penup() goto(-100,-90) right(225) pendown() circle(60,steps=4) penup() goto(20,-90) left(8) #right(180) pendown() circle(60,steps=5) penup() goto(160,-90) setheading(0) right(30) pendown() circle(60,steps=6) penup() goto(300,-90) pendown() left(8) circle(60,steps=8) done() 3.17: from turtle import* import math x1,y1,x2,y2,x3,y3=eval(input('输入三个点的坐标:')) side1=pow((x1-x2)**2+(y1-y2)**2,0.5) side2=pow((x1-x3)**2+(y1-y3)**2,0.5) side3=pow((x2-x3)**2+(y2-y3)**2,0.5) s=(side1+side2+side3)/2 area=pow((s*(s-side1)*(s-side2)*(s-side3)),0.5) #print(s,side1,side2,side3,area) penup() goto(x1,y1) pendown() write('p1('+str(x1)+','+str(y1)+')') goto(x2,y2) write('p2('+str(x2)+','+str(y2)+')') goto(x3,y3) write('p3('+str(x3)+','+str(y3)+')') goto(x1,y1) penup() goto(0,-90) pendown() write('the area of triangle is '+format(area,'.2f')) done() 3.18: from turtle import* import math x1,y1,x2,y2,x3,y3=eval(input('输入三个点的坐标:')) a=pow((x1-x2)**2+(y1-y2)**2,0.5) b=pow((x1-x3)**2+(y1-y3)**2,0.5) c=pow((x2-x3)**2+(y2-y3)**2,0.5) A=math.degrees(math.acos((a*a-b*b-c*c)/(-2*b*c))) B=math.degrees(math.acos((b*b-a*a-c*c)/(-2*a*c))) C=math.degrees(math.acos((c*c-b*b-a*a)/(-2*a*b))) penup() goto(x1,y1) pendown() write('A角:'+str(round(A*100)/100.0)) goto(x2,y2) write('B角:'+str(round(B*100)/100.0)) goto(x3,y3) write('C角:'+str(round(C*100)/100.0)) goto(x1,y1) done() 3.19: from turtle import* import math x1,y1,x2,y2=eval(input('输入两个点的坐标:')) penup() goto(x1,y1) pendown() write('p1('+str(x1)+','+str(y1)+')') goto(x2,y2) write('p2('+str(x2)+','+str(y2)+')') hideturtle() done()
|