Hello guys and welcome to Python Programming
tutorials by Amuls Academy. In the previous turtle tutorial we discussed
about how to draw different shapes like circle and square shape but till now whatever the
image we drawn, it is from the home position right. But if you want to draw in different position
then how to do that?. In this tutorial we are discussing about that
ok, so first i’ll import the turtle module, next
i will create a turtle object you can give any name.
alright so now we can see the screen here .
Alright this is the turtle. So now if i want to draw the circle, if i mention circle, if
i mention the radius as 100 it will draw from the home position here we can see right.
if i give the negative radius it will draw in the clockwise direction but it will start
from the home position itself but i don’t want that now ok.
for example, i will show you an image here we can see i want to draw a circle and here
the center of the circle must be the home position of the Turtle ok.
so i want to draw like this then how to do this? so you can do this in different ways
ok so first i will “undo” , you can use undo also here like this, ok it will undo
the operation and or you can go for the reset also . so now i will take right 90 degree ok, so
i will set the heading to 90°, now it is pointing towards this side here we can see.
so now forward if i want to draw a circle of 100 radius ok so i will move turtle to
100 pixel distance ok, now i will set this to again 90 degree ok so i will draw the circle.
now here we can see we draw a circle and here the center of the circle is home position
of the turtle ok. But here we can see an extra line also here
we used this 4 steps to do this, instead of this 4 step we can do this using single line
also , there is a method called “go to” which will do this work.
Like i will show you , i will reset this ok and now i will mention goto and here i need
to mention that x coordinate as well as y coordinate.
So here we can see i want to move the turtle to here ok in the 0 x , x coordinate as 0
and i’ll take y as -100. So now if i enter here we can see, it will
move to that position. so now if i use circle of 100 it will draw
the circle ok. so instead of writing these 4 step, in 2 step
i can do that. But in both these method there is a problem
that extra line, i don’t want this right i want to draw simple circle, I don’t want this
line. so while drawing some shapes using turtle
sometimes we want to draw the line while turtle is moving and sometimes we don’t want to draw
the line while turtle moving. for example at the beginning when turtle is
moving from this to this ok so i don’t want this line ok so you can get this using two
method called as “up and down”. So i can tell the turtle when to draw while
moving and when not to draw while moving ok. so for example, i will take t.up so if i use
t.up then while turtle moving it won’t draw the line ok so if you want to see that you
can see this. ok i will goto 0 and -100 , ok so if i enter
now here we can see there is no line ok so it won’t draw any line, so now if i go for
t.circle and radius it won’t draw any circle that means you can’t see any line because
turtle is up now right. That’s why we can’t see any line. If you want to draw the line now, you need
to do is t.down ok, now if i write circle and 100 here we can see the line.
And here we can see we draw the circle and here the center of the circle is the home
position of the turtle. so using this up and down method you can draw
the desired shape in any position ok . so for example, we will take another example
ok so i will take first t as up ok while moving to the position i don’t want draw any line
so t.up So i will use goto, i will take x as 100 y
as 100 ok so now this is the position so now here i can draw circle or square whatever
you want. Here I am taking circle because this method
is easy to use right that’s why. Ok so you should do this t. down ok .
Ok here we can see we draw the shape here. So in any position you can draw this using
this method. So In this tutorial we get know about the
undo method, goto method , up and down method. So first here,
Ok so this is about the undo, it will undo the last turtle action.
ok so you should mention turtle name dot undo ok .
so next we discussed about the goto. ok so this is the information about the goto,
it will move the turtle to an absolute position OK Here X and Y.
so this is the X co-ordinate value this is Y co-ordinate value if you didn’t mention
the Y co-ordinate value it will by default take none.
but you should mention the X co-ordinate value ok.
aliases you can instead of goto you can use “set position” “setpos” ok. These
are the aliases. X is the number , y is the number.
so it will move The Turtle to the absolute position alright. Next we discussed about the up, so this pull
the pen up no drawing when moving OK when the turtle is moving it won’t draw anything
ok. Aliases penup pu or up alright.
So Here the Turtle is also called as Pen. Ok so if you are creating a turtle object
instead of using Turtle class you can use Pen class also ok Turtle aliases Pen. for example while creating a turtle, so if
i take “a turtle dot Pen “ if you do this also it will create a turtle, here you can
see it will create a turtle ok. So here this up is also called as penup pu
or up. but in this tutorial mostly i will use up
because it is easy to use ok . So next is down ok it will draw when turtle
is moving that’s it. Ok so pull the pen down drawing when moving.
It can be written as pendown pd or down. Ok this is how we can draw different shape
in the different position. so in the next tutorial i’ll take one example
which contains all this method and we’ll see the output.
ok so that’s it for now guys thank you for watching don’t forget to subscribe to my channel
i will meet you in next class till then take care.