draw the brazilian flag in python

To draw the Brazilian flag inpython, you can use the turtle graphics library. Here's the code:

main.py
import turtle

# set up the turtle
t = turtle.Turtle()
t.speed(0) # fastest

# draw the green background of the flag
t.penup()
t.goto(-300, 200)
t.pendown()
t.color("green")
t.begin_fill()
t.goto(300, 200)
t.goto(300, -200)
t.goto(-300, -200)
t.goto(-300, 200)
t.end_fill()

# draw the yellow diamond in the center
t.penup()
t.goto(0, 80)
t.pendown()
t.color("yellow")
t.begin_fill()
t.goto(-80, 0)
t.goto(0, -80)
t.goto(80, 0)
t.goto(0, 80)
t.end_fill()

# draw the blue circle in the diamond
t.penup()
t.goto(0, 60)
t.pendown()
t.color("dark blue")
t.begin_fill()
t.circle(-60)
t.end_fill()

# draw the white stars inside the circle
t.penup()
t.goto(0, 20)
t.pendown()
t.color("white")
for i in range(5):
    t.forward(60)
    t.backward(60)
    t.left(72)
    
# hide the turtle when finished
t.hideturtle()
turtle.done()
825 chars
53 lines

This will create a turtle window with the Brazilian flag drawn inside it.

gistlibby LogSnag