- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a numpy array within a given range?
We have to create a numpy array in the range provided by the user. We will use the arange() function in the numpy library to get our output.
Algorithm
Step1: Import numpy. Step 2: Take start_value, end_value and Step from the user. Step 3: Print the array using arange() function in numpy.
Example Code
import numpy as np start_val = int(input("Enter starting value: ")) end_val = int(input("Enter ending value: ")) Step_val = int(input("Enter Step value: ")) print(np.arange(start_val, end_val, Step_val))
Output
Enter starting value: 5 Enter ending value: 50 Enter Step value: 5 [ 5 10 15 20 25 30 35 40 45]
- Related Articles
- How to print array elements within a given range using Numpy?
- Java Program to create random BigInteger within a given range
- How to find Kaprekar numbers within a given range using Python?
- Constrain a number within a given range in Arduino
- How to create a series from a NumPy array?
- Golang Program to Print Odd Numbers Within a Given Range
- How to add a vector to a given Numpy array?
- Return range of values from a masked array along a given axis in NumPy
- Find elements within range in numpy in Python
- Python Program to replace list elements within a range with a given number
- Java Program to create an array with randomly shuffled numbers in a given range
- Return evenly spaced values within a given interval in Numpy
- PHP program to find the sum of odd numbers within a given range
- Python program to generate random numbers within a given range and store in a list?
- Java program to generate random numbers within a given range and store in a list

Advertisements