Star Python Code

Star Python Code With 3 Different Ways

Here you find Star Python Code With 3 Different Ways with turtle code then you need to just copy and paste it into the code editor, Hello my dear python lovers Today in this article I want to share 3 Different Ways how to make a star in Python with GUI ( Graphically User Interface ), golden and black colours with for loop, while loop and without loop. This is the python projectCode If you have any other requests or project ideas then please share them with YouTube Channel.

Please note: If you want only the final code please jump to the Final code see below table of contents.

Without Loop

# Draw the star shape With our loop
t.forward(200)
t.right(144)
t.forward(200)
t.right(144)
t.forward(200)
t.right(144)
t.forward(200)
t.right(144)
t.forward(200)
t.right(144)

While Loop

# Draw the star shape in while loop
count = 0
while count < 5:
    t.forward(200)
    t.right(144)
    count += 1

For Loop

# Draw the star shape in for loop
for i in range(5):
    t.forward(200)
    t.right(144)

Final Code

import turtle

# Set the background color to black
turtle.bgcolor("black")

# Create a turtle object
t = turtle.Turtle()

# Move the turtle to the starting position
t.penup()
t.goto(-100, 0)
t.pendown()

# Set the color and thickness of the pen
t.pencolor("gold")
t.pensize(3)

# Set the fill color of the star to gold
t.fillcolor("gold")

# Begin filling the star
t.begin_fill()

# Draw the star shape With our loop
# t.forward(200)
# t.right(144)
# t.forward(200)
# t.right(144)
# t.forward(200)
# t.right(144)
# t.forward(200)
# t.right(144)
# t.forward(200)
# t.right(144)

# Draw the star shape in while loop
# count = 0
# while count < 5:
#     t.forward(200)
#     t.right(144)
#     count += 1

# Draw the star shape in for loop
for i in range(5):
    t.forward(200)
    t.right(144)


# End filling the star
t.end_fill()

# Hide the turtle when finished
t.hideturtle()

# Keep the window open until it is closed manually
turtle.done()

How To make start in turtle?

t.forward(200)
t.right(144)
t.forward(200)
t.right(144)
t.forward(200)
t.right(144)
t.forward(200)
t.right(144)
t.forward(200)
t.right(144)

How to turtle Keep the window open until it is closed manually?

Use below command for turtle window,
turtle.done()

Another Programmer For Coders:-

How to Make I Love You Programme in python?

How to make a love symbol In Java?

Scroll to Top
Mother’s Day Python Code Love calculator Miss Universe And You Check Your Love Score With K-POP Idols Check Your Love Score With Childhood Crush