#!/usr/bin/python2.7 from turtle import * # Create a turtle named Tommy: tommy = Turtle() tommy.shape("turtle") tommy.speed(7) def draw_circle(turtle, color, size, x, y): turtle.penup() turtle.color(color) turtle.fillcolor(color) turtle.goto(x,y) turtle.pendown() turtle.begin_fill() turtle.circle(size) turtle.end_fill() def draw_triangle(turtle, color, size, x, y): turtle.penup() turtle.color(color) turtle.fillcolor(color) turtle.goto(x,y) turtle.pendown() turtle.begin_fill() for i in range (3): turtle.forward(size*3) turtle.left(120) turtle.end_fill() turtle.setheading(0) def draw_square(turtle, color, size, x, y): turtle.penup() turtle.color(color) turtle.fillcolor(color) turtle.goto(x,y) turtle.pendown() turtle.begin_fill() for i in range (4): turtle.forward(size*2) turtle.left(90) turtle.end_fill() turtle.setheading(0) def draw_star(turtle, color, size, x, y): turtle.penup() turtle.color(color) turtle.fillcolor(color) turtle.goto(x,y) turtle.pendown() turtle.begin_fill() turtle.right(144) for i in range(5): turtle.forward(size*2) turtle.right(144) turtle.forward(size*2) turtle.end_fill() turtle.setheading(0) # Draw three circles: draw_circle(tommy, "green", 50, 25, 0) draw_circle(tommy, "blue", 50, 0, 0) draw_circle(tommy, "yellow", 50, -25, 0) # Write a little message: tommy.penup() tommy.goto(0,-50) tommy.color("black") tommy.write("Teach With Code!", None, "center", "16pt bold") tommy.goto(0,-80)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question