Gross profit margin is calculated by dividing the gross profit by the revenue, and it indicates the percentage of revenue that remains after accounting for the cost of goods sold. Net profit margin, on the other hand, is calculated by dividing the net profit by the revenue, revealing the percentage of revenue that translates into net profit. Both these margins are important as they indicate effective cost management and sustained profitability.