Python Forum

Full Version: Adding text to plot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am asked to plot a circle with user's input of radius, and display the area of the circle next to it on the plot. I know how to set up the whole thing but I don't know how to print on plot.
This is the code up till now:

import turtle
from math import pi
import math
r = float(input ("Input the radius of the circle : "))
print ("The area of the circle with radius " + str® + " is: " + str(pi * r**2))
turtle.circle®

I'm still a newbie and I'm taking a class in Python for the first time.
Use something like this:

import turtle  # importing the module
from math import pi
radius=float(input("Enter radius of the circle: \n"))
area=pi*(radius**2)
trtl = turtle.Turtle()    #making a turtle object of Turtle class for drawing
trtl.pencolor('black')    #making colour of the pen red
trtl.speed(10)
trtl.circle(radius) 
turtle.exitonclick()