4.1. Draw a draw box

4.1.1. Simple Version

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
'''
The simple way to draw a box
'''

from unifeatherbot import UniFeatherBot
bot = UniFeatherBot()

bot.pendown()

bot.forward(30)
bot.left(90)

bot.forward(30)
bot.left(90)

bot.forward(30)
bot.left(90)

bot.forward(30)
bot.left(90)

bot.done()

4.1.2. Better way to draw a box

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
'''
Better way to draw a box
'''

from turtleplotbot import TurtlePlotBot
bot = TurtlePlotBot()

bot.pendown()

for _ in range(4):
    bot.forward(30)
    bot.left(90)

bot.done()

4.1.3. Even better way to draw a box

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
'''
Even better way to draw boxes
'''

from unifeatherbot import UniFeatherBot
bot = UniFeatherBot()

def box(bot, size):
    bot.pendown()

    for _ in range(4):
        bot.forward(size)
        bot.left(90)

    bot.penup()

box(bot, 10)
box(bot, 20)
box(bot, 30)

bot.done()