find the surface area of a pyramid in python

To find the surface area of a pyramid in Python, you would need the following steps:

  1. Import the math module
  2. Define the base of the pyramid
  3. Define the slant height of the pyramid
  4. Calculate the lateral surface area of the pyramid using the formula: (base * slant height)/2
  5. Calculate the base area of the pyramid
  6. Add the lateral surface area to the base area to get the total surface area of the pyramid

Here's the Python code to implement these steps:

main.py
import math

# Step 2: Define the base of the pyramid
base = 10

# Step 3: Define the slant height of the pyramid
slant_height = 14

# Step 4: Calculate the lateral surface area of the pyramid
lateral_surface_area = (base * slant_height) / 2

# Step 5: Calculate the base area of the pyramid
base_area = base**2

# Step 6: Add the lateral surface area to the base area to get the total surface area of the pyramid
total_surface_area = lateral_surface_area + base_area

# Print the result
print("The surface area of the pyramid is:", total_surface_area)
553 chars
20 lines

You can replace the values of base and slant_height variables to calculate the surface area of any pyramid.

gistlibby LogSnag