Use turtle’s write() function to draw the following multiplication table.
Tag Archives: loop
Connect 4 Board
Draw a connect 4 board with a few red and black pieces.
Triacontagon Wheel
In a level 2 project (https://pythonturtle.academy/triacontagon/), you drew a Triacontagon (30-gon). In this project, you are going to draw a Triacontagon Wheel. You may either use mathematical skills or use programming (hacking) skills to solve this problem.
Square Spiral
In a level 2 project, you drew 60 titled squares (https://pythonturtle.academy/60-tilted-squares/). All those squares have the same size. Change the size gradually from small to large in the iteration to draw the following shape.
60 Tilted Squares
In level 1 project: three tilted squares (https://pythonturtle.academy/three-tilted-squares/), you drew only three tilted squares. Now use a loop to draw 60 evenly spaced out squares.
Concentric Circles
In this project, you practice loop and defining custom functions.
Draw the following shape with a for loop. Define a function draw_circle(x,y,r), which draws a circle centered at (x,y) and with radius r.
Concentric Squares
In this project, you practice loop and defining custom functions. Draw the following shape with a for loop. Define a function draw_square(x,y,s), which draws a square centered at (x,y) and with side length s.
Circle Flower
In this Python Turtle Project you are going to use recursion to draw a colorful drawing as shown. You may also need to use colorsys library to convert HSV colors to RGB colors.
Circle Matrix with Python Turtle (with Solution)
In this simple python turtle project, you are going to draw a 10×10 matrix of connected circles. You can either use nested loops or define a function that draws a line of circles and and call this function in a single loop.
Solution
import turtle
def draw_circle(x,y,r):
turtle.up()
turtle.seth(0)
turtle.goto(x,y-r)
turtle.down()
turtle.circle(r)
def draw_a_line_of_circles(x,y,r,n):
for i in range(n):
draw_circle(x,y,r)
x += 2*r
turtle.setup(900,900)
turtle.title("Circle Matrix - PythonTurtle.Academy")
turtle.speed(0)
turtle.hideturtle()
y = 300
radius=30
for i in range(10):
draw_a_line_of_circles(-300,y,radius,10)
y -= radius*2
Drawing Rainbow with Python Turtle (Solution Included)
Code:
import turtle
import colorsys
def draw_one_color_arc(x,y,r,pensize,color):
turtle.up()
turtle.goto(x+r,y)
turtle.down()
turtle.seth(90)
turtle.pensize(pensize)
turtle.pencolor(color)
turtle.circle(r,180)
turtle.speed(0)
turtle.hideturtle()
turtle.bgcolor('light blue')
turtle.title('49-Color Rainbow')
turtle.setup(700,700)
num_colors = 49
radius = 300
penwidth = 20*7/num_colors
hue = 0
for i in range(num_colors):
(r,g,b) = colorsys.hsv_to_rgb(hue,1,1)
draw_one_color_arc(0,-100,radius,penwidth,(r,g,b))
radius -= (penwidth-1) #overlapping a little removes the gaps
hue += 0.9/num_colors
Related Projects: