In Python, create a calculator that will ask the user to input a single dimension of a shape and then display its properties.

E.g. Enter the radius of a circle; Display the circle’s Diameter, Circumference and Area

Only done for square and circle.

Respuesta :

The code is given in the explanation section.

Explanation:

def areacalcpy():

   _input_ = input("Enter the shape that you wish to calculate the area: ")

   shapearea = 0

   pieval = 3.14

   if _input_ == "Square":

       sideval = int(input("Enter side value of the shape: "))

       shapearea = shapearea + (sideval ** 2)

   elif _input_ == "Circle":

       circleradius = int(input("Enter radius value of the circle: "))

       shapearea = shapearea + (2 * pieval * circleradius)

   else:

       print ("The given shape is invalid, give a valid shape to calculate area")

   print ("%.2f" % shapearea)

areacalcpy()

The given code can calculate the area for both the shapes circle and square.

Similarly the area can be calculated for triangle and rectangle.