I was looking at the last exerciese that prof. Mancini published on replit and i was wondering if anyone could think of a more efficent and simpler way to implement its solution.

My code is the following:

import math

def AreaCalculator():

type_of_figure = input("First of all write what kind of shape: ")

if type_of_figure == "circle":

radius = int(input("What is the radius of this circle? "))

return math.pi*radius**2

elif type_of_figure == "square":

side = int(input("What is the side of the square? "))

return side**2

elif type_of_figure == "rectangle":

greater_side = int(input("What is the greater side of the rectangle? "))

smaller_side = int(input("What is the smaller side of the rectangle? "))

return greater_side*smaller_side

elif type_of_figure == "triangle":

base_lenght = int(input("What is the lenght of the base? "))

height = int(input("What is the height of the triangle? "))

return base_lenght*height/2

I'm sure there are better solutions to this than just if statements, feel free to suggest