Hello guys and welcome to Python programming
tutorials by Amuls Academy. So in the previous tutorial we draw a pattern
using turtle module, right?, so in this tutorial also we are doing the same we are doing few
pattern using turtle module. So the first pattern is this. I want to draw
four circle ok, i want to fill the color ok this is the simple pattern.
so now we will see how to do this. so in a Python file first thing is, we need
to import the turtle module, next i need to create a turtle object so i will give name
as “t”, from The Turtle class done. so in the output we want to draw four circles
and we want to fill the color right?, so for that what I’ll do is, I’ll take a list and
in that I’ll take the colors as its elements ok so for example “list1” here I’ll take the
first element as “yellow” color, next i want “red”, next i want “blue”, next i want “green”
ok any color. I want four circle ok so that’s why i took
4 colors, here i took basic colors. so now if i save this and run this we can
see the turtle in the home position. I don’t want to draw Circle from here so I’ll move
forward some distance and I’ll start drawing the circle ok, so if i forward the turtle
by 200 pixel then it will come somewhere here, then i will draw the circle ok so at that
time while moving from home position to 200 pixel distance, i don’t want to draw the line
so here first “t dot up” and next “t dot goto” x y co-ordinate, i need to mention, i will
take x as 200 y as zero. so x is 200 y is 0 alright. So next i want four circles right?, so that’s
why i will use loops ok so here i will take “for i in range”, four because i want four
circle i want to execute this for loop four times, ok so first one is, i will do “t.down”
because here initially we did t.up ok so that’s why “t.down”, next here t.circle that is nothing
but draw a circle of 50 radius ok done, so here i am taking 50 radius ok if you want
you can change that also and here I’ll take “t.bk” ok that is nothing but move backwards
of 100 distance, so here i will do “t.up” because i don’t want to draw the line when
we move backwards ok that’s why. So i will show you the output now, you will get to know
about that. right?, we got the 4 circles.
Previously The Turtle was in the home position here i don’t want it to draw the circle from
the home position so what i did is, i moved 100 pixel distance ok and then i started to
draw the circle, i took the radius as 50, if radius is 50 then this distance is 100
right?, so we will get 100, so this distance is hundred, so now turtle is here OK it will
draw the circle of 50 radius ok so we will get this circle, next i used backward method
so turtle will move here so the distance is hundred, so it will move here and it will
draw the circle ok after that i moved backwards again so it will go here and it will draw
the circle, again it will go here and it will draw the circle ok so that’s why i took like
this. Next here i need to fill the color also right?,
so t.begin_fill, t.fillcolor, so here i will take fill color as list1 of i. Ok so i value
can be 0 1 2 3 right?, here using range we can see, so list1 means it is yellow, list
means it is red, 2 means blue, 3 means green ok it will print like that.
Ok so here t.endfill, after drawing the circle. Ok so next here if you want you can change
the radius of circle also, if i do this, we can see the bigger circle of 100 radius,
so it will overlap and we will get like this. ok so we can do different pattern using this
code, and here instead of filling the color, what i will do is, i will change the color
of the turtle ok, here t.color that means it will change the turtle color right?, so
here i will take list1 of i, and i will take pensize as 20, ok so pen size as 20 ok so
now if i save this and run this, ok so we can do like this also, instead of
filling the color we can change the turtle color itself ok.
this is the one pattern here we can do few changes to this program and we can get different
patterns ok so you can try that. ok so next we will move on to the next pattern.
I was searching something in the online and i got this pattern it looks so nice on the
screen that’s why i wanted to show you all. so first I’ll show you the output then we’ll
see how to write the program ok. ok so this is the output guys and it look
so nice right?, so to draw this pattern first you need to
remember here we can see the different color ok this is the turtle color, so i want to
change the turtle color, as well as we can see the thickness here initially the thickness
is less but here we can see the line thickness is more. I need to vary The Turtle thickness
also . ok so now we will draw this pattern ok.
ok so so i will import the turtle module, i will create a turtle object and I’ll take
list1 and I’ll take five colors because in the output we saw 5 colors ok.
So here i don’t want “yellow”, i’ll take it green, ok so green is there right?,purple,
blue is there, red is there, orange we can take Orange right?, so here after red I’ll
take orange. Ok so i took 5 colors here basic colors.
So next thing is, i will take for loop ok, here i want to run this for loop 200 times
ok, that means i want to run this several times, you can take 200, 300, 500 ok.
So next thing is, first is the turtle color right?, i want to change the turtle color
here, i am not filling the color right?, i am changing the turtle color, so for that
t.color and here list1 of i modulus 5, ok why i tooks list1 of i modulus 5, so whenever
i use %5 that means i value can be anything ok it can be 100, 150 or 50 , ok if i do %5
that means it will give output as 0 1 2 3 4.
Ok so that is nothing but list1 of 0 1 2 3 4, so that is nothing but the index of these
colors, purple is 0, red is 1, orange is 2, blue is 3 and green is 4.
ok so that’s why i wrote like this, i%5 there are 5 colors are there that is why %5 ok.
So next i need to change the pen size, ok so here i want to vary the line size right?,
or turtle size pen size. Ok so for that i will just write i/10 plus
1 ok. So the thickness will depend on the i value
ok, i wrote like this, if you ask why i write like this, you can change this value and you
can try but this size will work properly that’s why i took this ok if you want you can change
and experiment with this. so next is I’ll do is, t.forward of i distance
ok. if i is 0, move 0 distance, if i is Hundred
move 100 distance, ok 100 pixel forward ok. so next I’ll take an angle because i don’t
want to draw in a single line right?, so that’s why here I’ll take 59 as the angle, if you
want you can change and you can experiment with this.
so now if i save this and run this. if you want you can include more colors.
ok so done and we got this Output ok it looks so nice right?, so in this way you can draw
this pattern and if you want you can experiment here you can change the pen size, color and
this forward distance as well as angle and you can include more colors and you can try
ok so do experiment with this program and you can get the different patterns, so that’s
it for now guys thank you for watching don’t forget to subscribe to my channel I will meet
you next class till then take care.