User:Luisa Moura/prototyping/python/turtle: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "==flower hexagon== File:Flower hexagon.jpg <source lang="python"> import turtle import random def hexagon(angle,size): angle=60 for i in range(6): turtle.fo...")
 
No edit summary
 
Line 1: Line 1:
==flower hexagon==
[[File:Flower hexagon.jpg]]
[[File:Flower hexagon.jpg]]


Line 8: Line 6:


import random
import random


def hexagon(angle,size):
def hexagon(angle,size):
Line 20: Line 16:


turtle.left(angle)
turtle.left(angle)


def drawing(size):
def drawing(size):
Line 30: Line 24:


turtle.left(20)
turtle.left(20)


while(1):
while(1):
Line 40: Line 32:


turtle.width(random.randint(1,2))
turtle.width(random.randint(1,2))


turtle.exitonclick()
turtle.exitonclick()

Latest revision as of 15:17, 9 April 2014

Flower hexagon.jpg

<source lang="python">

import turtle

import random

def hexagon(angle,size):

angle=60

for i in range(6):

turtle.forward(size)

turtle.left(angle)

def drawing(size):

for i in range(18):

print hexagon(60,size)

turtle.left(20)

while(1):

print drawing(random.randint(40,100))

turtle.color(random.randint(0,1),random.randint(0,1),random.randint(0,1))

turtle.width(random.randint(1,2))

turtle.exitonclick()