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 | |
| from enum import Enum | |
| class StockSplit(Enum): | |
| REVERSE = 1 | |
| FORWARD = 2 | |
| def main(): | |
| # Choose StockSplit.REVERSE or StockSplit.FORWARD based on the type of stock split. |
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}") |
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(): | |
| months_in_year = 12 | |
| portion_of_year = 7.6 | |
| print(months_in_year * portion_of_year) | |
| 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(): | |
| dividend_per_share = 0.2775 | |
| # Payout frequency within a year | |
| # 4 for quarterly, 12 for monthly | |
| # For 2 years, assuming quarterly payments, 8 would be an appropriate frequency | |
| dividend_frequency = 4 | |
| share_count = 1 |
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 | |
| # Formula Resources: | |
| # https://www.omnicalculator.com/finance/compound-interest#example-2-complex-calculation-of-the-value-of-an-investment | |
| def main(): | |
| starting_balance = 5_000 | |
| years_to_achieve = 1 | |
| rate_of_return = 0.03 | |
| compound_frequency = 12 # number of times compounded per year |
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(): | |
| purchase_price = 100 | |
| current_price = 200 | |
| percentage_change = round(((current_price - purchase_price) / purchase_price) * 100, 2) | |
| print(f"At ${current_price}, that is a change of {percentage_change}% from ${purchase_price}") | |
| if __name__ == "__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(): | |
| y = 13 | |
| x = 52 | |
| percentage = round((y / x) * 100) | |
| print(f"{y} is {percentage}% of {x}") | |
| if __name__ == "__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(): | |
| num1 = 80 | |
| num2 = 100 | |
| absolute = abs(num1 - num2) | |
| average = (num1 + num2) / 2 | |
| answer = round((absolute / average) * 100) |
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(): | |
| num1 = 29.89 | |
| num2 = 29.86 | |
| midpoint = (num1 + num2) / 2 | |
| print(midpoint) | |
| if __name__ == "__main__": | |
| main() |
NewerOlder