Created
January 28, 2025 21:03
-
-
Save dorthrithil/fa7f97fe96369f03086d8b9d0b99bc78 to your computer and use it in GitHub Desktop.
Work percentage calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import symbols, Eq, solve | |
def calculate_work_percentage(additional_free_days, total_workdays_per_year=260, current_vacation_days=30): | |
""" | |
Calculate the required percentage of working time to achieve the desired total free days. | |
Parameters: | |
additional_free_days (float): The total free days you want to add to your vacation. | |
total_workdays_per_year (int): The average number of workdays in a year (default: 260). | |
current_vacation_days (int): The current number of vacation days (default: 30). | |
Returns: | |
float: The required working percentage. | |
""" | |
# Define the percentage of working time as a symbol | |
x = symbols('x') | |
# Equation for total free days | |
vacation_days = current_vacation_days * (x / 100) | |
gained_free_days = (100 - x) * (total_workdays_per_year / 100) | |
# Total free days equation | |
total_free_days = current_vacation_days + additional_free_days | |
equation = Eq(vacation_days + gained_free_days, total_free_days) | |
# Solve for x (percentage of working time) | |
required_work_percentage = solve(equation, x)[0] | |
return float(required_work_percentage) | |
if __name__ == "__main__": | |
# Input: additional free days desired | |
additional_free_days = float(input("Enter the number of additional free days you want: ")) | |
# Calculate the required working percentage | |
result = calculate_work_percentage(additional_free_days) | |
print(f"To achieve {30 + additional_free_days} total free days, you need to work approximately {result:.2f}% of full-time.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment