# Python勾股定理教学演示程序_为中小学信息技术教育添砖加瓦_Python精灵模块

### 本程序需要Python精灵模块V1.23以上版本,如果你无法运行,请用pip uninstall sprites先卸载,再用pip install sprites安装.

```"""
Python勾股定理粒子演示,本程序由sprites模块制作,请安装最新版本的sprites模块,要不然找不到相关方法.
"""
import math
from sprites import *

def spaceorwait():
start = time.time()
while not spacekey.down():
if  time.time()-start>1:break
screen.update()
def platlist(cors):
"""扁平化列表"""
d = []
for rows in cors:
for x,y in rows:
d.append((x,y))
return d

def placeball(cors):
stamps = []
for rows in cors:
for x,y in rows:
t.goto(x,y)
sid = t.stamp()
stamps.append(sid)
return stamps

screen = Screen()
screen.bgcolor('dodger blue')
screen.title('勾股定理教学演示by李兴球')
screen.listen()
spacekey = Key('space')

ft = ('楷体',32,'normal')
ft2 = ('黑体',16,'normal')
w = Sprite(1,visible=False)
w.scale(0.4)
w.color('lime')
w.goto(0,240)
w.write('观看与思考',align='center',font=ft)
w.goto(0,210)
w.color('yellow')
w.write('这是演示什么定律',align='center',font=ft2)
w.goto(0,180)
w.color('cyan')
w.write('本程序用Python精灵模块制作',align='center',font=ft2)

t = Sprite(1,visible=False)
t.scale(0.4)
t.color('white')

initx,inity = -50,-100
while not spacekey.down():screen.update()

t.play('Crashteroids.wav',loop=True)
while True:

```

VIP免费查看

scratch