猫史档案馆


【Python作品分享】美丽的四季【作品秀】

用户:LiuYMLiuYM查看:1 回复:2 评论:1 创建时间:2021-04-17T10:59:49


【作品展示】

center_image

 

【作品介绍】

转载

 

【作品源代码】

from turtle import *
from random import *
from math import *
import time
print("大家好~")
time.sleep(1)
print("有以下场景,请您观赏")
time.sleep(1)
print("1:春 2:夏 3:秋 4:冬 ")
time.sleep(1.5)
print("----------------")
bg = input("您选择的数字是:")
print("请看任务栏")
while bg != "1" and bg != "2" and bg != "3" and bg != "4":
    bg = input("输入有误,请输入正确内容(1~4):")
if bg == "1":
    color1 = ["tan", "mediumseagreen"]
elif bg == "2":
    color1 = ["burlywood", "lightpink"]
elif bg == "3":
    color1 = ["darkgoldenrod", "gold"]
else:
    color1 = ["olive", "azure"]


def tree(n, l):
    pd()
    color(color1[0])
    pensize(n / 3)
    forward(l)
    if n > 0:
        b = random() * 15 + 10
        c = random() * 15 + 10
        d = l * (random() * 0.25 + 0.7)
        right(b)
        tree(n - 1, d)
        left(b + c)
        tree(n - 1, d)
        right(c)
    else:
        right(90)
        color(color1[1])
        circle(3)
        left(90)
        if(random() > 0.7):
            pu()
            t = heading()
            an = -40 + random()*40
            setheading(an)
            dis = int(800*random()*0.5 + 400*random()*0.3 + 200*random()*0.2)
            forward(dis)
            setheading(t)
            pd()
            right(90)
            color(color1[1])
            circle(2)
            left(90)
            pu()
            t = heading()
            setheading(an)
            backward(dis)
            setheading(t)
    pu()
    backward(l)


print("记得点赞哟")
ht()
getscreen().tracer(1000)
pu()
backward(100)
left(90)
pu()
backward(300)
tree(12, 100)
done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
编程大佬喵编程大佬喵

厉害

点赞0


评论


浮躁的飓风雀HYKa浮躁的飓风雀HYKa

点赞1


评论