I've recently started learning Python and have made a simple program to calculate the area of a circle, however, I don't like the output of the answer and wanted to know how it would be possible to limit the number of decimal places in the output for multiple variables.
Example code:
import numpy as np
rad = input("Insert the radius of your circle: ")
radius = float(rad)
area = np.pi*(radius**2)
per=2*np.pi*radius
print("The area and perimeter of your chosen circle of radius "+str(radius)+" are: "+str(area)+" and "+str(per)+" respectively")
Output I get:
Insert the radius of your circle: 56.3
The area and perimeter of your chosen circle of radius 56.3 are: 9957.87481815703 and 353.7433327942107 respectively
Output I would like:
Insert the radius of your circle: 56.3
The area and perimeter of your chosen circle of radius 56.3 are: 9957.87 and 353.74 respectively
Many thanks!