How to draw a semi circle(half circle) in python turtle only?
I can only use Python turtle. I have try looking for resouces but no luck on finding ones that only use Python turtle.
How to draw a semi circle(half circle) in python turtle only?
I can only use Python turtle. I have try looking for resouces but no luck on finding ones that only use Python turtle.
See Python turtle reference on circle. For example, for a semi-circle with radius 100 it would be:
import turtle
turtle.circle(100,180)
Try the following:
import turtle
t = turtle.Pen()
t.left(90)
for x in range(180):
t.forward(1)
t.right(1)
t.right(90)
t.forward(115)
you can also do it just using circle. turtle.circle(radius, extent,steps)
eg.
turtle.circle(50,180) # - step is optional
For completeness, a way to create a semicircle with turtle using stamping instead of drawing:
from turtle import Turtle, Screen
screen = Screen()
DIAMETER = 200
STAMP_SIZE = 20
BACKGROUND = screen.bgcolor()
yertle = Turtle('circle', visible=False)
yertle.penup()
yertle.shapesize(DIAMETER / STAMP_SIZE)
yertle.color('black', BACKGROUND) # drop second argument for a filled semicircle
yertle.stamp()
yertle.shape('square')
yertle.shapesize(stretch_len=(DIAMETER / 2) / STAMP_SIZE)
yertle.color(BACKGROUND)
yertle.forward(DIAMETER / 4)
yertle.stamp()
screen.exitonclick()
It has its obvious shortcomings but sometimes it's exactly what you need.
for drawing a semicircle in python turtle is very simple all you have to do is
import turtle
tom=turtle.Turtle()
tom.circle(100,180)
for the circle, the first digit is the radius of the circle and the second one is the amount that you want to draw it for a semicircle you can use 180 degrees as shown in the code above but you can do a quarter of a circle then if you want to connect the semicircle just turn left then for forward the radius*2
If You also want a line under the semicircle(like a moon), Try this
import turtle
turtle.circle(100, 180) #Draws a circle with 180 degrees and 100 pixels radius(a half circle)
turtle.left(90)
turtle.forward(200)