Convertidor de Salario a Tarifa Horaria
Convierte entre tarifa horaria, diaria, semanal, mensual y salario anual. Horas y días de trabajo personalizables.
Preguntas Frecuentes
Implementación de Código
def salary_breakdown(amount, period, hours_per_day=8, days_per_week=5, weeks_per_year=52):
"""Convert salary from any period to all standard periods."""
hours_per_week = hours_per_day * days_per_week
hours_per_year = hours_per_week * weeks_per_year
annual = {
"hourly": amount * hours_per_year,
"daily": amount * days_per_week * weeks_per_year,
"weekly": amount * weeks_per_year,
"biweekly": amount * weeks_per_year / 2,
"semimonthly": amount * weeks_per_year / 24 * 2,
"monthly": amount * weeks_per_year / 12,
"quarterly": amount * weeks_per_year / 4,
"annual": amount,
}
# First convert to annual, then to each period
if period not in annual:
raise ValueError(f"Unknown period: {period}")
yearly = annual[period]
hourly = yearly / hours_per_year
return {
"hourly": round(hourly, 4),
"daily": round(hourly * hours_per_day, 2),
"weekly": round(hourly * hours_per_week, 2),
"biweekly": round(hourly * hours_per_week * 2, 2),
"semimonthly": round(yearly / 24, 2),
"monthly": round(yearly / 12, 2),
"quarterly": round(yearly / 4, 2),
"annual": round(yearly, 2),
}
# Example: $60,000 annual salary
result = salary_breakdown(60000, "annual")
for k, v in result.items():
print(k, ":", v)Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.