forked from UTSAVS26/PyVerse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
turtle_spiral.py
30 lines (24 loc) · 984 Bytes
/
turtle_spiral.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import turtle as t
# Setup the display window where turtle will draw
window = t.Screen()
# Configure Screen size
window.setup(800,800)
#set the speed of turtle
t.speed(50)
# Set background color
t.bgcolor('black')
# Define a function to draw spiral with total steps and list of colors
def spiral(steps,color_list):
for step in range(steps):
for c in color_list:
t.width(step/50 ) # Set pattern width
t.color(c) # Set's turtle color
t.forward(step) # Move the turtle forward by "steps"
t.left(30) # Turn the turtle 30 degree to left
if __name__ == '__main__':
print("Sprial printing!!")
total_steps = int(input("enter no. of steps: "))
# split(',') denotes split input of colors string into list
color_list = input("enter the list of colors separated by commas: ").split(',')
spiral(total_steps,color_list)
t.done()