Skip to content

Instantly share code, notes, and snippets.

@jawad360
jawad360 / investment_return.py
Created August 13, 2025 19:38
Investment+Return
# Withdrawal Calculator
def calculate_remaining_balance(principal, annual_rate, withdraw, annual_increase, no_of_years):
# Annual compounding interest rate
rate = annual_rate / 100
for year in range(1, no_of_years + 1):
# Compound the interest annually
principal *= (1 + rate)
# Withdraw monthly for the year
# Function to simulate the scenario with investment coming from the original principal and annual interest on the investment
def simulate_investment(principal, withdraw_amount, invest_amount, no_of_years, annual_interest_rate=0.12, annual_withdrawal_increase=0.10):
# Initialize variables
total_investment = 0 # Amount in investments (compounded annually)
current_principal = principal # Starting amount
current_withdraw_amount = withdraw_amount # Monthly withdrawal amount
months_in_year = 12 # Number of months in a year
months = no_of_years * 12 # Total number of months
# Iterate through each month