import math from random import randint print("\nProgram calculates the perimeter and area of different shapes. Let's begin!") burger = randint(1, 100) retry = "" while retry == "": print("\nChoose a shape:") shape = input("Square (S), Rectangle (R), Circle (C), Triangle (T), or Trapezium (Z): ").upper() if shape == "S": side = float(input("\nEnter the length of a side: ")) area = side ** 2 perimeter = side * 4 print(f"\nThe perimeter of the square is {perimeter} and the area is {area}") elif shape == "R": l = float(input("\nEnter the length: ")) w = float(input("Enter the width: ")) area = l * w perimeter = 2 * (l + w) print(f"\nThe perimeter of the rectangle is {perimeter} and the area is {area}") elif shape == "C": radius = float(input("Enter the radius: ")) area = math.pi * (radius ** 2) circumference = 2 * math.pi * radius print(f"\nThe circumference is {circumference:.2f} and the area is {area:.2f}") elif shape == "T": print("\nThe area:") base = float(input("\nEnter the base: ")) height = float(input("Enter the height: ")) print("\nThe perimeter:") s1 = float(input("\nEnter side 1: ")) s2 = float(input("Enter side 2: ")) s3 = float(input("Enter side 3: ")) area = 0.5 * base * height perimeter = s1 + s2 + s3 print(f"\nThe perimeter of the triangle is {perimeter} and the area is {area}") if shape == "z": print("You will need to add all of the sides plus the height for an accuratequasion") a = float(input("Enter top base (a): ")) b = float(input("Enter bottom base (b): ")) h = float(input("Enter height (h): ")) s1 = float(input("Enter side 1: ")) s2 = float(input("Enter side 2: ")) area = ((a + b) / 2) * h perimeter = a + b + s1 + s2 print(f"\nThe perimeter of the shape is {perimeter} and the area is {area}") else: print("Invalid option. Invalid selection.") retry = input("\nDo you want to calculate another shape? Press Enter to continue or type something to exit: ") print("The program has ended") if burger == 100: print("You are a burger and this is a 1 in 100 chance") print(f"{burger}")