- Code: Select all
`import math`

def plane_shape():

print('')

shape = input('Please enter either triangle, square, rectangle or circle to calculate its area: ')

plane_shape = ['triangle', 'square', 'rectangle', 'circle']

while shape not in plane_shape:

print('You entered:', shape)

print('')

shape = input('Please enter either triangle, square, rectangle or circle to calculate it\'s area: ')

if shape == 'triangle':

triangle()

elif shape == 'square':

square()

elif shape == 'rectangle':

rectangle()

else:

circle()

def triangle():

base = float(input('Please input the base of the triangle: '))

height = float(input('Please input the vertical height of the triangle: '))

area = (base*height)/2

print('The area of the triangle = ', area)

plane_shape()

def square():

length = float(input('Please input the length of one side of the square: '))

area = length*length

print('The area of the square = ', area)

plane_shape()

def rectangle():

width = float(input('Please input the width of the rectangle: '))

height = float(input('Please input the height of the rectangle: '))

area = width*height

print('The area of the rectangle =', area)

plane_shape()

def circle():

radius = float(input('Please input the radius of the circle: '))

area = (math.pow(radius,2))*math.pi

print('The area of the circle = ', area)

plane_shape()

plane_shape()

-JAP