# This program calculates the perimeter and area of different shapes keep_going = "" print("This program calculates the perimeter and area of different shapes.. lets begin") while keep_going == "": shape = input("Choose a shape from square (click 's'), rectangle (click 'r'), parallelogram (click 'p'), triangle (click 't'), or circle (click 'c'). ") if shape == "s" or shape == "S": print("square") side = float(input("Enter the length of a side ")) square_area = side **2 square_perimeter = side * 4 print(f"The perimeter of a square with a length of {side} is {square_perimeter} " f"the area is {square_area}") elif shape == "r" or shape == "R": print("rectangle") length = float(input("Enter the length ")) width = float(input("Enter the width ")) rectangle_area = length * width rectangle_perimeter = (length + width) * 2 print(f"The perimeter of a rectangle with a length of {length} and width of {width} is {rectangle_perimeter} " f"the area is {rectangle_area}") elif shape == "c" or shape == "C": print("circle") radius = float(input("Enter the radius ")) circle_area = 3.14 * radius **2 circle_perimeter = 2 * 3.14 * radius print(f"The perimeter of a circle with a radius of {radius} is {circle_perimeter} " f"the area is {circle_area}") elif shape == "p" or shape == "P": print("parallelogram") base_length = float(input("Enter the base length ")) side_length = float(input("Enter the side length ")) height = float(input("Enter the height ")) parallelogram_area = base_length * height parallelogram_perimeter = (base_length + side_length) * 2 print(f"The perimeter of a parallelogram with a base length of {base_length} and height of {height} is {parallelogram_perimeter} " f"the area is {parallelogram_area}") elif shape == "t" or shape == "T": print("triangle") height = float(input("Enter the height ")) width = float(input("Enter the width ")) triangle_area = (height * width) / 2 triangle_perimeter = height + width + width print(f"The perimeter of a triangle with a height of {height} and width of {width} is {triangle_perimeter} " f"the area is {triangle_area}") else: print("This shape is not recognised") keep_going = input("Would you like to keeping going? If yes click enter, if no type 'no' ") print("The program has ended")