User:Lucia Dossin/Protyping/Assignment 1
< User:Lucia Dossin | Protyping
Revision as of 18:07, 27 September 2013 by Lucia Dossin (talk | contribs) (Created page with "= Python & Turtle = circle.py import turtle #by changing the value of step, the resulting graphic changes #the larger step is, the less accurate the curve is (and the fas...")
Python & Turtle
circle.py
import turtle #by changing the value of step, the resulting graphic changes #the larger step is, the less accurate the curve is (and the faster the circle is rendered) step = 10 #to have a full circle path, divide 360 by the step value. int() assures the result is an integer rg = int(360 / step) for i in range(rg): turtle.forward(step) turtle.left(step) #if you print(i) you will see the number of steps that were needed to make the circle #print(i) turtle.exitonclick()
graphical result (used 60, 50, 10, 1, 0.5 and 0.1 as step)
circle_function.py
import turtle #turtle.circle(radius, extent=None, steps=None) for i in range(0, 180, 30): turtle.circle(i) turtle.exitonclick()
graphical result
circle_function_centric.py same as previous function, but reseting the turtle position so that the circles have the same center
import turtle for i in range(0, 180, 30): turtle.pd() turtle.circle(i) turtle.pu() turtle.goto(0,-i) turtle.exitonclick()
graphical result
centric_expansion.py
import turtle for i in range(360): turtle.forward(i) turtle.left(i)
graphical result