Last active
October 22, 2025 20:57
-
-
Save Adobe-Android/8f6b5c683e25dc4804dc843fd51b0b33 to your computer and use it in GitHub Desktop.
Calculate the percentage of your compensation that you invest
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
| #!/bin/env python3 | |
| def main(): | |
| compensation = 2_000 | |
| percentage_contribution = 0.06 # 6% | |
| additional_contribution = 0.03 # 3% | |
| investment_contribution = round((compensation * percentage_contribution), 2) | |
| print(f"${investment_contribution:.2f} is {percentage_contribution * 100}% of your compensation of ${compensation:.2f}") | |
| additional_investment_contribution = round((compensation * additional_contribution), 2) | |
| print(f"An additional {additional_contribution * 100}% investment would be ${additional_investment_contribution:.2f}") | |
| total_investment_contribution = investment_contribution + additional_investment_contribution | |
| print(f"The new total investment of ${total_investment_contribution:.2f} is {(percentage_contribution + additional_contribution) * 100:.2f}% of your compensation of ${compensation:.2f}") | |
| if __name__ == "__main__": | |
| main() |
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
| #!/bin/env python3 | |
| def main(): | |
| compensation = 2_000 | |
| percentage_contribution = 0.15 # 15% | |
| investment_contribution = round((compensation * percentage_contribution), 2) | |
| print(f"${investment_contribution:.2f} is {percentage_contribution * 100}% of your compensation of ${compensation:.2f}") | |
| if __name__ == "__main__": | |
| main() |
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
| #!/bin/env python3 | |
| def main(): | |
| compensation = 2_000 | |
| investment_contribution = 300 | |
| percentage = round((investment_contribution / compensation) * 100, 2) | |
| print(f"${investment_contribution:.2f} is {percentage}% of your compensation of ${compensation:.2f}") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment