How to use python/ R language to draw Christmas Tree
This article introduces the relevant knowledge of "how to draw a Christmas tree with python/ R language". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Python
1 、
Import turtle screen = turtle.Screen () screen.setup (800600) 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 () circle.stamp () k = 0for i in range (1) 17): y = 30yogi for j in range (iMurk): X = 30,000j square.goto (xmaijiaoyong280) square.stamp () square.goto (- xmaiwyong280) square.stamp () if I% 4 = = 0: X = 30* (jumb1) circle.color ('red') circle.goto (- x -yaoqiao 280) circle.stamp () circle.goto (xjinger talk 280) circle.stamp () k + = 2 if I% 4 = = 3: X = 30 * (juni1) circle.color ('yellow') circle.goto (- xMorelin 280) circle.stamp () circle.goto (x -Yizhong 280) circle.stamp () square.color ('brown') for i in range (17Magne20): y = 30yogi for j in range (3): X = 30Zhij square.goto (Xmai Meiyao280) square.stamp () square.goto (- XLINGLINGYLING 280) square.stamp () turtle.exitonclick ()
2 、
Import randomheight = 11for i in range (height): print ('* (height-I), end='') for j in range ((2 * I) + 1): if random.random ()
< 0.1: color = random.choice(['\033[1;31m', '\033[33m', '\033[1;34m']) print(color, end='') # the lights else: print('\033[32m', end='') # green print('*', end='') print()print((' ' * height) + '|')
3 、
N = 50from turtle import * speed ("fastest") # without this line, you will very very slow left (90) forward (3 millin) color ("orange", "yellow") begin_fill () left (126) for i in range (5): forward (nlag5) right (144) forward (nachet 5) left (72) end_fill () right (126) color ("dark green") backward (num 4.8) def tree (d, s): if d