2.1 - Introduction To Data Analytics
2.1 - Introduction To Data Analytics
PYTHON PROGRAMMING
24CAH-606
match term:
case pattern-1:
action-1
case pattern-2:
action-2
case pattern-3:
action-3
case _:
action-default
3
Implement Switch Statements with the match and case
Keywords in
lang = input("What's the programming language you want to learn? ")
match lang:
case "JavaScript":
print("You can become a web developer.")
case "Python":
print("You can become a Data Scientist")
case "PHP":
print("You can become a backend developer")
case "Java":
print("You can become a mobile app developer")
case _:
print("The language doesn't matter, what matters is solving problems.")
4
Introduction to Data Analytics
5
Introduction to Data Analytics
7
Libraries in Python
• Python library is a collection of codes and methods that allow to perform many
actions without writing code.
• There are following different types of libraries in Python:
• Numpy ( Numerical Computing)
• Matlotlib (Data visualization)
• Pandas (Data manuplation)
8
NumPy
9
NumPy
• Examples:
10
Initializing NumPy Array with zeros:
11
NumPy
• Initializing NumPy Array with same number:
12
Initializing NumPy Array with a range
method:
13
NumPy
• NumPy Array Indexing
14
NumPy Array Slicing
15
NumPy
• Data Types in NumPy:
16
Initializing NumPy Array with a shape
method:
17
Initializing NumPy Array with a reshape
method:
18
NumPy
• Iterating Arrays
19
NumPy
• Joining NumPy Arrays:
20
NumPy
• Addition of NumPy Arrays:
21
NumPy
• Addition of NumPy Arrays:
22
NumPy
• NumPy Math Functions:
23
NumPy
• Splitting NumPy Arrays:
24
NumPy
• Searching and Sorting NumPy Arrays:
25
NumPy
• NumPy Filter Array:
26
NumPy
• Random Numbers in NumPy:
27
NumPy
• Random Numbers in NumPy:
28
NumPy
• Python NumPy Array v/s List:
• NumPy array used instead of a list because of the below three reasons:
• Less Memory
• Fast
• Convenient
29
NumPy
• Less Memory
The above output shows that the memory allocated by list (denoted by S) is 28000 whereas the
memory allocated by the NumPy array is just 4000. This is a major difference between the two and
this makes Python NumPy array as the preferred choice over list.
30
NumPy
• Fast and Convenient:
List took 983ms whereas the numpy array took almost 56ms. Hence, numpy array is faster than list. Now,
a ‘for’ loop is used for a list to find sum, whereas for numpy arrays, added the two array by simply
printing A1+A2. That’s why working with numpy is much easier and convenient than lists.
31
THANK YOU
32