When we want to know the volume of the substrate in the pot, we can use geometric propertis of a frustum right cicular cone to conclude the substrate volume from its height inside the pot. 


import math

def calculate_pot_volume():
    # Constant dimensions of your pot (in cm)
    R1 = 7.75  # Bottom radius
    R2 = 9.5   # Top radius
    TOTAL_H = 18.0 # Total height of the pot
    
    # Calculate the slope constant k
    k = (R2 - R1) / TOTAL_H
    
    print(f"--- Pot Volume Calculator ---")
    print(f"Pot Specs: Bottom Diam 15.5cm, Top Diam 19cm, Height 18cm")
    
    try:
        # Get user input
        h = float(input("\nEnter the height of the substrate (cm): "))
        
        if h < 0:
            print("Error: Height cannot be negative.")
            return
        if h > TOTAL_H:
            print(f"Warning: The height entered ({h}cm) exceeds the pot height ({TOTAL_H}cm).")
            print("Calculating volume for an overflowing pot...")

        # Volume formula for a frustum of height h:
        # V = (pi * h / 3) * (R1^2 + R1*Rh + Rh^2) where Rh is radius at height h
        rh = R1 + k * h
        volume_cm3 = (math.pi * h / 3) * (R1**2 + R1 * rh + rh**2)
        
        # Alternatively using the expanded polynomial:
        # volume_cm3 = math.pi * ( (R1**2 * h) + (R1 * k * h**2) + (k**2 * h**3 / 3) )

        volume_liters = volume_cm3 / 1000
        
        print(f"\nResults for height {h} cm:")
        print(f"  Volume: {volume_cm3:.2f} cm³")
        print(f"  Volume: {volume_liters:.2f} Liters")
        
    except ValueError:
        print("Error: Please enter a valid numerical value for height.")

if __name__ == "__main__":
    calculate_pot_volume()