Ch 6 Introduction to Python Packages Class 9 Notes Important Points
Ch 6 Introduction to Python Packages Class 9 Notes Important Points
Introduction
Till now we have learned many concepts in python such as variables, datatypes, conditional statement, loops etc. Before jumping into python packages, let us test our understanding of the concept that we had learned in previous chapters
Revision Time
Q1. Identify the invalid variable name from the following.
- mark_student
- student_mark
- StudentMark
- if
Ans. if
Q2. What is the correct syntax to check the data type of a variable?
- print(typeof x)
- print(typeof(x))
- print(type(x))
- print(type x)
Ans. print(type(x))
Q3. Which of the following command to open Jupyter Notebook in anaconda prompt?
- conda jupyter notebook
- open jupyter notebook
- jupyter notebook
- activate jupyter notebook
Ans. jupyter notebook
Q4. Which of the following “if” statement is invalid.
1. if (a>b) : print (a)
2. if (a>b) :
print (a)
3. if (a>b) :
print (a)
4. if (a>b) :
print (a)
Ans. 2. if (a>b) :
print (a)
Q5. Write the output of the following code.
x = 2
while x <= 10:
print(x)
x = x + 1
Ans.
2
3
4
5
6
7
8
9
10
What Are Python Packages?
A package is a space where we can find codes or functions or modules of similar type. In other words we can say that a Python package is a collection of related code and functions. There are various packages readily available to use for free. Some packages are given below.
1. Numpy (Numerical Python): It works with large numerical data and arrays. This is the foundation of math and data science in Python.
2. OpenCV: An image processing package that can work with images and perform operations like cropping, resizing, and editing.
3. Matplotlib: A package that helps in plotting analytical (numerical) data in graphical form. It helps users to visualize the data.
4. NLTK: NLTK stands for Natural Language Tool Kit and it helps with tasks related to textual data. It is one of the most commonly used packages for Natural Language Processing.
5. Pandas: A package that helps in handling 2-dimensional data tables in Python. It is useful when working with data from Excel sheets and other databases.
How to Install Python Packages?
To use any package in python, first we have to install the package. To install Numpy package, write the following command in Anaconda
conda install numpy
Write the following command to install multiple packages together:
conda install numpy pandas matplotlib
During installation, type Y when asked “Proceed (y/n)?”.
How to Use a Package in Python?
To use a package, we need to import the package wherever it is required. There are various ways of importing a package in Python:
import numpy # Imports entire NumPy package
import numpy as np #It import numpy as an alias 'np'. We can now use np instead of numpy
from numpy import array #It imports only array() function from the numpy package
from numpy import array as arr #It imports only array() function from the numpy package as an alias 'arr'
NOTE: We can also import multiple functions from a numpy or any other package in a single line!
What is NumPy?
NumPy stands for Numerical Python, is the most important package for mathematical and logical operations in Python. NumPy also works with arrays, which is nothing but homogenous collection of Data.
An array is a set of values of same datatype like numbers, characters, Booleans, etc. In NumPy, the arrays used are known as ND-arrays (N-Dimensional Arrays) as NumPy comes with a feature of creating n-dimensional arrays in python.
Difference between NumPy arrays and List
| NumPy arrays | List |
| It is a homogenous collection of Data. | It is a heterogeneous collection of Data. |
| It can contain only one type of data. | It can contain multiple types of data. |
| Arrays take less memory space. | Lists acquire more memory space. |
| It is widely used for arithmetic operations | It is widely used for data management. |
| Example: To create a Numpy array ‘A’: import numpy A=numpy.array([1,2,3,4,5,6,7,8,9,0]) | Example: To create a list: A = [1,2,3,4,5,6,7,8,9,0] |
Creating Arrays with NumPy
Before using NumPy, we have to import it.
import numpy as np
Here are some ways by which we can create arrays using NumPy package
| Task | Code |
| Create array | np.array([1,2,3,4,5]) |
| Create 2D zero array (4×3) (4X3 – 4 rows and 3 columns) | np.zeros((4,3)) |
| Creating an array with 5 random values | numpy.random.random(5) |
| Creating a 2-Dimensional constant value array (3X4 – 3 rows and 4 columns) having all 6s | numpy.full((3,4),6) |
| Creating a sequential array from 0 to 30 with gaps of 5 | numpy.arrange(0,30,5) |
Arithmetic Operations on Arrays
Let we assume that there are two arrays
A = np.array([1,2,3,4,5])
B = np.array([6,7,8,9,0])
| Task | Code |
| Add 5 to each element of array “A” | A + 5 |
| Divide each element of array “A” by 5 | A/5 |
| Square each element of array “B” | B**2 |
| Multiply two arrays | A * B |
| Access 2nd element of array “B” | B[1] |
Do you know
No need to use loops! NumPy performs element-wise operations automatically.
Functions to Explore Array Properties
| Task | Function Name | Code (Let assume array name “A”) |
| To find the type of an array | type( ) | type(A ) |
| To find the dimensions of an array | ndim | A.ndim |
| To find Shape of an array | shape | A.shape |
| To find Size of an array | size | A.size |
| To find datatype of elements stored in the array | dtype | A.dtype |
Mathematical Functions in NumPy
| Task | Function Name | Code (Let assume array name “A”) |
| Finding out maximum element of an array | max( ) | A.max( ) |
| Finding out row-wise maximum elements | max( ) | A.max(axis = 1) |
| Finding out column-wise minimum elements | min( ) | A.min(axis = 0) |
| Sum of all array elements | sum( ) | A.sum( ) |
Disclaimer : I tried to give you the correct Notes of Ch 6 Introduction to Python Packages Class 9 (AI-417), but if you feel that there is/are mistakes in the Notes Ch 6 Introduction to Python Packages Class 9 given above, you can directly contact me at csiplearninghub@gmail.com. Also Share your valuable feedback about the above Ch 6 Introduction to Python Packages Class 9 or any other suggestion so that I can give better content to you. The Notes of Ch 6 Introduction to Python Packages Class 9 are from NCERT BOOK available on CBSE website. The content is not copied from any other site.
Important Links
Class IX A.I. Book
Class IX AI Curriculum 2025-26
Class X AI Book
Class X AI Curriculum 2025-26
Python Manual
—————————————————————————————————————————–
Chapter 1: Algorithms and Flowcharts NOTES
Chapter 2: Introduction to Python NOTES
Chapter 3: Introduction to tools for AI NOTES
Chapter 4: More about List and Tuples NOTES
Chapter 5: Flow of control and Conditions NOTES
Chapter 6 – Introduction to Packages NOTES
——————————————————————————————————————————
Unit 1 – A.I. Reflection Project Cycle and Ethics Class 9 Notes Important Points
Unit 1 – A.I. Reflection Project Cycle and Ethics Class 9 MCQ
Unit 1 – A.I. Reflection Project Cycle and Ethics Class 9 Question Answers
—————————————————————————————————————————–
Unit 2 – Data Literacy NOTES Important Points
Unit 2 – Data Literacy MCQ
Unit 2 – Data Literacy Question Answers
——————————————————————————————————————————
Unit 3 – Math in AI NOTES Important Points
Unit 3 – Math in AI MCQ
Unit 3 – Math in AI Question Answers
——————————————————————————————————————————