Adding text to plot - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Adding text to plot (/thread-12764.html) |
Adding text to plot - Pythcoronas - Sep-11-2018 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. RE: Adding text to plot - baby_quant - Sep-13-2018 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() |