SlideShare a Scribd company logo
1 of 11
Basic Operations on an Array
1. Arithmetic operations:
 These operations are basic arithmetic operations like
addition,subtraction,division,power etc.
 The operation takes place element wise.
 Eg: arr1=np.arange(6)
O/P:array([0, 1, 2, 3, 4, 5])
print(arr1+3)....every no. is added by 3
print(arr1*2).... every no. is multiplied by 2
print(arr1/3).... every no. is divided by 3
 Hence element wise operations are performed whereas in the list
it will repeat the same list .
 Eg: lst=[10,20,30]
print(lst*3)
 This will repeat the list thrice.
O/P: =[10,20,30,10,20,30,10,20,30]
Arithmetic operations between 2
Arrays
 Even between two arrays the operations take
place element wise.
 Eg 1 : arr1=np.arange(6).....[0,1,2,3,4,5]
arr2=np.arange(6) ).....[0,1,2,3,4,5]
print(arr1+arr2)
O/P: [ 0 2 4 6 8 10]
 Eg 2: print(arr1>arr2)
Here element wise comparison takes place and
returns array of boolean values.As the values in
arr1 and arr2 are equal it will return an array of
boolean values.
 O/P: [False False False False False False]
NOTE
 If number of elements in both the arrays are not same then it will throw an error .
Hence in this case as the broadcasting is not possible number of elements in the array
needs to be equal.
 In case of scalar multiplication element wise multiplication takes place while in vector
product dot product is considered . Hence number of rows should be equal to number
of columns.
 Eg:2D array: arr1=np.arange(6).reshape(2,3)
arr2=np.arange(7,13).reshape(2,3)
arr1=array([[ 1,2,3], [4, 5, 6]])
arr2=array([[ 7, 8, 9], [10, 11, 12]])
 np.dot(arr1,arr2) OR print(arr1.dot(arr2)
 O/P: array([[ 31, 34], [112, 124]])
 In all these examples every time new array is created and the original array remains as
it is.So the original array is not discarded.
2.Update/Modify the existing
array
 When an operation is performed on the array
always new array is created and original
remains as it is.To make changes in the
orignal array we use the below methd.
 arr=np.array([10,20,30])
arr+=2............# arr=arr+2
print(arr)
 O/P: [12 22 32]
 This will make changes to the existing array.
3.Unary Operations
 A single operator or unary operation
is one which takes and performs an operation with a single
operand / argument.
 Aggregation functions such as min(),max(),etc also used to
perform various operations on an array.
 Let arr1=[10,20,30]
1. sum():finding sum of all the elements in the array.
arr1.sum()........O/P:60
2.min(): finding minimum value from all the elements in
the array
arr1.sum()........O/P:10
3.max(): finding maximum value from all the elements in
the array
arr1.sum()........O/P:30
Finding the aggregation of
elements along row or column
 These functions can also be used to find the values
along the rows or columns.
 Eg: arr1=np.arange(12).reshape(6,2)
arr1
 O/P: array([[ 0, 1], [ 2, 3], [ 4, 5], [ 6, 7], [ 8, 9], [10,
11]])
np.sum(arr1,axis=0/1)
np.max(arr1,axis=0/1)
np.min(arr1,axis=0/1)
axis=0 :column wise addition/min/max value
axis=1:row wise addition/min/max value
Universal Functions
MATHS FINCTIONS
 np.add()-adds values
np.add(2,3)......O/P: 5
 np.multiply()-multiplication of the values
np.multiply(2,3)......O/P: 6
 np.sqrt()-to find square root of elements in array
np.sqrt(9,16) )......O/P: 3,4
 np.log()-to find log of a value
np.log(1) .....O/P: 0.0
 np.square()-to find square of a value
np.log(5) .....O/P: 25
Trignometric functions
 np.sin/cos/tan(angle)-to find value of specific angle
np.sin (np.pi/2) .....O/P: 1.0
 To convert values into angles that is, to understand that
it is value in degrees multiply the angle by pi/180 else it
will consider them as usual numerical values.
 Eg:
np.sin(np.array([0,30,60,90,120]))*(np.pi/180)
O/P: array([ 0. , -0.0172444 , -0.00531995, 0.01560319,
0.01013358])
 To converting an array of values of angles to array
values in radians use np.radians(angles).
 To find inverse trignometric functions use
arcsin(),arccos(),arctan() functions
Bitwise operators
 and (&): (int,int) -> int :0011 & 0101 returns the result 0001 inclusive
 Or (|): (int,int) -> int: 0011 & 0101 returns the result 0111
 not (~): (int) -> int: ~01 returns the result 10
 exclusive or(^): (int,int) -> int :0011 & 0101 returns the result 0110
 shift left (<<): (int,int) -> int: 101 << 2 returns the result 10100
For shifting left, 0s are added on the right
 shift right (>>): (int,int) -> int: 101 >> 2 returns the result 1
for shifting right, bits are removed from the right
 Examples: print(np.bitwise_and(10,20))
print(np.bitwise_or(10,20))
 To get the binary representation use below method:
print(np.binary_repr(30))........O/P: 11110
Statistical functions
 arr_pop=np.array([200,300,707,505,50,800])
 Mean:
finding mean of elements in the array
print(np.mean(arr_pop)).......O/P:427.0
 Median:
finding median of elements in the array
print(np.median(arr_pop)) ......O/P:402.5
 Standard deviation:
finding standard deviation of elements in the array
print(np.std(arr_pop)) ......O/P:268.762
 Variance:
finding variance of elements in the array
print(np.var(arr_pop)) ......O/P:72233.333

More Related Content

What's hot

Function Operations
Function OperationsFunction Operations
Function Operationsswartzje
 
Ap calculus speeding problem
Ap calculus speeding problemAp calculus speeding problem
Ap calculus speeding problemRon Eick
 
Practicle application of maxima and minima
Practicle application of maxima and minimaPracticle application of maxima and minima
Practicle application of maxima and minimaBritish Council
 
Functions by mstfdemirdag
Functions by mstfdemirdagFunctions by mstfdemirdag
Functions by mstfdemirdagmstf mstf
 
香港六合彩
香港六合彩香港六合彩
香港六合彩baoyin
 
4 logic circuit optimisation
4 logic circuit optimisation4 logic circuit optimisation
4 logic circuit optimisationchandkec
 
Rate of change and tangent lines
Rate of change and tangent linesRate of change and tangent lines
Rate of change and tangent linesMrs. Ibtsam Youssef
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra Sahil Kumar
 
Admission in india
 Admission in india Admission in india
Admission in indiaEdhole.com
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration methodshashikant pabari
 

What's hot (17)

Ch06 3
Ch06 3Ch06 3
Ch06 3
 
Function Operations
Function OperationsFunction Operations
Function Operations
 
Ap calculus speeding problem
Ap calculus speeding problemAp calculus speeding problem
Ap calculus speeding problem
 
Lesson 3 Operation on Functions
Lesson 3 Operation on FunctionsLesson 3 Operation on Functions
Lesson 3 Operation on Functions
 
Practicle application of maxima and minima
Practicle application of maxima and minimaPracticle application of maxima and minima
Practicle application of maxima and minima
 
Functions by mstfdemirdag
Functions by mstfdemirdagFunctions by mstfdemirdag
Functions by mstfdemirdag
 
香港六合彩
香港六合彩香港六合彩
香港六合彩
 
4 logic circuit optimisation
4 logic circuit optimisation4 logic circuit optimisation
4 logic circuit optimisation
 
Rate of change and tangent lines
Rate of change and tangent linesRate of change and tangent lines
Rate of change and tangent lines
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
 
Admission in india
 Admission in india Admission in india
Admission in india
 
AP Calculus 1984 FRQs
AP Calculus 1984 FRQsAP Calculus 1984 FRQs
AP Calculus 1984 FRQs
 
1988 FRQs AP Calculus
1988 FRQs AP Calculus1988 FRQs AP Calculus
1988 FRQs AP Calculus
 
Index laws
Index lawsIndex laws
Index laws
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration method
 
Arrays and its properties IN SWIFT
Arrays and its properties IN SWIFTArrays and its properties IN SWIFT
Arrays and its properties IN SWIFT
 
Quadrature
QuadratureQuadrature
Quadrature
 

Similar to Array presentation

Problem descriptionThe Jim Thornton Coffee House chain is .docx
Problem descriptionThe Jim Thornton Coffee House chain is .docxProblem descriptionThe Jim Thornton Coffee House chain is .docx
Problem descriptionThe Jim Thornton Coffee House chain is .docxelishaoatway
 
Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guideThalaAjith33
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqPradeep Bisht
 
Find the compact trigonometric Fourier series for the periodic signal.pdf
Find the compact trigonometric Fourier series for the periodic signal.pdfFind the compact trigonometric Fourier series for the periodic signal.pdf
Find the compact trigonometric Fourier series for the periodic signal.pdfarihantelectronics
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1smruti sarangi
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arraysmaamir farooq
 
Lists.pptx
Lists.pptxLists.pptx
Lists.pptxYagna15
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional arrayRajendran
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptxSajalFayyaz
 
M269 Data Structures And Computability.docx
M269 Data Structures And Computability.docxM269 Data Structures And Computability.docx
M269 Data Structures And Computability.docxstirlingvwriters
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdfSrinivasaReddyPolamR
 
Insersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmInsersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmEhsan Ehrari
 
Advanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfAdvanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfSheba41
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithmspppepito86
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..KarthikeyaLanka1
 
c++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdfc++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdfdhavalbl38
 

Similar to Array presentation (20)

Problem descriptionThe Jim Thornton Coffee House chain is .docx
Problem descriptionThe Jim Thornton Coffee House chain is .docxProblem descriptionThe Jim Thornton Coffee House chain is .docx
Problem descriptionThe Jim Thornton Coffee House chain is .docx
 
Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guide
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
Find the compact trigonometric Fourier series for the periodic signal.pdf
Find the compact trigonometric Fourier series for the periodic signal.pdfFind the compact trigonometric Fourier series for the periodic signal.pdf
Find the compact trigonometric Fourier series for the periodic signal.pdf
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
 
Lists.pptx
Lists.pptxLists.pptx
Lists.pptx
 
Slide2
Slide2Slide2
Slide2
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional array
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
 
M269 Data Structures And Computability.docx
M269 Data Structures And Computability.docxM269 Data Structures And Computability.docx
M269 Data Structures And Computability.docx
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
 
Insersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmInsersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in Algoritm
 
Differential calculus
Differential calculus  Differential calculus
Differential calculus
 
Advanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfAdvanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdf
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..
 
c++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdfc++ program I need to sort arrays using an insertion sort and a mer.pdf
c++ program I need to sort arrays using an insertion sort and a mer.pdf
 

More from Learnbay Datascience

Artificial Intelligence- Neural Networks
Artificial Intelligence- Neural NetworksArtificial Intelligence- Neural Networks
Artificial Intelligence- Neural NetworksLearnbay Datascience
 
Artificial intelligence - expert systems
 Artificial intelligence - expert systems Artificial intelligence - expert systems
Artificial intelligence - expert systemsLearnbay Datascience
 
Artificial intelligence - research areas
Artificial intelligence - research areasArtificial intelligence - research areas
Artificial intelligence - research areasLearnbay Datascience
 
Artificial intelligence intelligent systems
Artificial intelligence   intelligent systemsArtificial intelligence   intelligent systems
Artificial intelligence intelligent systemsLearnbay Datascience
 

More from Learnbay Datascience (20)

Top data science projects
Top data science projectsTop data science projects
Top data science projects
 
Python my SQL - create table
Python my SQL - create tablePython my SQL - create table
Python my SQL - create table
 
Python my SQL - create database
Python my SQL - create databasePython my SQL - create database
Python my SQL - create database
 
Python my sql database connection
Python my sql   database connectionPython my sql   database connection
Python my sql database connection
 
Python - mySOL
Python - mySOLPython - mySOL
Python - mySOL
 
AI - Issues and Terminology
AI - Issues and TerminologyAI - Issues and Terminology
AI - Issues and Terminology
 
AI - Fuzzy Logic Systems
AI - Fuzzy Logic SystemsAI - Fuzzy Logic Systems
AI - Fuzzy Logic Systems
 
AI - working of an ns
AI - working of an nsAI - working of an ns
AI - working of an ns
 
Artificial Intelligence- Neural Networks
Artificial Intelligence- Neural NetworksArtificial Intelligence- Neural Networks
Artificial Intelligence- Neural Networks
 
AI - Robotics
AI - RoboticsAI - Robotics
AI - Robotics
 
Applications of expert system
Applications of expert systemApplications of expert system
Applications of expert system
 
Components of expert systems
Components of expert systemsComponents of expert systems
Components of expert systems
 
Artificial intelligence - expert systems
 Artificial intelligence - expert systems Artificial intelligence - expert systems
Artificial intelligence - expert systems
 
AI - natural language processing
AI - natural language processingAI - natural language processing
AI - natural language processing
 
Ai popular search algorithms
Ai   popular search algorithmsAi   popular search algorithms
Ai popular search algorithms
 
AI - Agents & Environments
AI - Agents & EnvironmentsAI - Agents & Environments
AI - Agents & Environments
 
Artificial intelligence - research areas
Artificial intelligence - research areasArtificial intelligence - research areas
Artificial intelligence - research areas
 
Artificial intelligence composed
Artificial intelligence composedArtificial intelligence composed
Artificial intelligence composed
 
Artificial intelligence intelligent systems
Artificial intelligence   intelligent systemsArtificial intelligence   intelligent systems
Artificial intelligence intelligent systems
 
Applications of ai
Applications of aiApplications of ai
Applications of ai
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

Array presentation

  • 1.
  • 2. Basic Operations on an Array 1. Arithmetic operations:  These operations are basic arithmetic operations like addition,subtraction,division,power etc.  The operation takes place element wise.  Eg: arr1=np.arange(6) O/P:array([0, 1, 2, 3, 4, 5]) print(arr1+3)....every no. is added by 3 print(arr1*2).... every no. is multiplied by 2 print(arr1/3).... every no. is divided by 3  Hence element wise operations are performed whereas in the list it will repeat the same list .  Eg: lst=[10,20,30] print(lst*3)  This will repeat the list thrice. O/P: =[10,20,30,10,20,30,10,20,30]
  • 3. Arithmetic operations between 2 Arrays  Even between two arrays the operations take place element wise.  Eg 1 : arr1=np.arange(6).....[0,1,2,3,4,5] arr2=np.arange(6) ).....[0,1,2,3,4,5] print(arr1+arr2) O/P: [ 0 2 4 6 8 10]  Eg 2: print(arr1>arr2) Here element wise comparison takes place and returns array of boolean values.As the values in arr1 and arr2 are equal it will return an array of boolean values.  O/P: [False False False False False False]
  • 4. NOTE  If number of elements in both the arrays are not same then it will throw an error . Hence in this case as the broadcasting is not possible number of elements in the array needs to be equal.  In case of scalar multiplication element wise multiplication takes place while in vector product dot product is considered . Hence number of rows should be equal to number of columns.  Eg:2D array: arr1=np.arange(6).reshape(2,3) arr2=np.arange(7,13).reshape(2,3) arr1=array([[ 1,2,3], [4, 5, 6]]) arr2=array([[ 7, 8, 9], [10, 11, 12]])  np.dot(arr1,arr2) OR print(arr1.dot(arr2)  O/P: array([[ 31, 34], [112, 124]])  In all these examples every time new array is created and the original array remains as it is.So the original array is not discarded.
  • 5. 2.Update/Modify the existing array  When an operation is performed on the array always new array is created and original remains as it is.To make changes in the orignal array we use the below methd.  arr=np.array([10,20,30]) arr+=2............# arr=arr+2 print(arr)  O/P: [12 22 32]  This will make changes to the existing array.
  • 6. 3.Unary Operations  A single operator or unary operation is one which takes and performs an operation with a single operand / argument.  Aggregation functions such as min(),max(),etc also used to perform various operations on an array.  Let arr1=[10,20,30] 1. sum():finding sum of all the elements in the array. arr1.sum()........O/P:60 2.min(): finding minimum value from all the elements in the array arr1.sum()........O/P:10 3.max(): finding maximum value from all the elements in the array arr1.sum()........O/P:30
  • 7. Finding the aggregation of elements along row or column  These functions can also be used to find the values along the rows or columns.  Eg: arr1=np.arange(12).reshape(6,2) arr1  O/P: array([[ 0, 1], [ 2, 3], [ 4, 5], [ 6, 7], [ 8, 9], [10, 11]]) np.sum(arr1,axis=0/1) np.max(arr1,axis=0/1) np.min(arr1,axis=0/1) axis=0 :column wise addition/min/max value axis=1:row wise addition/min/max value
  • 8. Universal Functions MATHS FINCTIONS  np.add()-adds values np.add(2,3)......O/P: 5  np.multiply()-multiplication of the values np.multiply(2,3)......O/P: 6  np.sqrt()-to find square root of elements in array np.sqrt(9,16) )......O/P: 3,4  np.log()-to find log of a value np.log(1) .....O/P: 0.0  np.square()-to find square of a value np.log(5) .....O/P: 25
  • 9. Trignometric functions  np.sin/cos/tan(angle)-to find value of specific angle np.sin (np.pi/2) .....O/P: 1.0  To convert values into angles that is, to understand that it is value in degrees multiply the angle by pi/180 else it will consider them as usual numerical values.  Eg: np.sin(np.array([0,30,60,90,120]))*(np.pi/180) O/P: array([ 0. , -0.0172444 , -0.00531995, 0.01560319, 0.01013358])  To converting an array of values of angles to array values in radians use np.radians(angles).  To find inverse trignometric functions use arcsin(),arccos(),arctan() functions
  • 10. Bitwise operators  and (&): (int,int) -> int :0011 & 0101 returns the result 0001 inclusive  Or (|): (int,int) -> int: 0011 & 0101 returns the result 0111  not (~): (int) -> int: ~01 returns the result 10  exclusive or(^): (int,int) -> int :0011 & 0101 returns the result 0110  shift left (<<): (int,int) -> int: 101 << 2 returns the result 10100 For shifting left, 0s are added on the right  shift right (>>): (int,int) -> int: 101 >> 2 returns the result 1 for shifting right, bits are removed from the right  Examples: print(np.bitwise_and(10,20)) print(np.bitwise_or(10,20))  To get the binary representation use below method: print(np.binary_repr(30))........O/P: 11110
  • 11. Statistical functions  arr_pop=np.array([200,300,707,505,50,800])  Mean: finding mean of elements in the array print(np.mean(arr_pop)).......O/P:427.0  Median: finding median of elements in the array print(np.median(arr_pop)) ......O/P:402.5  Standard deviation: finding standard deviation of elements in the array print(np.std(arr_pop)) ......O/P:268.762  Variance: finding variance of elements in the array print(np.var(arr_pop)) ......O/P:72233.333