User:Lidia.Pereira/PNM: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
First experiences with the turtle! (Thank you very much Tamas and Lucia for technical support)
First experiences with the turtle! (Thank you very much Tamas and Lucia for technical support)


import turtle
<syntaxhighlight lang="py">
import random
#include <iostream>
import turtle
import random


def Poly(n,x):
def Poly(n,x):
angle = 360/n
angle = 360/n
for i in range(n):
for i in range(n):
turtle.forward(x)
turtle.forward(x)
turtle.left(angle)
turtle.left(angle)


def makeFlower(p):
def makeFlower(p):
    for i in range(12):
    for i in range(12):
            print Poly(9,p)
            print Poly(9,p)
            turtle.left(30)
            turtle.left(30)


while(1):
while(1):
  print makeFlower(random.randint(40,100))   turtle.color(random.randint(0,1),random.randint(0,1),random.randint(0,1))
    print makeFlower(random.randint(40,100))  
    turtle.color(random.randint(0,1),random.randint(0,1),random.randint(0,1))
 
</syntaxhighlight>




[[File:Networked2.png]]
[[File:Networked2.png]]

Revision as of 09:14, 17 September 2013

First experiences with the turtle! (Thank you very much Tamas and Lucia for technical support)

#include <iostream>
import turtle
import random

def Poly(n,x):
	angle = 360/n
	for i in range(n):
		turtle.forward(x)
		turtle.left(angle)

def makeFlower(p):
    for i in range(12):
            print Poly(9,p)
            turtle.left(30)

while(1):
    print makeFlower(random.randint(40,100)) 
    turtle.color(random.randint(0,1),random.randint(0,1),random.randint(0,1))


Networked2.png