🛠️ToolsShed

Sunscreen Calculator

Calculate how much sunscreen you need based on body area and reapplication schedule.

64.5

SunscreenCalculator.totalArea (dm²)

12.90 mL

Per Application

2.58 tsp

SunscreenCalculator.perApplicationTsp

64.5 mL

SunscreenCalculator.dailyTotal

SunscreenCalculator.howCalculated

SunscreenCalculator.ruleExplained

SunscreenCalculator.reapplyNote

Preguntas Frecuentes

Implementación de Código

# Sunscreen amount calculator based on 2mg/cm² rule

BODY_AREAS = {
    "face_neck":    600,   # cm²
    "chest":        900,
    "back":         900,
    "left_arm":     800,
    "right_arm":    800,
    "left_leg":    1450,
    "right_leg":   1450,
    "left_foot":    175,
    "right_foot":   175,
}

RECOMMENDATION_MG_PER_CM2 = 2.0  # WHO / dermatology standard

def calculate_sunscreen(selected_areas: list[str], reapply_every_hours: float = 2,
                         sun_hours: float = 4) -> dict:
    total_area = sum(BODY_AREAS[a] for a in selected_areas if a in BODY_AREAS)
    per_application_mg = total_area * RECOMMENDATION_MG_PER_CM2
    per_application_ml = per_application_mg / 1000  # convert mg to g ≈ ml

    applications = 1 + int(sun_hours / reapply_every_hours) if reapply_every_hours > 0 else 1
    total_ml = per_application_ml * applications

    return {
        "area_cm2": total_area,
        "per_application_ml": round(per_application_ml, 1),
        "applications": applications,
        "total_ml": round(total_ml, 1),
    }

result = calculate_sunscreen(
    selected_areas=["face_neck", "chest", "left_arm", "right_arm"],
    reapply_every_hours=2,
    sun_hours=6,
)
print(f"Per application: {result['per_application_ml']} ml")
print(f"Applications needed: {result['applications']}")
print(f"Total needed: {result['total_ml']} ml")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.