#4l: Drawing in Python {SPIRAL}
This is to inform that 'drawing in python' contents are made using "help()" and ability to explore contents.
I>
import turtle as t
def cmagic(y):
import turtle as t
t.speed(y)
x=float(0.027)
for i in range(1):
for k in range(1,38):
x=x+0.027
if x>1:
x=1
for g in range(1,36):
x=x-0.027
t.color(x,x,x)
t.fd(10)
t.right(5)
if x<1:
x=x
t.color(x,x,x)
t.fd(10)
t.right(5)
for i in range(1,37):
cmagic(0)
t.right(10)
II>
import turtle as t
import random
p=int(input('Enter number of sides of polygon: '))
t.speed(0)
g=p+1
colo=[]
for i in range(1,100,1):
colo.append(i/100)
for k in range(37):
for q in range(1,p+1):
x=random.choice(colo)
y=random.choice(colo)
z=random.choice(colo)
a=random.choice(colo)
b=random.choice(colo)
c=random.choice(colo)
t.bgcolor(a,b,c)
t.color(x,y,z)
t.fd(100)
t.right(360/(p))
t.right(10)
for j in range(37):
for i in range(1,(p+1)):
a=random.choice(colo)
b=random.choice(colo)
c=random.choice(colo)
t.bgcolor(a,b,c)
t.color(1,1,1)
t.fd(100)
t.right((360/(p)))
t.right(10)
t.bgcolor(1,1,1)
t.speed(1)
I>
import turtle as t
def cmagic(y):
import turtle as t
t.speed(y)
x=float(0.027)
for i in range(1):
for k in range(1,38):
x=x+0.027
if x>1:
x=1
for g in range(1,36):
x=x-0.027
t.color(x,x,x)
t.fd(10)
t.right(5)
if x<1:
x=x
t.color(x,x,x)
t.fd(10)
t.right(5)
for i in range(1,37):
cmagic(0)
t.right(10)
II>
import turtle as t
import random
p=int(input('Enter number of sides of polygon: '))
t.speed(0)
g=p+1
colo=[]
for i in range(1,100,1):
colo.append(i/100)
for k in range(37):
for q in range(1,p+1):
x=random.choice(colo)
y=random.choice(colo)
z=random.choice(colo)
a=random.choice(colo)
b=random.choice(colo)
c=random.choice(colo)
t.bgcolor(a,b,c)
t.color(x,y,z)
t.fd(100)
t.right(360/(p))
t.right(10)
for j in range(37):
for i in range(1,(p+1)):
a=random.choice(colo)
b=random.choice(colo)
c=random.choice(colo)
t.bgcolor(a,b,c)
t.color(1,1,1)
t.fd(100)
t.right((360/(p)))
t.right(10)
t.bgcolor(1,1,1)
t.speed(1)
III>
x=int(input('Size of spiral (larger number more number of circles in spiral): '))
g=x+1
kl=(360/x)
import turtle as t
t.pensize(5)
t.speed(0)
x=0.01
for k in range(1,g):
for i in range(1,25):
j=i/24
t.color(j,1,1)
t.fd(10)
t.right(5)
if j==1:
j=1
for i in range(1,25):
w=i/24
t.color(j,w,1)
t.fd(10)
t.right(5)
if w==1:
w=1
for i in range(1,25):
q=i/24
t.color(j,w,q)
t.fd(10)
t.right(5)
t.right(kl)
t.hideturtle()
IV>
import turtle as t
x=float(0.027)
for i in range(1,37):
t.pensize(3)
t.speed(0)
t.color('blue')
x=x+0.027
t.circle(100)
t.color(x,x,x)
t.circle(100)
t.right(10)
V>
import turtle as t
import random as r
t.speed(0)
t.penup()
t.goto(0,-300)
t.pendown()
for ki in range(0,400):
k=(ki/400)
t.color(k,k,k)
x=t.position()
t.circle((ki),360)
t.goto(0,-300)
t.goto(x)