Star with 6 points (Python/Turtle)

vegaseat

Just in time for the season, a star.
(Playing with my grandson on the Raspberry Pi computer)

3,649 Views
About the Author

Scientist

''' turtle_star_six.py
draw a star with six points using Python module turtle
'''

import turtle as tu

def draw_star(x, y, side):
    star_angle = 360.0/6
    left_angle = star_angle * 2
    tu.penup()
    # start drawing here (default is center x=0, y=0)
    tu.goto(x, y)
    tu.pendown()
    for k in range(6):
        tu.forward(side)
        tu.right(star_angle)
        tu.forward(side)
        tu.left(left_angle)

x = -150
y = -50
side = 100
draw_star(x, y, side)

tu.done()
sneekula 969 Nearly a Posting Maven

What does tu.done() do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.