noelnw2.py

Created by schraf

Created on December 10, 2019

602 Bytes

Apprendre Python sur une Numworks


from turtle import *
from random import *
speed(0)

# Un arbre
def tree(d, s, c):
    color(c)
    if d <= 0: return
    forward(s)
    tree(d-1, s*.8, c)
    right(120)
    tree(d-3, s*.5, c)
    right(120)
    tree(d-3, s*.5, c)
    right(120)
    backward(s)
    
# 11 rangees de 20 arbres
for i in range(11):
  for j in range(20):
    # sapin debout ?
    setheading(90 if random()<.95 else 0)
    penup()
    # position depart
    goto(randint(-150,150),100-20*i+randint(-10,10))
    pendown()
    # choix du vert
    c = choice([(0,120,0), (0,180,0)])
    tree(10,randint(2,2+i),c)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.