PYTHON script that draws a chart showing initial investment of 500,000 invested at 9%…
- User
PYTHON script that draws a chart showing initial investment of 500,000 invested at 9% and 15% over 25 years.
Assistant
Here is a Python script to generate the requested chart:
import matplotlib.pyplot as plt import numpy as np initial_investment = 500000 years = 25 rate1 = 0.09 rate2 = 0.15 values1 = [initial_investment * (1 + rate1) ** i for i in range(years + 1)] values2 = [initial_investment * (1 + rate2) ** i for i in range(years + 1)] plt.plot(range(years + 1), values1, label='9% Rate') plt.plot(range(years + 1), values2, label='15% Rate') plt.title('Investment Growth Over 25 Years') plt.xlabel('Years') plt.ylabel('Value') plt.legend() plt.grid() plt.show()This script calculates the growth of the initial investment at 9% and 15% annual returns over 25 years using compound interest. It plots the results in a line chart with legends to compare the two growth rates. matplotlib is used to generate the chart.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.