Get the App
SLTechnology News&Howtos  ›  Development  › 

How to draw a Christmas tree with python

Shulou Source: shulou.com Published: 2022-06-02 06:30:09 10月02日 Update

This article mainly introduces how to use python to draw a Christmas tree, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

How to draw a Christmas tree with python?

Turtle library to draw the Christmas tree.

1. Square Christmas tree import turtlescreen = turtle.Screen () screen.setup (375,700) 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 (0280) circle.stamp () k = 0for i in range (1) 13): 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 + = 3if 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 (13 17): y = 30 * i for j in range (2): X = 30 * j square.goto (x,-y + 280) square.stamp () square.goto (- x,-y + 280) square.stamp ()

two。 Line Christmas tree import turtle# defines the green leaf function def tree (d, s): if d of the Christmas tree

Tags: Christmas tree color snowflake size lights that is method article pentagonal star angle speed pentagonal function at the same time coordinates font branch white pen luxury Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn Shulou Information NVidia Shulou Technology