# Python turtle正弦定义演示程序

### Python海龟宝典含200多个原创的用turtle模块制作的创意程序，原名《Python趣味编程200例》。准备参加全国创意编程与智能设计大赛的同学们可以用来做参考。

```"""
正弦定理演示程序.py
"""
__author__ = '李兴球'
__date__ = '2021/8/22'

import math
from turtle import Screen,Turtle,TurtleScreenBase

pass                                        # 这里省略几行代码

corturtle = Turtle(shape='blank')
corturtle.fd(340)
corturtle.bk(680)
corturtle.fd(340)
corturtle.left(90)
corturtle.fd(280)
corturtle.bk(560)
screen.update()

p = Turtle(shape='blank')
p.penup()
p.goto(-300,150)
s = '正弦定理演示程序'
p.write(s,font=('',24))
w = Turtle(shape='blank')
w.penup()
w.pensize(4)
w.speed(0)

t = Turtle(shape='blank')                      # 新建无形海龟
t.pensize(4)
def draw(a,b):
t.clear()
t.color('red')
t.fd(a)
t.left(90)
t.color('blue')
t.fd(b)
t.color('black')
t.home()
c = math.dist([a,b],[0,0])
angle = round(math.degrees(math.asin(b/c)),2)
s = 'sin(' + str(angle) + ")=" + str(round(b/c,2))
w.clear()
w.home()
w.fd(20)
w.left(90)
w.pendown()
w.circle(20,angle)
w.penup()
try:
dd = 25 * (b/a) * 0.08
w.goto(25,dd)
w.write('θ',align='center',font=('',14))
except:pass
w.goto(a/2,-20)
w.write('a='+str(a),align='center',font=('',14))
w.goto(a+38,b/2)
w.write('b='+str(b),align='center',font=('',14))
w.goto(a/2,b/2+30)
w.write('c='+str(round(c,2)),align='center',font=('',14))
w.goto(0,-100)
w.write(s,align='center',font=('',22))
screen.update()

screen.onmousemove(draw)
screen.mainloop()

```

VIP免费查看

#### 学本领，探索更大的世界！

error: Content is protected !!