SlideShare a Scribd company logo
Arrays In Python | Python Array Operations | Edureka
What is an Array?
How to Create an Array in Python?
Is Python List same as an Array?
Basic Array Operations
• Finding the length of an Array
• Addition
• Removal
• Concatenation
• Slicing
• Looping
Accessing Array Elements
www.edureka.co/python
What is an Array?
www.edureka.co/python
What is an Array?
www.edureka.co/python
→ a
a[0] a[1] a[2] a[3…98] a[99]
1 2 3 … 100
Var_Name
Values →
Index →
Basic structure
of an Array:
An array is basically a data structure which can hold more than one value at a
time. It is a collection or ordered series of elements of the same type.
Is Python List same as an Array?
www.edureka.co/python
Is Python List same as an Array?
Python Arrays and lists have the
same way of storing data.
Arrays take only a single data type
elements but lists can have any
type of data.
Therefore, other than a few
operations, the kind of operations
performed on them are different.
www.edureka.co/python
How to create Arrays in Python?
www.edureka.co/python
Arrays in Python can be created after importing the array module.
How to create Arrays in Python?
→ from array import *
USING *
3
→ import array → import array as arr
WITHOUT ALIAS
1 USING ALIAS
2
www.edureka.co/python
Accessing Array Elements www.edureka.co/python
❑ Access elements using index values.
❑ Indexing starts at 0 and not from 1. Hence, the index number is always 1 less than the length
of the array.
❑ Negative index values can be used as well. The point to remember is that negative indexing
starts from the reverse order of traversal i.e from right to left.
www.edureka.co/python
a[2]=3
Example: a[2]=3
Accessing Array Elements
Basic Array Operations www.edureka.co/python
Operations
Removing/ Deleting
elements of an array
Slicing
Looping through an Array
Basic Array Operations
Adding/ Changing
element of an Array
Finding the length of an
Array
Array ConcatenationArray Concatenation
www.edureka.co/python
Finding the length of an Array www.edureka.co/python
❑ Length of an array is the number of elements that are actually present in an array.
❑ You can make use of len() function to achieve this.
❑ The len() function returns an integer value that is equal to the number of elements present in that array.
Finding the length of an Array
www.edureka.co/python
Lengthofanarrayisdeterminedusingthelen()functionasfollows:
Finding the length of an Array
import array as arr
a=arr.array('d', [1.1 , 2.1 ,3.1] )
len(a)
len(array_name)
Output- 3
SYNTAX:
www.edureka.co/python
Adding elements to an Array
www.edureka.co/python
js
Insert()extend()append()
Used when you want to add
a single element at the end
of an array.
Used when you want to add
more than one element at
the end of an array.
Used when you want to add
an element at a specific
position in an array.
Functions used to add elements to an Array:
Adding elements to an Array
www.edureka.co/python
Thecodesnippetbelowimplementstheappend(),extend()andinsert() functions:
Adding elements to an Array
Array a= array('d', [1.1, 2.1, 3.1, 3.4])
Array b= array('d', [2.1, 3.2, 4.6, 4.5,
3.6, 7.2])
Array c=array('d', [1.1, 2.1,3.4, 3.1])
import array as arr
a=arr.array('d', [1.1 , 2.1 ,3.1] )
a.append(3.4)
print("Array a=",a)
b=arr.array('d',[2.1,3.2,4.6])
b.extend([4.5,3.6,7.2])
print("Array b=",b)
c=arr.array( 'd' , [1.1 , 2.1 ,3.1] )
c.insert(2,3.4)
print(“Arrays c=“,c)
OUTPUT-
www.edureka.co/python
Removing elements of an Array www.edureka.co/python
Removing elements of an Array
js
pop() remove()
Used when you want to
remove an element and
return it.
Used when you want to
remove an element with a
specific value without
returning it.
Functions used to remove elements of an Array:
www.edureka.co/python
Thecodesnippetbelowshowshowyoucanremoveelementsusingthesetwofunctions:
import array as arr
a=arr.array('d', [1.1, 2.2, 3.8, 3.1, 3.7])
print(“Popping last element”,a.pop())
print(“Popping 4th element”,a.pop(3))
a.remove(1.1)
print(a)
Popping last element 3.7
Popping 4th element 3.1
array('d', [2.2, 3.8])
OUTPUT-
Removing elements of an Array
www.edureka.co/python
Array Concatenation
www.edureka.co/python
Arrayconcatenation canbedoneasfollowsusingthe+symbol:
Array Concatenation
import array as arr
a=arr.array('d',[1.1 , 2.1 ,3.1,2.6,7.8])
b=arr.array('d',[3.7,8.6])
c=arr.array('d’)
c=a+b
print("Array c = ",c)
Array c= array(‘d’, [1.1, 2.1, 3.1, 2.6,
7.8, 3.7, 8.6])
OUTPUT-
www.edureka.co/python
Slicing an Array
www.edureka.co/python
Slicing an Array
import array as arr
a=arr.array('d',[1.1 , 2.1 ,3.1,2.6,7.8])
print(a[0:3])
OUTPUT -
array(‘d’, [1.1, 2.1, 3.1])
An array can be sliced using the : symbol. This returns a range of elements that we have
specified by the index numbers.
www.edureka.co/python
Looping through an Array
www.edureka.co/python
js
for while
Iterates over the items of an
array specified number of
times.
Iterates over the elements
until a certain condition is met.
We can loop through an array easily using the for and while loops.
Looping through an Array
www.edureka.co/python
Some of the for loop implementations are:
import array as arr
a=arr.array('d', [1.1, 2.2, 3.8, 3.1, 3.7])
print("All values")
for x in a:
print(x)
Allvalues
1.1
2.2
3.8
3.1
3.7
OUTPUT-
Looping through an Array using for loop
www.edureka.co/python
Example for while loop implementation
Looping through an Array using while loop
import array as arr
a=arr.array('d', [1.1, 2.2, 3.8, 3.1, 3.7])
b=0
while b<len(a):
print(a[b])
b=b+1
1.1
2.2
3.8
3.1
3.7
OUTPUT-
www.edureka.co/python
www.edureka.co/python

More Related Content

What's hot (20)

Python set
Python setPython set
Python set
Mohammed Sikander
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
Smit Parikh
 
NUMPY
NUMPY NUMPY
NUMPY
Global Academy of Technology
 
Set methods in python
Set methods in pythonSet methods in python
Set methods in python
deepalishinkar1
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
nitamhaske
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
CPD INDIA
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
Devashish Kumar
 
List in Python
List in PythonList in Python
List in Python
Siddique Ibrahim
 
Python strings
Python stringsPython strings
Python strings
Mohammed Sikander
 
Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
Emertxe Information Technologies Pvt Ltd
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Sets in python
Sets in pythonSets in python
Sets in python
baabtra.com - No. 1 supplier of quality freshers
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
Sujith Kumar
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and Packages
Damian T. Gordon
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Python list
Python listPython list
Python list
Mohammed Sikander
 
Python-Encapsulation.pptx
Python-Encapsulation.pptxPython-Encapsulation.pptx
Python-Encapsulation.pptx
Karudaiyar Ganapathy
 

Similar to Arrays In Python | Python Array Operations | Edureka (20)

Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdfJava R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
kamalabhushanamnokki
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
LOVELY PROFESSIONAL UNIVERSITY
 
In Python, a list is a built-in dynamic sized array. We can store all types o...
In Python, a list is a built-in dynamic sized array. We can store all types o...In Python, a list is a built-in dynamic sized array. We can store all types o...
In Python, a list is a built-in dynamic sized array. We can store all types o...
Karthik Rohan
 
Array properties
Array propertiesArray properties
Array properties
Shravan Sharma
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
SivaSankar Gorantla
 
Java ArrayList Tutorial | Edureka
Java ArrayList Tutorial | EdurekaJava ArrayList Tutorial | Edureka
Java ArrayList Tutorial | Edureka
Edureka!
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
Abbott
 
Collections framework
Collections frameworkCollections framework
Collections framework
Anand Buddarapu
 
Data structures
Data structuresData structures
Data structures
Manaswi Sharma
 
U-III-part-1.pptxpart 1 of Java and hardware coding questions are answered
U-III-part-1.pptxpart 1 of Java and hardware coding questions are answeredU-III-part-1.pptxpart 1 of Java and hardware coding questions are answered
U-III-part-1.pptxpart 1 of Java and hardware coding questions are answered
zainmkhan20
 
Unit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTUREUnit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTURE
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
ACP-arrays.pptx
ACP-arrays.pptxACP-arrays.pptx
ACP-arrays.pptx
MuhammadSubtain9
 
Various Operations Of Array(Data Structure Algorithm).pptx
Various Operations Of Array(Data Structure Algorithm).pptxVarious Operations Of Array(Data Structure Algorithm).pptx
Various Operations Of Array(Data Structure Algorithm).pptx
atirathpal007
 
object oriented programing in python and pip
object oriented programing in python and pipobject oriented programing in python and pip
object oriented programing in python and pip
LakshmiMarineni
 
Unit-5-Part1 Array in Python programming.pdf
Unit-5-Part1 Array in Python programming.pdfUnit-5-Part1 Array in Python programming.pdf
Unit-5-Part1 Array in Python programming.pdf
582004rohangautam
 
F# array searching
F#  array searchingF#  array searching
F# array searching
DrRajeshreeKhande
 
Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)
Abbott
 
Net (f#) array
Net (f#)  arrayNet (f#)  array
Net (f#) array
DrRajeshreeKhande
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues
Intro C# Book
 
Any Which Array But Loose
Any Which Array But LooseAny Which Array But Loose
Any Which Array But Loose
michael.labriola
 
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdfJava R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
kamalabhushanamnokki
 
In Python, a list is a built-in dynamic sized array. We can store all types o...
In Python, a list is a built-in dynamic sized array. We can store all types o...In Python, a list is a built-in dynamic sized array. We can store all types o...
In Python, a list is a built-in dynamic sized array. We can store all types o...
Karthik Rohan
 
Java ArrayList Tutorial | Edureka
Java ArrayList Tutorial | EdurekaJava ArrayList Tutorial | Edureka
Java ArrayList Tutorial | Edureka
Edureka!
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
Abbott
 
U-III-part-1.pptxpart 1 of Java and hardware coding questions are answered
U-III-part-1.pptxpart 1 of Java and hardware coding questions are answeredU-III-part-1.pptxpart 1 of Java and hardware coding questions are answered
U-III-part-1.pptxpart 1 of Java and hardware coding questions are answered
zainmkhan20
 
Various Operations Of Array(Data Structure Algorithm).pptx
Various Operations Of Array(Data Structure Algorithm).pptxVarious Operations Of Array(Data Structure Algorithm).pptx
Various Operations Of Array(Data Structure Algorithm).pptx
atirathpal007
 
object oriented programing in python and pip
object oriented programing in python and pipobject oriented programing in python and pip
object oriented programing in python and pip
LakshmiMarineni
 
Unit-5-Part1 Array in Python programming.pdf
Unit-5-Part1 Array in Python programming.pdfUnit-5-Part1 Array in Python programming.pdf
Unit-5-Part1 Array in Python programming.pdf
582004rohangautam
 
Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)Data structure lecture 2 (pdf)
Data structure lecture 2 (pdf)
Abbott
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues
Intro C# Book
 
Ad

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 
Ad

Recently uploaded (20)

Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 

Arrays In Python | Python Array Operations | Edureka

  • 2. What is an Array? How to Create an Array in Python? Is Python List same as an Array? Basic Array Operations • Finding the length of an Array • Addition • Removal • Concatenation • Slicing • Looping Accessing Array Elements www.edureka.co/python
  • 3. What is an Array? www.edureka.co/python
  • 4. What is an Array? www.edureka.co/python → a a[0] a[1] a[2] a[3…98] a[99] 1 2 3 … 100 Var_Name Values → Index → Basic structure of an Array: An array is basically a data structure which can hold more than one value at a time. It is a collection or ordered series of elements of the same type.
  • 5. Is Python List same as an Array? www.edureka.co/python
  • 6. Is Python List same as an Array? Python Arrays and lists have the same way of storing data. Arrays take only a single data type elements but lists can have any type of data. Therefore, other than a few operations, the kind of operations performed on them are different. www.edureka.co/python
  • 7. How to create Arrays in Python? www.edureka.co/python
  • 8. Arrays in Python can be created after importing the array module. How to create Arrays in Python? → from array import * USING * 3 → import array → import array as arr WITHOUT ALIAS 1 USING ALIAS 2 www.edureka.co/python
  • 9. Accessing Array Elements www.edureka.co/python
  • 10. ❑ Access elements using index values. ❑ Indexing starts at 0 and not from 1. Hence, the index number is always 1 less than the length of the array. ❑ Negative index values can be used as well. The point to remember is that negative indexing starts from the reverse order of traversal i.e from right to left. www.edureka.co/python a[2]=3 Example: a[2]=3 Accessing Array Elements
  • 11. Basic Array Operations www.edureka.co/python
  • 12. Operations Removing/ Deleting elements of an array Slicing Looping through an Array Basic Array Operations Adding/ Changing element of an Array Finding the length of an Array Array ConcatenationArray Concatenation www.edureka.co/python
  • 13. Finding the length of an Array www.edureka.co/python
  • 14. ❑ Length of an array is the number of elements that are actually present in an array. ❑ You can make use of len() function to achieve this. ❑ The len() function returns an integer value that is equal to the number of elements present in that array. Finding the length of an Array www.edureka.co/python
  • 15. Lengthofanarrayisdeterminedusingthelen()functionasfollows: Finding the length of an Array import array as arr a=arr.array('d', [1.1 , 2.1 ,3.1] ) len(a) len(array_name) Output- 3 SYNTAX: www.edureka.co/python
  • 16. Adding elements to an Array www.edureka.co/python
  • 17. js Insert()extend()append() Used when you want to add a single element at the end of an array. Used when you want to add more than one element at the end of an array. Used when you want to add an element at a specific position in an array. Functions used to add elements to an Array: Adding elements to an Array www.edureka.co/python
  • 18. Thecodesnippetbelowimplementstheappend(),extend()andinsert() functions: Adding elements to an Array Array a= array('d', [1.1, 2.1, 3.1, 3.4]) Array b= array('d', [2.1, 3.2, 4.6, 4.5, 3.6, 7.2]) Array c=array('d', [1.1, 2.1,3.4, 3.1]) import array as arr a=arr.array('d', [1.1 , 2.1 ,3.1] ) a.append(3.4) print("Array a=",a) b=arr.array('d',[2.1,3.2,4.6]) b.extend([4.5,3.6,7.2]) print("Array b=",b) c=arr.array( 'd' , [1.1 , 2.1 ,3.1] ) c.insert(2,3.4) print(“Arrays c=“,c) OUTPUT- www.edureka.co/python
  • 19. Removing elements of an Array www.edureka.co/python
  • 20. Removing elements of an Array js pop() remove() Used when you want to remove an element and return it. Used when you want to remove an element with a specific value without returning it. Functions used to remove elements of an Array: www.edureka.co/python
  • 21. Thecodesnippetbelowshowshowyoucanremoveelementsusingthesetwofunctions: import array as arr a=arr.array('d', [1.1, 2.2, 3.8, 3.1, 3.7]) print(“Popping last element”,a.pop()) print(“Popping 4th element”,a.pop(3)) a.remove(1.1) print(a) Popping last element 3.7 Popping 4th element 3.1 array('d', [2.2, 3.8]) OUTPUT- Removing elements of an Array www.edureka.co/python
  • 23. Arrayconcatenation canbedoneasfollowsusingthe+symbol: Array Concatenation import array as arr a=arr.array('d',[1.1 , 2.1 ,3.1,2.6,7.8]) b=arr.array('d',[3.7,8.6]) c=arr.array('d’) c=a+b print("Array c = ",c) Array c= array(‘d’, [1.1, 2.1, 3.1, 2.6, 7.8, 3.7, 8.6]) OUTPUT- www.edureka.co/python
  • 25. Slicing an Array import array as arr a=arr.array('d',[1.1 , 2.1 ,3.1,2.6,7.8]) print(a[0:3]) OUTPUT - array(‘d’, [1.1, 2.1, 3.1]) An array can be sliced using the : symbol. This returns a range of elements that we have specified by the index numbers. www.edureka.co/python
  • 26. Looping through an Array www.edureka.co/python
  • 27. js for while Iterates over the items of an array specified number of times. Iterates over the elements until a certain condition is met. We can loop through an array easily using the for and while loops. Looping through an Array www.edureka.co/python
  • 28. Some of the for loop implementations are: import array as arr a=arr.array('d', [1.1, 2.2, 3.8, 3.1, 3.7]) print("All values") for x in a: print(x) Allvalues 1.1 2.2 3.8 3.1 3.7 OUTPUT- Looping through an Array using for loop www.edureka.co/python
  • 29. Example for while loop implementation Looping through an Array using while loop import array as arr a=arr.array('d', [1.1, 2.2, 3.8, 3.1, 3.7]) b=0 while b<len(a): print(a[b]) b=b+1 1.1 2.2 3.8 3.1 3.7 OUTPUT- www.edureka.co/python