KnowledgeBoat Logo
|
OPEN IN APP

Part II: AI — Chapter 4.1

Modules & Packages

Class 10 - Exploring Robotics & AI



Multiple Choice Questions

Question 1

What does the given picture represent in NumPy?

What does the given picture represent in NumPy. Modules and Packages, APC ICSE Robotics & Artificial Intelligence Solutions Class 10.
  1. 2D arrays
  2. 1D arrays
  3. 3D arrays
  4. None of these

Answer

2D arrays

Reason — The given figure shows both row index and column index, which indicates that elements are arranged in rows and columns. In NumPy, such an arrangement represents a two-dimensional (2D) array, where each element is accessed using two indices: one for the row and one for the column.

Question 2

Which of the following is appropriate for Pandas?

  1. It is a function.
  2. It is a language.
  3. It is a library.
  4. It is a hardware.

Answer

It is a library.

Reason — Pandas is a software library developed by Wes McKinney for the Python programming language for data manipulation and analysis. It is an open-source Python library used for data structures and their operations.

Question 3

Which of the following library uses the functionality of ndarray?

  1. math library
  2. NumPy library
  3. Pandas library
  4. statistics library

Answer

NumPy library

Reason — The ndarray is a component of the NumPy library and provides different functions to work with dimensional arrays.

Question 4

A Series object can be created using:

  1. A sequence
  2. A ndarray
  3. A scalar value
  4. None of these

Answer

A sequence

Reason — A Series is a one-dimensional data structure and is created by passing a sequence of data values while defining the Series object.

Question 5

In Python, ............... is also known as Numerical Python.

  1. NumPy
  2. SciPy
  3. Pandas
  4. None of these

Answer

NumPy

Reason — NumPy stands for Numerical Python, which is the expanded form of its name.

Question 6

Pandas was developed by:

  1. Brendan Eich
  2. Guido Van Rossum
  3. Wes McKinney
  4. Travis Oliphant

Answer

Wes McKinney

Reason — Pandas is a Python software library developed by Wes McKinney for data manipulation and analysis.

Question 7

Which of the following functions calculates the mean of a NumPy array arr?

  1. np.mean(arr)
  2. arr.mean()
  3. mean(arr)
  4. arr.avg()

Answer

np.mean(arr)

Reasonnp.mean() is used to find the arithmetical mean or the average value of the elements in a NumPy array.

Syntax: np.mean(array)

Question 8

Series in Pandas is a:

  1. One dimensional data structure
  2. Two-dimensional data structure
  3. Three-dimensional data structure
  4. None of these

Answer

One dimensional data structure

Reason — A Series in Pandas represents data along a single axis and is described as a single dimensional (1D) array.

Question 9

The term 'Pandas' has been derived from:

  1. Pinned data
  2. Processed data
  3. Panel data
  4. Python data

Answer

Panel data

Reason — The term Pandas is derived from Panel Data, which refers to multi-dimensional structured data commonly used in statistics and econometrics.

Question 10

Which of the following is used to install Pandas?

  1. -m pip install pandas
  2. --m pip install
  3. install pandas
  4. download pandas

Answer

-m pip install pandas

Reason — Pandas is installed using the PIP (Preferred Installer Program) with the command py -m pip install pandas, which installs the Pandas library in the Python environment.

Fill Blanks

Question 1

Fill in the blanks:

  1. Data Visualisation is the process of creating, interpreting and comparing data into ................ contexts.
  2. Series is a one-dimensional data structure that contains a ................ set of data.
  3. ................ uses mainly two types of data structures such as Series and DataFrame.
  4. ................ is the alternate name given to the actual module which can be imported in Python program.
  5. ................ chart is used to plot the relationship or dependence of one variable on another to display changes or trends.
  6. ................ is a graphical representation of data where data is grouped into continuous number ranges in the form of vertical bars.

Answer

  1. Data Visualisation is the process of creating, interpreting and comparing data into visual contexts.
  2. Series is a one-dimensional data structure that contains a homogeneous set of data.
  3. Pandas uses mainly two types of data structures such as Series and DataFrame.
  4. Alias is the alternate name given to the actual module which can be imported in Python program.
  5. Line chart is used to plot the relationship or dependence of one variable on another to display changes or trends.
  6. Histogram is a graphical representation of data where data is grouped into continuous number ranges in the form of vertical bars.

Name the Following

Question 1

Name the functions with the reference to NumPy.

  1. used to create an array with a range of values
  2. used to find the greatest value in a ndarray
  3. used to find the smallest value in a ndarray
  4. used to find the arithmetical mean of the elements in a ndarray
  5. used to find the mid value of a ndarray

Answer

  1. np.arange()
  2. np.max()
  3. np.min()
  4. np.mean()
  5. np.median()

Assertion and Reason Based Question

Question 1

Assertion (A): Python NumPy library is widely used library for carrying out mathematical operations involving dimensional arrays.

Reason (R): The term 'dimensional arrays' refers to as a sequence of mutable elements similar to the Python Lists.

Based on the above assertion and reasoning, choose an appropriate statement from the options given below:

  1. Both A and R are true and R is the correct explanation of A.
  2. Both A and R are true and R is not the correct explanation of A.
  3. A is true but R is false.
  4. A is false but R is true.
  5. Both A and R are false.

Answer

Both A and R are true and R is not the correct explanation of A.

Reason — Assertion (A) is true because NumPy is widely used for carrying out mathematical operations involving dimensional arrays. Reason (R) is also true because dimensional arrays are sequences of mutable elements similar to Python lists. However, R only explains the meaning of dimensional arrays and does not explain why NumPy is widely used for mathematical operations.

Application Based Question

Question 1

Pandas library has two primary data structures viz, Series and DataFrame that can handle the vast majority in various fields such as finance, statistics, etc. In Python, a library is available which is used for data visualisation, an essential component of Data Science.

With the above discussions, it is expected that the student must be confident to answer the following statements, as stated below:

(a) It is a two-dimensional (2D) structure in Pandas (similar to a NumPy 2D array) represented along two axes (i.e., X-axis and Y-axis).

(b) It is a Python library that allows the user to plot various two dimensional graph such as bar graph, line graph, etc.

(c) It is an important data structure of Pandas library which represents data along the x-axis like the structure 1D array.

Answer

(a) DataFrame

(b) Matplotlib

(c) Series

Write Short Notes

Question 1

Write short notes on Line graph.

Answer

A line graph, also called a line chart, displays information as a series of data points connected by straight line segments. It is used to plot the relationship of one variable on another and to display changes or trends over time, making it ideal for continuously changing data. In Python, it is created using the plot() function by providing values for the X-axis and Y-axis, and the show() function is used to display the graph. The shape of a line graph is not necessarily a straight line from start to end, as it depends on the values plotted on the X-axis and Y-axis.

Question 2

Write short notes on Bar graph.

Answer

A bar graph is one of the most popular ways to visualise data. It represents data using rectangular bars to clearly show comparisons between different categories, where the height or length of each bar corresponds to the value it represents. Bar graphs are commonly used for comparing categories and analysing changes over time. In data visualisation, bars can be displayed either vertically or horizontally. In Python, a bar graph is plotted using the bar() function for vertical bars or the barh() function for horizontal bars, and the show() function is used to display the graph.

Question 3

Write short notes on Pie graph.

Answer

A pie graph is a basic and easy-to-understand technique of data visualisation represented in the form of a circular region. The circle is divided into slices or sectors, where each slice represents a category and shows its proportion of the whole. The total value of a pie graph is always considered to be 100%, which subtends an angle of 360 degrees. Pie graphs are useful for comparing different parts of a whole. In Python, a pie graph is plotted using the pie() function along with suitable data values and labels.

Question 4

Write short notes on Scatter plot.

Answer

A scatter plot is a two-dimensional data visualisation plot that uses dots to represent values for two different variables. Each dot (marker) represents an observation, where its position shows the values on the X-axis and Y-axis. Scatter plots are used to determine the relationship between different data groups and to observe how a change in one variable affects another. In Python, a scatter plot is created using the scatter() function along with show() to display the graph.

Question 5

Write short notes on Histogram.

Answer

A histogram is a graphical representation of data where values are grouped into continuous number ranges called class intervals or bins and displayed in the form of vertical bars. The horizontal axis represents the number ranges, while the vertical axis shows the frequency or number of observations. A histogram is used to represent the distribution of continuous or discrete data. In Python, a histogram is created using the hist() function along with show() to display the graph.

Question 6

Write short notes on Series.

Answer

A Series is an important data structure of the Pandas library that represents data along a single axis and is known as a one-dimensional (1D) array. It contains a set of data values along with a corresponding set of indices, which may be integers or strings. The indices act as reference points to access the data values of the Series. A Series can be created using default indexing or custom indexing depending on the user’s requirement.

Question 7

Write short notes on DataFrame.

Answer

A DataFrame is a two-dimensional data structure of the Pandas library that represents data in a tabular or matrix form using rows and columns. It is similar to a NumPy 2D array and is represented along two axes, namely the X-axis and Y-axis. A DataFrame uses two types of indices: row indices and column names, which may be numbers, letters, or strings. It can store heterogeneous data and its values and size are mutable, meaning they can be changed as required.

Question 8

Write short notes on NumPy.

Answer

NumPy stands for Numerical Python and is a Python library used for carrying out mathematical operations involving dimensional arrays. The term dimensional arrays refers to a sequence of mutable elements similar to Python lists. NumPy works efficiently with N-dimensional arrays and provides powerful functions for fast mathematical operations. It is widely used in Python for numerical computations and array processing.

Answer the Following Questions

Question 1

What do you mean by NumPy library in Python?

Answer

The NumPy library in Python is used for carrying out mathematical operations involving dimensional arrays. The term dimensional arrays refers to a sequence of mutable elements similar to Python lists. NumPy is widely used for fast mathematical operations and works efficiently with N-dimensional arrays.

Question 2

Differentiate between 1D and 2D arrays.

Answer

Differences between between 1D and 2D arrays are:

1D Array2D Array
It is a one-dimensional array where elements are arranged along a single axis.It is a two-dimensional array where elements are arranged in rows and columns.
Elements are accessed using a single index.Elements are accessed using two indices (row index and column index).
It represents a simple linear collection of elements.It represents a matrix or table-like structure.

Question 3

What is meant by module? Give an example.

Answer

A module is referred to as a piece of software which has a specific functionality. It is a file like Python program file that contains classes, functions and variables, and also includes executable code.

Example: math module

Question 4

Write two features of Pandas library.

Answer

Two features of the Pandas library are:

  1. It supports organising data into different forms such as Series and DataFrame.

  2. Being integrated with the matplotlib library, it is capable of producing data in the form of graphs and charts for better analysis.

Question 5

Is Pandas compatible with NumPy? Comment.

Answer

Yes, Pandas is compatible with NumPy. Pandas is an extension of the NumPy library and builds on NumPy's array capabilities. It internally uses the basic functionalities of NumPy, which allows efficient data manipulation and analysis using structured data.

Question 6

Can Pandas work with NumPy arrays? Explain.

Answer

Yes, Pandas can work with NumPy arrays. Pandas is an extension of the NumPy library and builds on NumPy's array capabilities. It internally uses the basic functionalities of NumPy, which allows Pandas to perform data manipulation and analysis efficiently using NumPy arrays.

Question 7

What are the features of NumPy library?

Answer

The features of the NumPy library are:

  1. It works easily with N-dimensional arrays.
  2. It uses powerful functions to work with arrays.
  3. It uses software tools for integrating Python with C/C++.
  4. It is capable of working with Fourier transformation, linear algebra and random numbers.

Question 8

What is data visualisation? How is it useful?

Answer

Data Visualisation is the process of communicating and translating data and information into visual contexts and to make data easier for the human brain to understand. It communicates complex ideas more clearly and thus making it easier for the user to identify the analysis of logical patterns.

Usefulness of Data Visualisation:

  1. It communicates the information clearly and efficiently to the users.
  2. It displays the input data through graphical representations using different charts.
  3. It helps the users in analysing a large amount of data in a simpler way.
  4. It supports by finding incorrect, corrupted or missing values.
  5. It makes complex data more accessible, understandable and usable.

Question 9(a)

Explain mean in the context of basic statistics in NumPy.

Answer

In NumPy, mean refers to the arithmetical mean or the average value of the elements in an array. It is calculated by adding all the elements of the array and dividing the sum by the total number of elements. The mean always results in a float type value. In NumPy, the mean is calculated using the np.mean() function.

Question 9(b)

Explain median in the context of basic statistics in NumPy.

Answer

In NumPy, median refers to the mid value of an array. The median is calculated only after sorting the values of the array. If there is one middle value, that value is the median. If there are two middle values, the average of the two middle values is taken as the median. The median always results in a float type value. In NumPy, the median is calculated using the np.median() function.

Question 10

Create a NumPy ndarray object by using the array() function storing values: [12, 34, 22, 30, 26, 18, 20, 24, 42, 10]

Using the above values, write Python codes to perform the following tasks:
(a) mean of the array object
(b) smallest element of the array object
(c) greatest element of the array object

Answer

# creating a NumPy ndarray object
import numpy as np

arr = np.array([12, 34, 22, 30, 26, 18, 20, 24, 42, 10])
print("Elements present in NumPy array:", arr)

# (a) mean of the array
mean_value = np.mean(arr)
print("Mean of the array:", mean_value)

# (b) smallest element of the array
min_value = np.min(arr)
print("Smallest element of the array:", min_value)

# (c) greatest element of the array
max_value = np.max(arr)
print("Greatest element of the array:", max_value)
Output
Elements present in NumPy array: [12 34 22 30 26 18 20 24 42 10]
Mean of the array: 23.8
Smallest element of the array: 10
Greatest element of the array: 42
PrevNext