4.3. Draw a polygonΒΆ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'''
Draw a `n` sided polygon
'''

from unifeatherbot import UniFeatherBot
bot = UniFeatherBot()

def polygon(bot, sides, length):
    '''
    Draw a 'sides' sided polygon

    Args:
        sides: number of sides in polygon
        length: length of eacg side
    '''
    angle = 360 / sides
    bot.pendown()
    for _ in range(sides):
        bot.forward(length)
        bot.right(angle)

    bot.penup()

polygon(bot, 8, 20)
bot.done()