Untitled

 avatar
unknown
python
2 years ago
701 B
4
Indexable
import matplotlib.pyplot as plt
import numpy as np

# Function to calculate population using the exponential growth formula
def calculate_population(P0, r, t):
    return P0 * (1 + r)**t

# Given data
initial_population = 100000
growth_rate = 0.03
years = np.arange(0, 11, 1)  # 0 to 10 years in steps of 1

# Calculate population for each year
population_over_time = calculate_population(initial_population, growth_rate, years)

# Plotting the population growth
plt.figure(figsize=(8, 5))
plt.plot(years, population_over_time, marker='o', linestyle='-', color='b')
plt.title('Population Growth Over Time')
plt.xlabel('Years')
plt.ylabel('Population')
plt.grid(True)
plt.show()
Editor is loading...
Leave a Comment