Python Array With Examples
Rushikesh J.
Software Test Engineer @Vinz Global | Robot Framework | Manual Testing, Automation Testing | Python | Selenium | GIT | JIRA | Immediate Joiner | API Testing Using Postman | Jenkins
Array in Python
Array in Python
List used as Array
Array module Installation
NumPy installation
Just type in your terminal like cmd, PowerShell or gitbash to install numpy.
pip install numpy
pip is the package manager and package installer in python.
Use of NumPy
Import numpy
Creating array with numpy
Accessing array element using index number (Positive and Negative Index number)
Arithmetic operations on Array
Looping array elements
Reversing, Removing, Finding length of array elements etc
What is Array?
Array is the data structure which store the multiple items, that items is known as elements.
Items will have same data type
Items will have consecutive memory location
Items will have unique index number starting 0 to n-1 where n means total number of items
领英推荐
Array may be one dimensional or two dimensional (multidimensional)
Different Terminologies Of Array
Name of array: It show the array name, when we declare the array, then that variable is the name of array
Array Element: Items or data in the array is the array element
Index: Each array element have its own unique number, which help in accessing that element
Size: Total number of element is the size of array
Memory location: Each element are stored in the computer memory device which have their own specific and unique memory address or memory location
Array Programming Example:
Example: Write a Python Program To Create a Array Using Numpy To Get 5 Number From User, Store In a Array And Find Product Of All The Number As Stored In a Array.
from numpy import *
arr = array([])
for i in range(5):
??? v = input("Element:? ")
??? arr = append(arr, v)
print(arr)