Python Forum
Making turtle draw a sine wave recursively - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code sharing (https://python-forum.io/forum-5.html)
+--- Thread: Making turtle draw a sine wave recursively (/thread-13979.html)



Making turtle draw a sine wave recursively - rootVIII - Nov-09-2018

Definitely worth running once Rolleyes

#! /usr/bin/python3
# Recursively drawing a sine wave
from turtle import *
import time
import math


def draw_sine(x):
    if not x < 50:
        print("done")
    else:
        y = 30 * math.sin(.5 * x)
        setx(x)
        sety(y)
        penup()
        goto(x, y)
        dot()
        pendown()
        draw_sine(x + .25)

if __name__ == "__main__":
    x = -50
    penup()
    draw_sine(x)
    time.sleep(100)



RE: Making turtle draw a sine wave recursively - heiner55 - May-23-2019

Nice job.


RE: Making turtle draw a sine wave recursively - rootVIII - Jun-09-2019

Thank you kindly Wink