0
0
NumPydata~30 mins

np.exp() and np.log() in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Using np.exp() and np.log() for Data Transformation
📖 Scenario: Imagine you are analyzing daily growth rates of a small plant species. You have recorded the growth rates as percentages, and you want to understand the exponential growth and also convert back from exponential values to the original growth rates.
🎯 Goal: You will create a numpy array of growth rates, apply the exponential function to simulate growth, then use the natural logarithm to retrieve the original rates. This helps understand how exponential and logarithmic functions work in data science.
📋 What You'll Learn
Create a numpy array with exact growth rates
Create a variable to hold the base of natural logarithm (e)
Use np.exp() to calculate exponential growth
Use np.log() to convert exponential values back to original growth rates
Print the final results
💡 Why This Matters
🌍 Real World
Exponential and logarithmic functions are used in biology to model growth, in finance to calculate compound interest, and in many data science tasks to transform data for analysis.
💼 Career
Understanding how to apply np.exp() and np.log() is important for data scientists working with growth models, time series data, and feature engineering.
Progress0 / 4 steps
1
Create the growth rates array
Import numpy as np and create a numpy array called growth_rates with these exact values: 0.05, 0.10, 0.15, 0.20, 0.25.
NumPy
Need a hint?

Use np.array() to create the array with the given values.

2
Create the constant for natural logarithm base
Create a variable called e and assign it the value of the mathematical constant e using np.e.
NumPy
Need a hint?

Use np.e to get the value of e.

3
Calculate exponential growth and apply logarithm
Create a variable called exp_growth by applying np.exp() to growth_rates. Then create a variable called log_values by applying np.log() to exp_growth.
NumPy
Need a hint?

Use np.exp() to get exponential values and np.log() to get back the original values.

4
Print the exponential and logarithmic results
Print the variables exp_growth and log_values each on a separate line.
NumPy
Need a hint?

Use two print() statements to display the arrays.