from Turtle import Turtle import argparse from math import sin, radians if __name__ == "__main__": parser = argparse.ArgumentParser(description='Draw a pointed start') parser.add_argument('n', type=int, help='number of sides of the star : odd number') args = parser.parse_args() n = args.n # t = Turtle(0.5,0.1, 180/n) t = Turtle(0.5, 0.1, 180 / n * 6) size = sin(radians(180 / n)) for i in range(n): t.go_forward(size) t.turn_left(-360 / n * 2) print(t._lines) t.draw()
from Turtle import Turtle import argparse from math import sin, radians import random if __name__ == "__main__": parser = argparse.ArgumentParser( description='Drunken turtle : study of brownian motion') parser.add_argument('step_size', type=float, help='size of each step') parser.add_argument('nb_steps', type=int, help='number of steps') args = parser.parse_args() step_size = args.step_size nb_steps = args.nb_steps t = Turtle(0.5, 0.5, 0) for i in range(nb_steps): t.turn_left(random.random() * 360) t.go_forward(step_size) t.draw()