用户:天狐Drift查看:0 回复:0 评论:0 创建时间:2021-05-16T13:11:11
【作品展示】

【作品介绍】
程序会画出一个随机的星座,猜猜这是哪个星座呢?(重复3次)
【作品源代码】
import turtle
import random
turtle.bgcolor("#090C29")
turtle.color("white")
turtle.speed(0)
my = turtle.Turtle()
turtle.hideturtle()
def ursaMajor():
turtle.penup()
x = -310
y = 0
coordinates = ((x, y), (x + 135, y + 1), (x + 223, y - 58), (x + 330, y - 105), (x + 344, y - 193), (x + 470, y - 209), (x + 500, y - 123))
for i in coordinates:
turtle.penup()
turtle.setpos(i)
turtle.pendown()
for x in range(7):
turtle.forward(12)
turtle.right(144)
my.hideturtle()
my.penup()
for i in coordinates:
my.color("white")
my.goto(i)
my.pendown()
my.goto(coordinates[-4])
def aries():
turtle.penup()
x = -290
y = 75
coordinates = ((x, y), (x + 270, y - 45), (x + 420, y - 95), (x + 450, y - 180))
for i in coordinates:
turtle.penup()
turtle.setpos(i)
turtle.pendown()
for x in range(7):
turtle.forward(12)
turtle.right(144)
my.hideturtle()
my.penup()
for i in coordinates:
my.color("white")
my.goto(i)
my.pendown()
def libra():
turtle.penup()
x = -200
y = -100
coordinates = ((x, y), (x + 75, y + 200), (x + 180, y + 275), (x + 260, y + 140), (x + 148, y + 10))
for i in coordinates:
turtle.penup()
turtle.setpos(i)
turtle.pendown()
for x in range(7):
turtle.forward(12)
turtle.right(144)
my.hideturtle()
my.penup()
for i in coordinates:
my.color("white")
my.goto(i)
my.pendown()
my.goto(coordinates[3])
my.goto(coordinates[1])
constellations = ["UrsaMajor", "Aries", "Libra"]
for i in range(3):
x = random.choice(constellations)
constellations.remove(x)
if x == "UrsaMajor":
ursaMajor()
answer = input("这些星星的名字叫什么?")
if answer == "北斗七星":
print("答对了!这就是北斗七星")
turtle.clear()
my.clear()
else:
print("答错了D: 这是北斗七星")
turtle.clear()
my.clear()
elif x == "Aries":
aries()
answer = input("这是哪个星座?")
if answer == "白羊座":
print("答对了!这就是白羊座")
turtle.clear()
my.clear()
else:
print("答错了D: 这是白羊座")
turtle.clear()
my.clear()
else:
libra()
answer = input("这是哪个星座?")
if answer == "天枰座":
print("答对了!这就是天枰座")
turtle.clear()
my.clear()
else:
print("答错了D: 这是天枰座")
turtle.clear()
my.clear()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn