Hello, I need some help with this homework problem. Define a function named drawsquare. This function expects a Turtle object, a pair of integers that indicates the coordinates of the square’s upper left corner, and an integer that designates the length of aside. The function begins by lifting the turtle up and moving to the square’s corner point. It then points the turtle south at 270 degrees and places the turtle pen down on the drawing surface. Finally, it moves the turtle to the given length and turns it left 90 degrees four times. here's what I have with a circle assignment I have done but building off from that. Any assistance would be greatly appreciated. import math from turtle import Turtle, tracer, update print("\n-------Circle-------") def drawCircle(t, x, y, radius): """Draws a line segment between the endpoints.""" t.up() t.goto(x + radius, y) t.setheading(90) t.down() t.pencolor("blue") t.fillcolor("red") t.begin_fill() t.speed(3) t.hideturtle() for count in range(120): t.left(3) t.forward(2.0*math.pi*radius/120.0) t.end_fill() def main(): x = int(input("Enter the x coordinator for the center point: ")) y = int(input("Enter the y coordinator for the center point: ")) radius = int(input("Enter the radius: ")) drawCircle(Turtle(), x, y, radius) if __name__ == "__main__": main()
Hello, I need some help with this homework problem.
Define a function named drawsquare. This function expects a Turtle object, a pair of integers that indicates the coordinates of the square’s upper left corner, and an integer that designates the length of aside. The function begins by lifting the turtle up and moving to the square’s corner point. It then points the turtle south at 270 degrees and places the turtle pen down on the drawing surface. Finally, it moves the turtle to the given length and turns it left 90 degrees four times.
here's what I have with a circle assignment I have done but building off from that. Any assistance would be greatly appreciated.
import math
from turtle import Turtle, tracer, update
print("\n-------Circle-------")
def drawCircle(t, x, y, radius):
"""Draws a line segment between the endpoints."""
t.up()
t.goto(x + radius, y)
t.setheading(90)
t.down()
t.pencolor("blue")
t.fillcolor("red")
t.begin_fill()
t.speed(3)
t.hideturtle()
for count in range(120):
t.left(3)
t.forward(2.0*math.pi*radius/120.0)
t.end_fill()
def main():
x = int(input("Enter the x coordinator for the center point: "))
y = int(input("Enter the y coordinator for the center point: "))
radius = int(input("Enter the radius: "))
drawCircle(Turtle(), x, y, radius)
if __name__ == "__main__":
main()
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images