📘
Create Range Arrays
Problem Statement
Create NumPy arrays with sequential or evenly spaced values.
Background
- np.arange(start, stop, step): Like Python range, but returns array
- np.linspace(start, stop, num): num evenly spaced values
Your Task
Write a function create_ranges(start, stop, num_points) that returns a dictionary with:
- "arange": Array from start to stop (exclusive) with step 1
- "linspace": num_points evenly spaced values from start to stop (inclusive)
Round linspace values to 2 decimal places.
Output Format
Return a dictionary with exactly these two keys.
Example:
Input:
start = 0, stop = 5, num_points = 5
Output:
{'arange': [0, 1, 2, 3, 4], 'linspace': [0.0, 1.25, 2.5, 3.75, 5.0]}Reasoning:
arange gives [0,1,2,3,4], linspace gives 5 points from 0 to 5
Constraints:
- Round linspace to 2 decimal places
- start < stop
Editor
Python 3.13.1
Test Results
0/0Run code to see test results.