Page 19 - 2501_KVS_C-6
P. 19

1.4.2 Shortened Versions of Directions

                     Aryan:  Do I need to write forward, backward, left, and right every time I want to draw a
                     shape? Or is there a shortcut too?
                     Gowri: Ohh..Sorry I forgot to tell you.. you may use following shortened forms of the above
                     commands.. they will produce the same result.
                     T.fd(n) – instead of turtle.forward(n)

                             e.g. t.fd(100)
                             T.bk(n) – instead of turtle.backward(n)
                         Ø
                             e.g. t.bk(100)

                             T.lt(degree) – instead of turtle.left(degree)
                         Ø
                             e.g. t.lt(90)

                             T.rt(degree) – instead of turtle.right(degree)
                         Ø
                             e.g. t.rt(90)

                     Gowri: You now can write your codes using any of the methods that you like.

                 While writing codes, make sure that t is the name of your turtle object. If you used pen = turtle.
                 Turtle(), then use pen.fd(100), pen.bk(100), and so on.

                 1.4.3 Home and Quadrants


                     Aryan: I want to learn the figure about quadrants in detail..could you please help?

                     Gowri: Sure! When you open the Python Turtle software, the starting position of the turtle is
                     at (0, 0).

                 From the fig. 1.3 we see that there are four quadrants ..means four parts ..x means horizontal
                 and y means vertical ..If we move up then y increases and if we move down then y decreases.
                 Similarly if we move right x increases and if we move left y decreases. These directions

                 help you understand where and how the turtle moves on the canvas from its home point.
                 To go to any quadrant you can use the following command:

                 turtle.goto(x,y)

                 for example: pen.goto(10,20)

                 1.5 DRAWING POLYGONS

                 A command tells the turtle to do exactly what we want, so it is an instruction.

                     Aryan:  I’ve understood the commands for moving the turtle and changing its directions.
                 I think I can now show you how to draw various geometrical figures. Shall I?

                     Gowri: Yes, dear! Go ahead and show me, please.




                                                                                 Python Turtle                      17
   14   15   16   17   18   19   20   21   22   23   24