neve.py

Created by numworks-pt

Created on November 30, 2021

430 Bytes

Floco de neve desenhado com Turtle. Para inserir flocos de neve escrever neve(n) em que n é o número de flocos que devem ser desenhados no ecrã.


from turtle import *
from random import *

def losango(l):
  forward(l)
  left(40)
  forward(l)
  left(140)
  forward(l)
  left(40)
  forward(l)
  
def floco(l):  
  pendown()
  for i in range(10):
    losango(l)
    left(176)

def neve(n):
  for i in range(n):
    color(randint(0,255),randint(0,255),randint(0,255))
    penup()
    x=randint(-160,160)
    y=randint(-110,110)
    goto(x,y)
    pendown()
    floco(5)

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.