23 lines
605 B
Python
23 lines
605 B
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
# Initial population
|
|
population = 1_000_000
|
|
death_rate = 0.10
|
|
years = np.arange(0, 1001, 100) # 0 to 1000 years in 100-year intervals
|
|
|
|
# Calculate population after each 100-year interval
|
|
population_values = [population]
|
|
for year in years[1:]:
|
|
population -= death_rate * population
|
|
population_values.append(population)
|
|
|
|
# Create the graph
|
|
plt.figure(figsize=(8, 6))
|
|
plt.plot(years, population_values, marker='o', linestyle='-', color='b')
|
|
plt.xlabel('Years')
|
|
plt.ylabel('Population')
|
|
plt.title('Population Projection')
|
|
plt.grid(True)
|
|
plt.show()
|