Bottom Page

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.
Quote
#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()
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Help adding items to a glossary lga13 2 113 Jan-08-2019, 06:39 AM
Last Post: perfringo
  How do I make my plot show up? ThomasM4 0 114 Dec-09-2018, 05:28 AM
Last Post: ThomasM4
  Tips on surface plot HW question Cwcox 1 180 Nov-14-2018, 11:45 PM
Last Post: Larz60+
  How to customize x axis in matplotlib.pyplot for a scatter plot? wlsa 9 352 Nov-10-2018, 01:32 AM
Last Post: wlsa
  Adding values to list and pickling mefiak 2 379 May-31-2018, 08:57 AM
Last Post: mefiak
  plot the mean in a bar diagram sussii 3 385 May-23-2018, 11:27 PM
Last Post: wavic
  How to plot date series in matplotlib? StrybolData 2 1,626 Jan-25-2018, 07:13 PM
Last Post: StrybolData
  adding a number to the list atux_null 4 771 Nov-06-2017, 07:01 PM
Last Post: gruntfutuk
  text = str(text.encode('utf-8')) AttributeError: 'float' object has no attribute 'enc ulrich48155 2 2,702 Jul-31-2017, 05:21 PM
Last Post: ulrich48155
  adding to code but still getting same output Crackity 7 1,292 Jul-12-2017, 02:36 PM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)