Ch 6 Introduction to Python Packages Class 9 Notes Important Points

Share with others

Ch 6 Introduction to Python Packages Class 9 Notes Important Points

Ch 6 Introduction to Python Packages Class 9 Notes Important Points

Python Packages
Python Packages

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.

  1. mark_student
  2. student_mark
  3. StudentMark
  4. if

Ans. if

Q2. What is the correct syntax to check the data type of a variable?

  1. print(typeof x)
  2. print(typeof(x))
  3. print(type(x))
  4. print(type x)

Ans. print(type(x))

Q3. Which of the following command to open Jupyter Notebook in anaconda prompt?

  1. conda jupyter notebook
  2. open jupyter notebook
  3. jupyter notebook
  4. 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
Python Packages
Python Packages

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 arraysList
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 operationsIt 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]
Python Packages
Python Packages

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

TaskCode
Create arraynp.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 valuesnumpy.random.random(5)
Creating a 2-Dimensional constant value array (3X4 – 3 rows and 4 columns) having all 6snumpy.full((3,4),6)
Creating a sequential array from 0 to 30 with gaps of 5numpy.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])

TaskCode
Add 5 to each element of array “A”A + 5
Divide each element of array “A” by 5A/5
Square each element of array “B”B**2
Multiply two arraysA * 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

TaskFunction NameCode (Let assume array name “A”)
To find the type of an arraytype( )type(A )
To find the dimensions of an arrayndimA.ndim
To find Shape of an arrayshapeA.shape
To find Size of an arraysizeA.size
To find datatype of elements stored in the arraydtypeA.dtype

Mathematical Functions in NumPy

TaskFunction NameCode (Let assume array name “A”)
Finding out maximum element of an arraymax( )A.max( )
Finding out row-wise maximum elementsmax( )A.max(axis = 1)
Finding out column-wise minimum elementsmin( )A.min(axis = 0)
Sum of all array elementssum( )A.sum( )
Python Packages
Python Packages

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

——————————————————————————————————————————

Unit 4 – Generative AI NOTES Important Points

Unit 4 – Generative AI MCQ

Unit 4 – Generative AI Question Answers


Share with others

Leave a Reply

error: Content is protected !!