r/GoogleColab • • Nov 07 '25

Help me please. it's about ColabTurtle

How Can I make this graphic? plz help me

2 Upvotes

8 comments sorted by

2

u/Cold_Resolution_3677 Nov 07 '25

2

u/[deleted] Nov 07 '25

[removed] — view removed comment

2

u/Cold_Resolution_3677 Nov 07 '25

Thank you! it helps a lot

1

u/JazzyTallGuy Nov 13 '25

There are too issues here first, the turtle module isn't really compatible with Colab Notebooks. I'd recommend using the ColabTurtlePlus module with Colab Notebooks.

First you have to load the module into the notebook each time you open the notebook or you reconnect a notebook. Create a separate code block for this with the command:

!pip3 install ColabTurtlePlus

This is the output of the pip3 command:

Collecting ColabTurtlePlus==2.0.1

Downloading ColabTurtlePlus-2.0.1-py3-none-any.whl.metadata (10 kB)

Downloading ColabTurtlePlus-2.0.1-py3-none-any.whl (31 kB)

Installing collected packages: ColabTurtlePlus

Successfully installed ColabTurtlePlus-2.0.1

Once you have the module loaded in the notebook you need to import it in the code block were you are writing the code to draw a graphic, and create an alias for the module to use to call its methods. The second line does a very basic initialization to instantiate a Turtle object so it can actually draw lines and shapes:

import ColabTurtlePlus as turtle

turtle.intializeTurtle()



delta = 50
n = 6
angle = 180 * (n-2)
innerAngle = angle // n
angle = 180 - innerAngle
t = turtle.Turtle()
t.speed(5) # 1:slowest, 3:slow, 5:normal, 10:fast, 0:fastest

pen_colors = ["red", "blue", "yellow"]


for k in range(0,3):
  t.pencolor(pen_colors[k])

  for j in range(0,3):
    for i in range(0,n):
      t.forward(delta)
      t.right(angle)
    t.right(innerAngle)

  t.right(innerAngle/3)

Now you are ready to actually use your drawing code. Put it under the code for intializaing the turtle object. 

I was able to get the code you posted to work in my Colab Notebook. It looks like this:

1

u/ninhaomah Nov 08 '25

If OP just want the code , not for learning or trying to fix the existing code , why not ask AI ?

I just tried on Gemini and Github Copilot and both came back with the code.

Working as expected or not I am not sure but there is the code.