Python turtle Tutorial : Create an amazing Tiranga badge
Tiranga badge using Python Turtle.
# first import the turtle module
import turtle
# create the turtle object
trt = turtle.Turtle()
#create the screen object
scr = turtle.Screen()
scr.setup(850,850)
# set the background color of the window (canvas) to balck
scr.bgcolor('black')
# increase the speed of the turtle
trt.speed(0)
# increase the width of the turtle
trt.pensize(5)
# now define list of colors required
colors = ['orange', 'white', 'green']
# now get into the central part of the logic
radius = 150 # initially the radius is 150px
# first define a for loop for every color
for color in colors:
# define a for loop for number of required iteration .. here we need 5
for i in range(6):
# now define the loop for drawing the circles and changing the size
for j in range(6):
trt.color(color)
trt.circle(radius) #define the variable radius for every color
trt.left(10) # shifting of every circle in degrees
radius = radius -50 # decreasing the radius after every color completion
trt.hideturtle() # hide the turtle after the completion of the diagram
turtle.done() # closing the turtle object movement
Video link : https://youtu.be/V76E6PxsD4A
Comments
Post a Comment