Sensitivity is calculated as the number of true positives divided by the sum of true positives and false negatives. Specificity is calculated as the number of true negatives divided by the sum of true negatives and false positives. These calculations help to determine how well a test performs in distinguishing between those who have the condition and those who do not.