Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding text to plot
#1
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.
Reply
#2
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation URGENT: How to plot data from text file. Trying to recreate plots from MATLAB JamieAl 4 3,549 Dec-03-2023, 06:56 AM
Last Post: Pedroski55
  Split string into 160-character chunks while adding text to each part iambobbiekings 9 9,606 Jan-27-2021, 08:15 AM
Last Post: iambobbiekings
  Adding text to files easy but I need help bodo1025 2 4,340 Mar-08-2017, 09:53 AM
Last Post: merlem

Forum Jump:

User Panel Messages

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