#版权:guozhetao
import turtle
import random
import time
__Pen = turtle.Pen()
#开始进入Python的世界
t = turtle.Turtle()
t.speed(0)
t.shape('turtle')
#while 语句
def nb(b,d,c):
t.penup()
t.goto((-200+b), (0+d))
t.pendown()
a = c#随机
#正方形框
for i in range(4):
t.forward(150)
t.right(90)
t.penup()
#点数1
if (a == 1):
t.fillcolor('red')
t.begin_fill()
t.goto((-125+b), (-85+d))
t.circle(20)
t.end_fill()
#点数2
if (a == 2):
t.fillcolor('black')
t.begin_fill()
t.goto((-90+b), (-75+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-155+b), (-75+d))
t.circle(10)
t.end_fill()
#点数3
if (a == 3):
t.fillcolor('black')
t.begin_fill()
t.goto((-160+b), (-50+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-125+b), (-75+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-90+b), (-100+d))
t.circle(10)
t.end_fill()
#点数4
if (a == 4):
t.fillcolor('red')
t.begin_fill()
t.goto((-160+b), (-50+d))
t.circle(10)
t.end_fill()
t.fillcolor('red')
t.begin_fill()
t.goto((-100+b), (-50+d))
t.circle(10)
t.end_fill()
t.fillcolor('red')
t.begin_fill()
t.goto((-160+b), (-120+d))
t.circle(10)
t.end_fill()
t.fillcolor('red')
t.begin_fill()
t.goto((-100+b), (-120+d))
t.circle(10)
t.end_fill()
#点数5
if (a == 5):
t.fillcolor('black')
t.begin_fill()
t.goto((-160+b), (-50+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-100+b), (-50+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-160+b), (-120+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-100+b), (-120+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-125+b), (-85+d))
t.circle(10)
t.end_fill()
#点数6
if (a == 6):
t.fillcolor('black')
t.begin_fill()
t.goto((-180+b), (-50+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-130+b), (-50+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-80+b), (-50+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-180+b), (-120+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-130+b), (-120+d))
t.circle(10)
t.end_fill()
t.fillcolor('black')
t.begin_fill()
t.goto((-85+b), (-120+d))
t.circle(10)
t.end_fill()
def a():
q=random.randint(1,6)
w = random.randint(1, 6)
e = random.randint(1, 6)
r = random.randint(1, 6)
v = random.randint(1, 6)
y = random.randint(1, 6)
nb(0, 0, q)
nb(200,0,w)
nb(400,0,e)
nb(0, 200, r)
nb(200, 200, v)
nb(400, 200, y)
t.hideturtle()
time.sleep(5)
t.clear()
turtle.onkeypress(a,'3')
turtle.listen()
turtle.done()
#版权:guozhetao

10-09
2357

10-24
388

02-19
3594
