1. What is NumPy?
NumPy stands for Numerical Python.
👉 It is a Python library used for:
- Working with numbers
- Performing mathematical operations
- Handling large datasets efficiently
Simple Meaning:
👉 NumPy = Faster and easier way to work with numbers in Python
2. Why Use NumPy?
NumPy is:
- Faster than normal Python lists ⚡
- Used in data science and AI
- Efficient for calculations
- Easy to use for numerical operations
3. Installing NumPy
Install using:
pip install numpy
4. Importing NumPy
import numpy as np
👉 np is just a shortcut name.
5. NumPy Arrays (Core Concept)
👉 NumPy works with arrays (like lists but more powerful).
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr)
6. Difference: List vs NumPy Array
# Python list
list1 = [1, 2, 3]
# NumPy array
arr1 = np.array([1, 2, 3])
👉 NumPy arrays are:
- Faster
- More efficient
- Better for calculations
7. Types of Arrays
1D Array
arr = np.array([1, 2, 3])
2D Array (Matrix)
arr = np.array([[1, 2], [3, 4]])
8. Basic Operations
Addition
arr = np.array([1, 2, 3])
print(arr + 2)
👉 Output: [3, 4, 5]
Multiplication
print(arr * 2)
👉 Output: [2, 4, 6]
9. Useful NumPy Functions
Create Zeros
np.zeros((2, 2))
Create Ones
np.ones((3, 3))
Range of Numbers
np.arange(0, 10)
10. Indexing and Accessing Elements
arr = np.array([10, 20, 30])
print(arr[0]) # Output: 10
11. Shape of Array
arr = np.array([[1, 2], [3, 4]])
print(arr.shape)
👉 Output: (2, 2) → 2 rows, 2 columns
12. Simple Practical Example
import numpy as np
scores = np.array([50, 60, 70, 80])
average = np.mean(scores)
print("Average score:", average)
13. Real-Life Uses of NumPy
Students can use NumPy for:
- Data analysis
- Scientific calculations
- Machine learning
- AI projects
- Financial calculations
14. NumPy in the Real World
NumPy is used with:
- Pandas (data analysis)
- Matplotlib (visualization)
- Machine learning tools
15. Simple Summary
👉 NumPy is:
- A powerful math tool in Python
- Used for fast calculations
- Important for data science and AI
Power Teaching Line (for your class)
👉 “If Python is the brain, NumPy is the calculator that makes it powerful.”
No comments:
Post a Comment