Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Turtle circle
#1
Hi everybody !

I am trying to learn Python and I got three exercises:

Write a procedure for drawing a circle given the center and radius (with turtle.circle)

Write a procedure for drawing a square, given the center, the side and the orientation

Combine procedures to draw circles inscribed in squares


Can someone help me please ?
Reply
#2
First off, you need to import the turtle module!
import turtle
Then, for your circle.
turtle.circle(radius, extent=None, steps=None)
The center is radius units left of the turtle.

extent, an angle – determines which part of the circle is drawn.
If extent is not given, draw the entire circle.

As the circle is approximated by an inscribed regular polygon, steps determine the number of steps to use. If not given, it will be calculated automatically. May be used to draw regular polygons.

So basically, to get a perfect circle,
radius = 40
turtle.circle(radius)
input()
You can change the value of the radius.

2nd assignment.

To draw a simple square,

any_num = 30
turtle.forward(any_num)
turtle.right(90)
turtle.forward(any_num)
turtle.right(90)
turtle.forward(any_num)
turtle.right(90)
turtle.forward(any_num)
input()
Third one.

Hmm, I A bit hard even for me!.
Have a nice day

~~~~~~~~~~~~~~~~~~~~~~~~~~
Why
input()
?
Otherwise, it will close immediately after drawing.
GaivSo likes this post
Reply
#3
I think you just need to draw a circle inside a square. Orientation of a square, does this mean ths square is tilted? If so, then you need set turtle heading before you draw the square.
Reply
#4
Thank you everybody !
Oshadha likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How Can I Draw Circle With Turtle İn Python ? mdm 2 2,752 Jun-03-2021, 02:07 PM
Last Post: DPaul
Photo I need help with a circle random color code and error Vxploit 4 3,015 Mar-21-2021, 07:23 PM
Last Post: jefsummers
  Calculate area of a circle pythonuser1 20 7,035 Apr-15-2020, 03:18 AM
Last Post: Skaperen
  Intersection of a triangle and a circle Gira 3 3,623 May-19-2019, 06:04 PM
Last Post: heiner55
  radius of circle question charlottecrosland 5 4,221 Sep-11-2017, 09:50 AM
Last Post: charlottecrosland

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020