How to create P shape in turtle and make it increasingly bigger? and how to make mutiple P shape rotate along a circular path.
What code do you have so far?
Create a function which walks the turtle in a P-shape.
Work-out which factors must change to draw a larger P, and make those parameters of the function.
Write a loop which progressively calls the function with ‘bigger’ parameters.
Find the factor(s) which decide the starting-point of the P.
Make that/those parameters.
Write another loop which alters the start-position along the ‘circular path’.
…
i don’t know how start
Which web-page, training course, or text-book are you using to learn?
Hey Jeff what @d_n is asking have you tried to attempt it at least? Have you tried any other shapes or drawings?..nywy but it seems you don’t how to get started… I also didn’t know about this package lol… I tried this maybe it can trigger your mind but I bet there are much nicer ways to get it done
import turtle
# Create a Turtle screen
screen = turtle.Screen()
screen.bgcolor("green")
# Create a Turtle object
pen = turtle.Turtle()
pen.speed(1) # setset the drawing speed
# for you to draw the letter p you draw a semi circle first then a straight line going downwards
radius = 60
print('the starting position' + str(pen.position())) #
pen.circle(radius, 180) # draw the semi circle first
pen.left(90) # then turn left at 90 deegrees i.e. a right angle turn
pen.forward(180) # then this draws a straight line
print('the last position' + str(pen.position()))
# Close the Turtle graphics window when clicked
screen.exitonclick()
And as for increasing the size of the letter P needs a little bit of logic which I couldn’t wrap my head around it. If you could think of a way of getting the pen(our turtle object) up and moving it to the starting point, then repeat the process but with an increasing in size… nywy think of how you can modify the following two codes
# draws a unique shape of 4 P'S increasing in size
import turtle
# Create a Turtle screen
screen = turtle.Screen()
screen.bgcolor("green")
# Create a Turtle object
pen = turtle.Turtle()
pen.speed(1) # Set the drawing speed
# Function to draw the letter "P"
def draw_p(size):
pen.circle(size, 180)
pen.left(90)
pen.forward(180)
# pen.left(90)
# Draw multiple "P" shapes of increasing sizes
for size in range(100): # Adjust the range as needed
draw_p(size)
# Close the Turtle graphics window when clicked
screen.exitonclick()
Then there is this other one… i’ve tried resetting the position to the initial position after every drawing but still not getting the desired result
import turtle
# Create a Turtle screen
screen = turtle.Screen()
screen.bgcolor("green")
# Create a Turtle object
pen = turtle.Turtle()
pen.speed(1) # Set the drawing speed
# straightline_increment = 180
radius = 40
starting_position = pen.position()
for increment in range(100):
# starting_point += 10
print('the starting position' + str(pen.position()))
pen.circle(radius, 180)
pen.left(90)
pen.forward(180)
print('the last position' + str(pen.position()))
# straightline_increment += 10
# pen.up()
pen.setposition(starting_position)
# Close the Turtle graphics window when clicked
screen.exitonclick()
Nywho for more resources and much cooler stuff check out geeks for geeks