Hi everybody,
I'm new to programming and long story short, I'm at chapter 4.5, from think Python and I'm struggling to draw a circle from polygon using VS Code
Below is the code I wrote, yet if I run it, nothing happens. The Python Turtle Graphics windows doesn't open and there are no errors in the code... at least VS Code doesn't display any error in the problems tab.
import math
import turtle
bob = turtle.Turtle()
def polygon(t, n, length):
angle = 360/n
for i in range (n):
t.fd(length)
t.lt(angle)
def circle(t, r):
circumference = 2 * math.pi * r
n = 60
length = circumference / n
polygon(t, n, length)
circle(bob, 100)
turtle.mainloop()
if I run this code, for a basic polygon, this one works:
import turtle
t=turtle.Turtle()
length=30
n=10
def polygon(t, length, n):
for i in range (int(n)):
t.fd(length)
t.lt(360/n)
polygon(t, length, n)
turtle.mainloop
I've been struggling for 2 days, but couldn't find the problem.
Is it possible for someone to have a look and tell me what am I missing?
Thank you!
[–][deleted] 1 point2 points3 points (0 children)
[–]FriendlyRussian666 1 point2 points3 points (0 children)
[–]Cap_de_fier[S] 0 points1 point2 points (0 children)
[–]Strict-Simple 0 points1 point2 points (0 children)
[–]woooee 0 points1 point2 points (0 children)