tITLE: BODy FAT CALCULATOR
COURSE
NAME & Done By:
CODE:
Vijay.M
Introducti
on To 230301114
Python BME-“B”
Program (2nd year)
ming
(CS23336) 4th semester
Mini Project Report
Body Fat Calculator Using Python
1. Title
Body Fat Calculator Using Python
2. Aim
To develop a simple Python-based body fat calculator that estimates the body fat
percentage of a person based on user inputs like height, neck, waist, and hip (for females)
using the U.S. Navy Body Fat Formula.
3. Tools Required
• Programming Language: Python 3.x
• Platform: Any Python IDE or online compiler (e.g., IDLE, VS Code, Jupyter, Replit)
• Libraries Used:
- math (standard Python library for logarithmic calculations)
4. Methodology
1. Ask the user to enter their gender (male or female).
2. Collect the necessary body measurements:
- Height, Neck, Waist (for males)
- Height, Neck, Waist, Hip (for females)
3. Use the appropriate U.S. Navy Body Fat formula based on the gender.
4. Calculate and display the estimated body fat percentage.
5. Provide a health status based on the calculated percentage.
5. Sample Code (Python)
import math
def calculate_bfp(gender, height, neck, waist, hip=0):
if gender == "male":
return round(86.01 * math.log10(waist - neck) - 70.041 * math.log10(height) + 36.76,2)
else: # female
return round(163.205 * math.log10(waist + hip - neck) - 97.684 * math.log10(height)
78.387, 2)
# Input
gender = input("Enter gender (male/female): ").lower()
height = float(input("Enter height (cm): "))
neck = float(input("Enter neck circumference (cm): "))
waist = float(input("Enter waist circumference (cm): "))
# For females, input hip circumference
hip = float(input("Enter hip circumference (cm): ")) if gender == "female" else 0
# Calculate and output body fat percentage
bfp = calculate_bfp(gender, height, neck, waist, hip)
print(f"Body Fat Percentage: {bfp}%")
6. Output Example
=== Body Fat Calculator (U.S. Navy Method) ===
Enter your gender (male/female): male
Enter height (in cm): 175
Enter neck circumference (in cm): 38
Enter waist circumference (in cm): 85
Estimated Body Fat Percentage: 16.8%
7. Conclusion
This project uses a standard scientific formula (U.S. Navy Method) to calculate body fat
percentage using simple Python code. It reinforces core programming concepts like user
input, conditional logic, and mathematical operations. The program can be further
enhanced with GUI or data logging features in the future.