Skip to content

Instantly share code, notes, and snippets.

@slaiyer
Last active August 8, 2025 23:21
Show Gist options
  • Select an option

  • Save slaiyer/9cc4ec17c8f9c178a873ed61725e77d3 to your computer and use it in GitHub Desktop.

Select an option

Save slaiyer/9cc4ec17c8f9c178a873ed61725e77d3 to your computer and use it in GitHub Desktop.
Euler's identity
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "numpy",
# "PythonTurtle",
# ]
# ///
# `brew install python-tk`
import math
import numpy
from turtle import *
def euler(unit):
d_r_90 = math.pi / 2
arc_length = math.pi * unit
unit_inv = 1 / unit
penup()
forward(unit)
left(d_r_90)
pendown()
for _ in numpy.linspace(start=0, stop=arc_length, num=math.floor(arc_length)):
forward(1)
left(unit_inv)
left(d_r_90)
for _ in range(unit * 2):
forward(0.5)
if __name__ == '__main__':
bgcolor('black')
hideturtle()
title("Euler's identity")
speed('fastest')
pencolor('green')
width(2)
radians()
euler(100)
exitonclick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment