Bob Dylan

All

I created this post a long time ago, when the Nobel prize was annouced and before Bob refusing to go there.

Well, here comes the hystory of a hurricane! Congrats Dylan! You’re just great

 

Python Fractal from [1]

import turtle
PROGNAME = ‘Sierpinski Triangle’
#Credits: This code was written by editing the code from http://www.lpb-riannetrujillo.com/blog/python-fractal/

myPen = turtle.Turtle()
myPen.ht()
myPen.speed(5)
myPen.pencolor(‘orange’)

points = [[-175,-125],[0,175],[175,-125]] #size of triangle

def getMid(p1,p2):
return ( (p1[0]+p2[0]) / 2, (p1[1] + p2[1]) / 2) #find midpoint

def triangle(points,depth):

myPen.up()
myPen.goto(points[0][0],points[0][1])
myPen.down()
myPen.goto(points[1][0],points[1][1])
myPen.goto(points[2][0],points[2][1])
myPen.goto(points[0][0],points[0][1])

if depth>0:
triangle([points[0],
getMid(points[0], points[1]),
getMid(points[0], points[2])],
depth-1)
triangle([points[1],
getMid(points[0], points[1]),
getMid(points[1], points[2])],
depth-1)
triangle([points[2],
getMid(points[2], points[1]),
getMid(points[0], points[2])],
depth-1)
triangle(points,4)

REFs

[1]http://www.101computing.net/python-fractals/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s