圣诞节快到了应该送点什么呢(圣诞节怎么能少了礼物)
公众号:AI图书馆
AI图书馆坐标上海,专注于人工智能\机器学习\深度学习\计算机视觉\SLAM\Python学习\英语学习\思维培养\读书生活感想以及相关资源分享。欢迎关注,共同成长。121篇原创内容
懂点技术,会讲故事,有点意思。
欢迎关注,相互交流,共同进步。
今天是圣诞节,先祝大家圣诞快乐!再送福利!先送你一棵圣诞树!幸运的话还有一本书哟!快来领取吧!会Python编程的,自己照着下方代码来一遍,你就拥有了美妙的圣诞树;
不会编程的,关注我,跟着学,常练习,不懂就来私聊小助手,免费答疑。
当然,今天是圣诞节,不会代码,也要送你一颗圣诞树,领取方式在文末!
OK,会编程的看过来,不会代码的移步文末咯!
1.简单版
treeheight = 11
for i in range(treeheight):
print((' ' * (treeheight - i)) ('*' * ((2 * i) 1)))
print((' ' * treeheight) '|')
2.升级版
import turtle
screen = turtle.Screen()
screen.setup(800,600)
circle = turtle.Turtle()
circle.shape('circle')
circle.color('red')
circle.speed('fastest')
circle.up()
square = turtle.Turtle()
square.shape('square')
square.color('green')
square.speed('fastest')
square.up()
circle.goto(0,280)
circle.stamp()
k = 0
for i in range(1, 17):
y = 30*i
for j in range(i-k):
x = 30*j
square.goto(x,-y 280)
square.stamp()
square.goto(-x,-y 280)
square.stamp()
if i % 4 == 0:
x = 30*(j 1)
circle.color('red')
circle.goto(-x,-y 280)
circle.stamp()
circle.goto(x,-y 280)
circle.stamp()
k = 2
if i % 4 == 3:
x = 30*(j 1)
circle.color('yellow')
circle.goto(-x,-y 280)
circle.stamp()
circle.goto(x,-y 280)
circle.stamp()
square.color('brown')
for i in range(17,20):
y = 30*i
for j in range(3):
x = 30*j
square.goto(x,-y 280)
square.stamp()
square.goto(-x,-y 280)
square.stamp()
turtle.exitonclick()
3.高级版
from turtle import *
import random
import time
n = 80.0
speed("fastest")
screensize(bg='seashell')
left(90)
forward(3*n)
color("orange", "yellow")
begin_fill()
left(126)
for i in range(5):
forward(n/5)
right(144)
forward(n/5)
left(72)
end_fill()
right(126)
color("dark green")
backward(n*4.8)
def tree(d, s):
if d <= 0: return
forward(s)
tree(d-1, s*.8)
right(120)
tree(d-3, s*.5)
right(120)
tree(d-3, s*.5)
right(120)
backward(s)
tree(15, n)
backward(n/2)
for i in range(200):
a = 200 - 400 * random.random()
b = 10 - 20 * random.random()
up()
forward(b)
left(90)
forward(a)
down()
if random.randint(0, 1) == 0:
color('tomato')
else:
color('wheat')
circle(2)
up()
backward(a)
right(90)
backward(b)
time.sleep(60)
4.特级版
领取方式
识别二维码,回复:圣诞树
圣诞节怎么能少了礼物!快来领取吧! Devote yourselves to prayer,�being watchful and thankful.�
,免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com