勾股定理简易演示程序

勾股定理简易演示程序

Python勾股定理简易演示程序

Python勾股定理简易演示程序

"""
   请说出三角形的边长分别是多少? 它们有什么关系?
"""
import turtle

turtle.shape('turtle')
turtle.pensize(2)
turtle.speed(1)
turtle.color('gray')
turtle.setup(800,800)

turtle.bk(400)
turtle.fd(800)
turtle.bk(400)

turtle.left(90)
turtle.fd(400)
turtle.bk(800)
turtle.home()

turtle.fd(180)
turtle.goto(0,240)
turtle.left(36.87)
turtle.begin_fill()
for _ in range(4):
    turtle.fd(300)
    turtle.right(90)
turtle.end_fill()    
turtle.home()

turtle.fillcolor('light gray')
turtle.begin_fill()
for _ in range(4):
    turtle.fd(180)
    turtle.right(90)
turtle.end_fill()

turtle.right(180)
turtle.begin_fill()
for _ in range(4):
    turtle.fd(240)
    turtle.right(90)
turtle.end_fill() 
turtle.done()

李兴球

李兴球的博客是Python创意编程原创博客