0% found this document useful (0 votes)
25 views156 pages

Xii Ip SSM Ahd 2023-24

The document outlines the syllabus for the Informatics Practices (065) subject for the academic session 2023-24, detailing both theoretical and practical components. It includes a month-wise breakdown of topics, practical exercises, and assessment criteria, focusing on data handling using Pandas, SQL database queries, computer networks, and societal impacts of technology. The document also lists the contributors and mentors involved in the syllabus creation.

Uploaded by

varshitha0816
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views156 pages

Xii Ip SSM Ahd 2023-24

The document outlines the syllabus for the Informatics Practices (065) subject for the academic session 2023-24, detailing both theoretical and practical components. It includes a month-wise breakdown of topics, practical exercises, and assessment criteria, focusing on data handling using Pandas, SQL database queries, computer networks, and societal impacts of technology. The document also lists the contributors and mentors involved in the syllabus creation.

Uploaded by

varshitha0816
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 156

SUBJECT: INFORMATICS PRACTICES (065)

SESSION: 2023-24

1|Page
CHIEF PATRON

SMT SHRUTI BHARGAV


(Deputy Commissioner, KVS RO Ahmedabad)

PATRON

SMT VINITA SHARMA


(Assistant Commissioner KVS RO Ahmedabad )

2|Page
MENTOR

SMT SUNITA KUMARI


(Principal. KV No.2 Army, Baroda)

CONTENT CREATOR TEAM

RAKSHA PARMAR, PGT (CS) ASHISH KUMAR CHAURDIA, MAYURI PATEL, PGT (CS)
KV SABARMATI PGT (CS) KV SILVASSA
KV NO. 2 EME, BARODA

MRS NAMRATA SHAH VIVEK KUMAR GUPTA KAMLESH AMIN, PGT (CS)
KV ONGC MEHSANA KV ONGC ANKLESHWAR KV NO. 3 SU JAMNAGAR
3|Page
INDEX

THEORY PART

PAGE NO.
UNIT UNIT NAME
NO.
FROM TO

1. SPLIT UP SYLLABUS 5 9

2. DATA HANDLING USING PANDAS AND DATA 9 48


VISUALIZATION

3. DATABASE QUERY USING SQL 49 76

4. INTRODUCTION TO COMPUTER NETWORKS 77 133

5. SOCIETAL IMPACTS 134 149

PRACTICAL PART

6. LIST OF PRACTICALS 150 156

4|Page
KENDRIYA VIDYALAYA SANGATHAN: AHMEDABAD REGION
Month Wise Split up syllabus (Theory & Practical) 2023-24
Class: XII Subject: Informatics Practices (065) Max Marks: 70
Month Portion to be covered
April 2023 Unit 1: Data Handling using Pandas and Data Visualization
Data Handling using Pandas -I
Introduction to Python libraries- Pandas, Matplotlib. Data structures
in Pandas - Series and Data Frames.

Series: Creation of Series from – ndarray, dictionary, scalar value;


mathematical operations; Head and Tail functions; Selection, Indexing
and Slicing.

Data Frames: creation - from dictionary of Series, list of


dictionaries, Text/CSV files; display; iteration;

May-June Operations on rows and columns: add, select, delete, rename;


2023 Head and Tail functions; Indexing using Labels,
Boolean Indexing;
Importing/Exporting Data between CSV files and Data Frames.

July 2023 Unit 1: Data Handling using Pandas and Data


Visualization (Contd.)
Data Visualization
Purpose of plotting; drawing and saving following types of plots using
Matplotlib – line plot, bar graph, histogram

Customizing plots: adding label, title, and legend in plots

August Unit 2: Database Query using SQL


2023
Revision of database concepts and SQL commands covered in Class
XI

Maths Functions POWER (), ROUND (), MOD () etc.

Text functions: UCASE ()/UPPER (), LCASE ()/LOWER (),


MID()/SUBSTRING ()/SUBSTR (), LENGTH (), LEFT (), RIGHT (),
INSTR (), LTRIM (), RTRIM (), TRIM ().

Date Functions: NOW (), DATE (), MONTH (), MONTHNAME (), YEAR
(), DAY (), DAYNAME ().

Aggregate Functions: MAX (), MIN (), AVG (), SUM (), COUNT (),
using COUNT (*).
5|Page
Querying and manipulating data using Group by, Having, Order by.
Working with two tables using equi-join.

September Unit 3: Introduction to Computer Networks


2023
Introduction to networks, Types of networks: PAN, LAN, MAN, WAN.
Network Devices: modem, hub, switch, repeater, router, gateway
Network Topologies: Star, Bus, Tree, Mesh.
Introduction to Internet, URL, WWW, and its applications- Web, email,
Chat, VoIP.
Website: Introduction, difference between a website and webpage,
static vs dynamic web page, web server and hosting of a website.
Web Browsers: Introduction, commonly used browsers, browser
settings, add-ons and plug-ins, cookies.

October Unit 4: Societal Impacts


2023 Digital footprint, net and communication etiquettes Data protection,
intellectual property rights (IPR), plagiarism, licensing and copyright,
free and open source software (FOSS).

Cybercrime and cyber laws, hacking, phishing, cyber bullying,


overview of Indian IT Act.

November E-waste: hazards and management.


2023 Awareness about health concerns related to the usage of technology.
Revision Work

December Revision Work, Pre-Board – I


2023
January Remedial classes, Pre-Board – II
2023 & Practical Examination
February
2023
March CBSE Board Exams
2023
Note: For Any Changes / Updated / Discrepancy CBSE Syllabus may be referred

6|Page
Split up syllabus (Theory & Practical)
Class: XII Subject: Informatics Practices
Unit Unit Name Marks (Theory)
I Data Handling using Pandas and Data 25
Visualization
II Database Query using SQL 25
III Introduction to Computer Networks 10
IV Societal Impacts 10
Total 70

PRACTICAL MARKS DISTRIBUTION


Unit Unit Name Marks (Theory)
1 Python Program Using Pandas and 8
Matplotlib
2 SQL Queries 7
3 Practical File (Min. 15 Programs Based on 5
Pandas, 4 Based on Matplotlib and 15
SQL Queries must be included)
4 Project Work 5
5 Viva Voce 5
Total 30

7|Page
Suggested Practical List:
A. Data Handling
1. Create a pandas series from a dictionary of values and an ndarray
2. Given a Series, print all the elements that are above the 75th percentile.
3. Create a Data Frame quarterly sales where each row contains the item
category, item name, and expenditure. Group the rows by the category and
print the total expenditure per category.
4. Create a data frame based on ecommerce data and generate descriptive
statistics (mean, median, mode, quartile, and variance)
5. Create a data frame for examination result and display row labels, column
labels data types of each column and the dimensions
6. Filter out rows based on different criteria such as duplicate rows.
7. Find the sum of each column, or find the column with the lowest mean.

8. Locate the 3 largest values in a data frame.


9. Subtract the mean of a row from each element of the row in a Data Frame.
10. Replace all negative values in a data frame with a 0.
11. Replace all missing values in a data frame with a 999.
12. Importing and exporting data between pandas and CSV file
13. Importing and exporting data between pandas and MySQL database

B. Visualization
14. Given the school result data, analyse the performance of the students on
different parameters, e.g. subject wise or class wise.
15. For the Data frames created above, analyze and plot appropriate charts with
title and legend.
16. Take data of your interest from an open source (e.g. data.gov.in),
aggregate and summarize it. Then plot it using different plotting functions of
the Matplotlib library.

C. Data Management
17. Create a student table with the student id, name, and marks as attributes
where the student id is the primary key.

8|Page
18. Insert the details of a new student in the above table.
19. Delete the details of a particular student in the above table.
20. Use the select command to get the details of the students with marks more
than 80.
21. Create a new table (order ID, customer Name, and order Date) by joining
two tables (order ID, customer ID, and order Date) and (customer ID,
customer Name, contact Name, country).
22. Create a foreign key in one of the two tables mentioned above
23. Find the min, max, sum, and average of the marks in a student marks
table.
24. Find the total number of customers from each country in the table (customer
ID, customer Name, country) using group by.
25. Create a new table (name, date of birth) by joining two tables (student id,
name) and (student id, date of birth).
26. Write a SQL query to order the (student ID, marks) table in descending order of
the marks.

9|Page
Unit 1: Data Handling using Pandas
Introduction
Python Pandas Pandas is a software library written for the Python programming
language for data manipulation and analysis. Pandas is defined as an open-source
library that provides high-performance data manipulation in Python. The name of
Pandas is derived from the word Panel Data, which means an Econometrics from
Multidimensional data. It is used for data analysis in Python and developed by
Wes McKinney in 2008.
There are 3 well-established python libraries namely NumPy, Pandas and
Matplotlib specially for scientific and analytical use. These libraries allow us to
manipulate, transform and visualize data easily and efficiently.
Using the Pandas, we can accomplish five typical steps in the processing and
analysis of data, regardless of the origin of data. These steps are- load, prepare,
manipulate, model and analyze
Benefits of Pandas
The benefits of pandas over using the languages are
 Data representation: It can easily represent data in a form naturally suited
for data analysis through its DataFrame and Series data structures in a
concise manner. Doing the equivalent in C/C++ or Java would require many
lines of custom code, as these languages were not built for data analysis
but rather networking and kernel development.
 Clear code: The clear API of the Pandas allows you to focus on the core part
of the code. So, it provides clear code.
Matplotlib
It is an amazing visualization library in Python that used for 2D plots of arrays.
It is a multi-platform data visualization library which build NumPy arrays.
Matplotlib produces publication-quality figures in a variety of hardcopy formats
and interactive environments across platforms. Matplotlib can be used in Python
scripts, the Python and IPython shell, web application servers and various
graphical user interface toolkits. To get matplotlib up and running in our
environment, we need to import it. import matplotlib.pyplot as plt.
Data structures in Pandas:
Data structure is defined as the storage and management of the data for its
efficient and easy access in the future where the data is collected, modified and
the various types of operations are performed on the data respectively. Pandas
provides two data structures for processing the data, which are explained below:
(1) Series: It is one dimensional object similar to an array, list or column in a
table. It will assign a labelled index to each item in the series. By default, each
item will receive an index label from 0 to N, where N is the length of the series
minus one.

10 | P a g e
(2) DataFrame: It is a tabular data structure comprised of rows and columns.
DataFrame is defined as a standard way to store data which has two different
indexes i.e., row index and column index.

Know the Terms:


Pandas: The Pandas is a high-performance open source library for data analysis
in Python.
Matplotlib: It is a visualization library in Python that used for 2D plots of arrays.
Series: It is a one-dimensional array containing a sequence of values. Each value
has a data label associated with it also called its index. DATA HANDLING USING
PANDAS-I 7
Selection: This function returns data corresponding to axis labels matching
criteria.
Indexing: This function is used to get or set the index labels of the given series
object.
Slicing: Slicing is a powerful approach to retrieve subsets of data from a Pandas
object.
Series is a one-dimensional array like structure with homogeneous data. For
example, the following series is a collection of integers 10, 23, 56, … Pandas
Series is a one-dimensional labelled array capable of holding any data type
(integer values, string values, double value and more). A Series represents a
single column in memory. Series can only contain single list with index, whereas
DataFrames can be made of more than one series or we can say that a
DataFrames is a collection of series.
Key Points of Series
● Homogeneous data
● Size Immutable
● Values of Data Mutable
A pandas Series can be created using the following constructor − pandas. Series
(data, index, dtype, copy)
CREATION OF SERIES
A series can be created using various inputs like:
● List
● Tuple
● Dictionary
● Array

11 | P a g e
● Scalar value or constant
Create an Empty Series
A basic series, which can be created is an Empty Series.
1. Write a program to create an empty series

#import the pandas library and aliasing as pd

Ans.
import pandas as pd
s =pd.Series()
print (s)
Output is as follows: Series ([], dtype: float64)
Create a Series from List
2. Write a program to create a series by given list [‘red’,’green’,’blue’].
Ans.

import pandas as pd
c=[‘red’,’green’,’blue’]
p=pd.Series(c)
print (p)
OR
import pandas as pd
c=[‘red’,’green’,’blue’]
p=pd.Series(data=c)
print (p)
OR
import pandas as pd
p=pd.Series([‘red’,’green’,’blue’])
print (p)

Output:
0 red
1 green
2 blue

We did not pass any index, so by default, it assigned the indexes ranging from 0
to len(data)-1, i.e., 0 to 2.

3. Modify the above program and change the index values to r, g, b


Ans.
import pandas as pd
c=[‘red’,’green’,’blue’]
p=pd.Series(c,index=[‘r’,’g’,’b’])

12 | P a g e
print (p)
OR
import pandas as pd
p=pd.Series([‘red’,’green’,’blue’],index=[r,g,b])
print (p)
OR
import pandas as pd
c=[‘red’,’green’,’blue’]
p=pd.Series(c,[r,g,b])
print (p)
OR
import pandas as pd
c=[‘red’,’green’,’blue’]
p=pd.Series(data=c,index=[r,g,b])
print (p)
Output:
r red
g green
b blue

Create a Series from Tuple


4. Write a program to create a series from a given Tuple data
data=(‘1’,’Aman’,86.3,’A’).
Ans:
import pandas as pd
data=(‘1’,’Aman’,86.3,’A’)
p=pd.Series(data)
print (p)

Output
0 1
1 Aman
2 86.3
3 A

13 | P a g e
Create a Series from Dictionary
A dictionary can be passed as input and if no index is specified, then keys of the
dictionary are used to represent the index of the Series.
5. A dictionary data ={‘a’:0.,’b’:1.,’c’:2} is given.
Write a program to create series from dictionary data.

Ans.
import pandas as pd
data ={‘a’:0.,’b’:1.,’c’:2.}
s =pd.Series(data)
print(s)
Its output is as follows –
a 0.0
b 1.0
c 2.0
dtype: float64
If index is passed, the values will be displayed in the same sequence as index
values are passed.
import pandas as pd
data ={‘a’:0.,’b’:1.,’c’:2.}
s =pd.Series(data,index=[‘b’,’c’,’a’])
print(s)
Its output is as follows –
b 1.0
c 2.0
a 0.0
You can also show the specified values by giving their keys as index values.

6. Modify the above program and display values of ‘a’ and ‘c’ only.

Ans.

import pandas as pd
data ={‘a’:0.,’b’:1.,’c’:2.}
s =pd.Series(data,index=[‘a’,’c’])
print(s)
14 | P a g e
Its output is as follows –
a 0.0
c 2.0

If index value is passed other than keys value then NaN (Not a Number) as value
will be displayed.

7. Give the output:


Ans.
import pandas as pd
data ={‘a’:0,’b’:1.,’c’:2.}
s =pd.Series(data,index=[‘b’,’c’,’d’,’a’])
print(s)
Its output is as follows –
b 1.0
c 2.0
d NaN
a 0.0
dtype: float64
Observe − Index order is persisted and the missing element is filled with
NaN (Not a Number).

Create a Series from Scalar/Constant value


If data is a scalar value, an index must be provided. The value will be repeated
to match the length of index.
8. Write a program to create a series to print scalar value “5” four times.
Ans.
import pandas as pd
s =pd.Series(5, index=[0,1,2,3])
print(s)

Its output is as follows –


0 5
1 5
2 5
3 5

As you can see the “5” is printed 4 times because the length of index is 4.

15 | P a g e
Create a Series from ndarray

9. Write a program to create a series from ndarray with elements ‘a’,’b’,’c’,’d’


Ans.
import pandas as pd
import numpy as np
data =np.array([‘a’,’b’,’c’,’d’])
s =pd.Series(data)
print(s)
Its output is as follows –
0a
1b
2c
3d
dtype: object
10. Give the output:
import pandas as pd
import numpy as np
data =np.arange(10,15)
s =pd.Series(data)
print(s)
Ans.
0 10
1 11
2 12
3 13
4 14
REINDEXING
Reindexing means to conform the data to match a given set of labels along a
particular axis. Reorder the existing data to match a new set of labels. Reindexing
does not mean providing new index values; in fact, it is used to reorder the
existing data or print specified data.
11. Give the output:
16 | P a g e
import pandas as pd
name=[‘Raj’,’Ankur’,’Harsh’]
p=pd.Series(name,index=[2,5,6])
print(p)
# Reindex the series and create a new series variable
p1=p.reindex([6,2,5])
print (p1)

Ans.
2 Raj
5 Ankur
6 Harsh
6 Harsh
2 Raj
5 Ankur

12. Give the output:

import pandas as pd
name=[‘Raj’,’Ankur’,’Harsh’]
p=pd.Series(name,index=[2,5,6])
print(p) p1=p.reindex([2,5])
print (p1)

Ans.
2 Raj
5 Ankur
6 Harsh
dtype: object

2 Raj
5 Ankur
dtype: object

if other than existing index value is provided to reindex then NaN will be
displayed.

13. Give the output:

import pandas as pd
name=[‘Raj’,’Ankur’,’Harsh’]
p=pd.Series(name,index=[2,5,6])
print(p) p1=p.reindex([2,4,5])
print (p1)

Ans.
2 Raj
5 Ankur
6 Harsh
dtype: object
2 Raj
4 NaN
5 Ankur

dtype: object

17 | P a g e
ALTER INDEX VALUES
The Series index function does not only allow you to display the index items, but
you can also alter it as well. This example changes the actual index items and
places the integer values as the index.
14. Give the output:

import pandas as pd
S = pd.Series([10,20,30,40,50], index = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’])
print(S)
# Assigning New Index Values
S.index = [1, 2, 3, 4, 5]
print(“Series after new index values”)
print(S)

Ans.
a 10
e 20
i 30
o 40
u 50
dtype: int64

Series after new index values


1 10
2 20
3 30
4 40
5 50
dtype: int64

SIZE ATTRIBUTE

All pandas data structures are value-mutable (the values they contain can be
altered). All pandas data structures are size mutable except Series. The length of
a Series cannot be changed, i.e. number of columns and rows can’t be altered
once defined. Series is size immutable.

15. What is Series Size?


Ans. Size attribute returns the number of elements in the underlying data for the
given series objects.
16. Give the output:

import pandas as pd
L=[10,20,30]
S=pd.Series(L)
print(S.size)

Ans. 3

18 | P a g e
PRACTICE QUESTIONS
1. What is series? Explain with the help of an example.
Ans. Pandas Series is a one-dimensional labeled array capable of holding data
of any type (integer, string, float, python objects, etc.). The axis labels
are collectively called index.
Example:
import pandas as pd # simple array
data =pd.Series([1,2,3,4,5])
print(data)
2. Write a suitable Python code to create an empty series.
Ans.
import pandas as pd
s=pd.Series()
print (s)
3. Write single line Pandas statement to declare a Pandas series named
Packets having dataset as: [125, 92, 104, 92, 85, 116, 87, 90]
Ans. Packets = pd.Series([125, 92, 104, 92, 85, 116, 87, 90])
4. Write single line Pandas statement to declare a Pandas series named S
having dataset as: (44,65,35,77,87,90)
Ans. S=pd.Series((44,65,35,77,87,90))
5. Write single line Pandas statement to declare a Pandas series named SR
having dataset as: {1:’one’,2:’two’,3:’three’}
Ans. SR=pd.Series({1:’one’,2:’two’,3:’three’})
6. Write python code to create the Series EMP with following data (using
Dictionary)
Ans.
import pandas as pd
d={“E1”:”Sanya”,”E2”:”Krish”,”E3”:Rishav”,”E4”:”Deepak”}
EMP=pd.Series(d)
EMP.index.name=”code”

19 | P a g e
print(EMP)
7. Write python series to print scalar value “100” 5 times with index
values(1,2,3,4,5)
Ans.
import pandas as pd
s = pd.Series(100, index=[1, 2, 3, 4,5])
OR
s = pd.Series(100, [1, 2, 3, 4,5])
print (s)
8. Write python code to create the following series using Dictionary:

101 Harsh
102 Arun
103 Ankur
104 Harpahul
105 Divya
106 Jeet

Ans:
import pandas as pd
D={101:“Harsh”,102:”Arun”,103:”Ankur”,104:”Harpahul”,105:”Divya”
,106:”Jeet” }
s=pd.Series(D)
print(s)
9. Write a program to create a series by using given an array [‘a’,’b’,’c’,’d’]
and assign index values 100,101.....
Ans.
import pandas as pd
import numpy as np
data =np.array([‘a’,’b’,’c’,’d’])
s =pd.Series(data,index=[100,101,102,103])
print(s)
Its output is as follows –

20 | P a g e
100 a
101 b
102 c
103 d
dtype: object
10. Give the output:

import pandas as pd
s =pd.Series(10, index=[5,6,7,9])
print(s)

Ans.
5 10
6 10
7 10
9 10
ACCESSING DATA
Accessing using head()
By default Series.head() function display top 5 rows. To print n no of top rows,
pass n as parameter i.e. Series. head(n)
17. Write a code to create a series from empno list and show the first five
ro rows empno = [101,102,103,104,105,106,107]
Ans.
import pandas as pd
p=pd.Series(empno)
print (p.head())
output:
0 101
1 102
2 103
3 104
4 105

21 | P a g e
18. Using the above series write a single line statement to show the first
rows using head()
Ans. print(p.head(3))
output:
0 101
1 102
2 103
Accessing using tail()
By default Series.tail() function display last 5 rows. To print n no of last rows,
pass n as parameter i.e. Series. tail(n)
19. Write a code to create a series from empno list and show the last five
rows empno=[101,102,103,104,105,106,107]
Ans.
import pandas as pd
p=pd.Series(empno)
print (p.tail())
output:
2 103
3 104
4 105
5 106
6 107
20.Fill the missing statements
import pandas as pd L=[101,102,103,104,105,106,107]
_ = pd.Series(L) #statement 1
print (p.___(3)) #statement 2

output:
4 105
5 106
6 107
Ans.
p=pd.Series(L) #statement 1
print (p.tail(3)) #statement 2

22 | P a g e
Indexing
Pandas now supports three types of indexing.
(i) loc: is label based indexing.
(a) A single label
21. Give the output:
import pandas as pd
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])
print(s.loc[‘a’])
print(s.loc[0])
Ans.
10
40
# in loc[0], 0 is interpreted as a label of the index. This is not an integer
position along the index.
(b) A list of labels
22. Give the output:
import pandas as pd
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])
print(s.loc[[‘b’,’c’,1]])
Ans.
b 20
c 30
1 50
(c) A slice object with labels
A slice is a subset of series elements.
my_series[start:stop:step] where start is the index of the first element
to include, stop is the index of the item to stop and step sets the interval

23 | P a g e
23. Give the output:
import pandas as pd
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])
print(s.loc[‘a’:’c’])
Ans.
a 10
b 20
c 30
Note: Both the start and the stop are included, when present in the label
index
(ii) iloc: integer position based.
This series can also be indexed by position (using integers) even though
it has string index entries! The first item is at key 0, and the last item is
at key -1
(a) input an integer
24. Give the output:
import pandas as pd
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])
print(s.iloc[0])
Ans. 10
(b) input a list of integers
25. Write a program to print the values of 0,2,4 positions from Series
s[10,20,30,40,50] using .iloc.
Ans.
import pandas as pd
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])
print(s.iloc[[0,2,4]])
output
a 10
c 30
1 50

24 | P a g e
26. Write a program to print the values of 0,2,4 positions from Series
s[10,20,30,40,50] using .iloc.
Ans. import pandas as pd
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])
print(s.iloc[[0,2,4]])
output
a 10
c 30
1 50
(c) input a slice object with ints
A slice is a subset of series elements. my_series[start:stop:step] where
start is the index of the first element to include, stop is the index of the
item to stop without including the stop value and step sets the interval.
27. Show the first 3 values from Series using iloc.
Ans.
import pandas as pd
s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])
print(s.iloc[0:3])
a 10
b 20
c 30
(iii) with [ ]: Accessing Data from Series with Position and Using Label (index).
By using [] you can take advantage of both .loc and .iloc. You can access
the records using [] directly.
If index value is not defined you can pass default index value 0,1,2... to
access the elements.
If string index values are defined then elements can be accessed by both
ways: passing default index values (0,1,2...) or passing defined string
index values.
If integer index values are defined, [] will work only as .loc i.e. elements
can be accessed by passing defined index values only.

25 | P a g e
28. Give the output:
import pandas as pd
M=[15,-10,56,39,-90,15]
p=pd.Series(M)
print(p[0])
print(p[[0,3,4]])
Ans.
15
0 15
3 39
4 -90
29. Give the output of the following program:
import pandas as pd
s=pd.Series([10,20,30,40,50],index=[‘a’,’b’,’c’,’d’,’e’])
print(s[0]) #or print(s.iloc[0])
print(s[‘a’:’c’]) #or print(s.loc[‘a’:’c’])
print(s[2]) #or print(s.iloc[s[2])
print(s[‘a’]) #or print(s.loc[‘a’])
Its output is as follows –
Ans.
10
a 10
b 20
c 30
30
10

26 | P a g e
30. PRACTICE QUESTIONS
(i) Write python code to create the following series
101 Harsh
102 Arun
103 Ankur
104 Harpahul
105 Divya
106 Jeet
(ii) Show details of 1st 3 employees using head function
(iii) Show details of last 3 employees using tail function
(iv) Show details of 1st 3 employees without using head function
(v) Show details of last 3 employee without using tail function
(vi) Show value of index no 102
(vii) Show 2nd to 4th records
(viii) Show values of index no=101,103,105
(ix) Show details of “Arun”
Ans.
(i) import pandas as pd
name=[‘Harsh’,’Arun’,’Ankur’,’Harpahul’,’Divya’,’Jeet’]
p=pd.Series(name,index=[101,102,103,104,105,106])
print (p)
(ii) print (p.head(3))
(iii) print (p.tail(3))
(iv) print(p[:3]) or pirnt(p.loc[101:103]) or print(p.iloc[0:3]) or
print(p[[101,102,103]])
(v) print (p[-3:]) or print(p[3:]) or print(p[[104,105,106]])
(vi) print(p[102]) or print(p.loc[102])
(vii) print(p[1:4])
(viii) print(p[[101,103,105]])
(ix) print(p[p= =’Arun’])

27 | P a g e
Accessing data from a Series with Position
We can also access data from a Series by passing the position value and even
through slicing. Using a series, we can access any position values through
index by the corresponding number to retrieve values.
Eg: import pandas as pd
S = pd.Series([10,20,30,40,50], index = [‘a’,’b’,’c’,’d’,’e’])
print(S[0]) # for 0 index position
print(S[:3]) # for first 3 index position
print(S[-3:]) # for last 3 index position
print(S[-4])
print(S[3:])
print(S[2:4])

Output:
10
a 10
b 20
c 30
dtype: int64
c 30
d 40
e 50
dtye: int64
20
d 40
e 50
dtype: int64
c 30
d 40

28 | P a g e
dtype: int64

iloc and loc


Indexing and accessing can also be done using iloc and loc.
iloc is used for indexing or selecting based on position.
loc is used for indexing or selecting based on name.
Eg: import pandas as pd
s = pd.Series([1,2,3,4,5], index = [‘a’,’b’,’c’,’d’,’e’])
print(s.iloc[1:4])
print(s.loc[‘b’:’e’])
Output:
b 2
c 3
d 4
dtype: int64
b 2
c 3
d 4
e 5
dtype: int64

NOTE: All elements from index b to e are included in loc

21. Give the output:

Naming a Series
We can also give name to the columns, index and values of a Series using
‘name’ property.

29 | P a g e
Eg: import pandas as pd
s = pd.Series({‘Jan’:31, ‘Feb’:28, ‘Mar’:31})
s.name = ‘Days’
s.index.name = ‘Month’
print(s)
Output:
Month
Jan 31
Feb 28
Mar 31
Name: Days, dtype: int64
Note that the index column is assigned the name Month and data is assigned
the name Days, displayed at the bottom of the Series.
Series Object Attributes:
We can obtain various properties of a Series through its attributes. Some
common attributes of Series are:

Attribute Description
index Returns index of the series
values Return ndarray of values
dtype Returns dtype object of underlying
data
shape Returns tuple of the shape of
underlying data
nbytes Returns number of bytes of
underlying data
ndim Returns the number of dimension
size Returns number of elements
hasnans Return True if there are any NaN
empty Returns True if Series object is empty

Mathematical Operations on Series:


Mathematical operations can be performed on Series using scalar values and
functions.

30 | P a g e
Eg: Consider three series s1, s2, s3 and output obtained after mathematical
operations on them
>>>s1 >>>s2 >>>s3
1 11 1 21 101 21
2 12 2 22 102 22
3 13 3 23 103 23
4 14 4 24 104 24
dtype: int64 dtype: int64 dtype: int64

>>>s1+s2 >>>s1*s2 >>>s1+s3


1 32 1 231 1 NaN
2 34 2 64 2 NaN
3 36 3 299 3 NaN
4 38 4 336 4 NaN
dtype: int64 dtype: int64 101 NaN
102 NaN
103 NaN
104 NaN
dtype: float64

Vector operations on Series:


Series also supports vector operations. Any operations to be performed on a
series gets performed on every single element of it.
Eg: >>>s
0 11
1 12
2 13
3 14
dtype: int64

31 | P a g e
>>>s+2
0 13
1 14
2 15
3 16
dtype: int64
>>>s>13
0 False
1 False
2 False
3 True
dtype: bool

Retrieving Values using Conditions:


Eg: >>>s
0 11
1 12
2 13
3 14
dtype: int64
>>> s > 13
0 False
1 False
2 False
3 True
dtype: bool
>>> s[s>13]
3 14
dtype: int64
32 | P a g e
Deleting elements from a Series
We can delete an element from a Series using drop method by passing the
index of the element to be deleted.
Eg: >>>s
0 11
1 12
2 13
3 14
dtype: int64
>>>s.drop(2)
0 11
1 12
3 14
dtype: int64

Note: Original series does not change after dropping the element.

***********

33 | P a g e
DataFrame
A pandas DataFrame is a two (or more) dimensional data structure – basically
a table with rows and columns. The columns have names and the rows have
indexes. For instance, the price can be the name of a column and 2,3 the price
values.
A picture of a Pandas DataFrame is shown alongside:
In general, you could say that the Pandas DataFrame consists of
three main components: the data, the index, and the columns.
A pandas DataFrame can be created using the following constructor pandas.
DataFrame (data, index, columns, dtype, copy).
The parameters of the constructor are as follows:

Create a DataFrame from Dictionary


When DataFrame is created by using Dictionary, keys of dictionary are set as
columns of DataFrame. You can change the order of columns and store
specified columns. If you try to change the column name, NaN will be
displayed.
Note: Column name values must be same as dictionary keys
Q. Write python code to create a Dictionary Dic to store roll, name and marks
of 3 students. Convert Dic into DataFrame df and display the DataFrame
df.
Ans.
import pandas as pd
Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}
df=pd.DataFrame(Dic)
print (df)
Output:
roll name marks
0 1 a 24
1 2 b 53
2 3 c 66

34 | P a g e
Q. Write python code to create the DataFrame emp using dictionary:

Name Salary
101 Rohan 20000
102 Aman 25000

Ans.
import pandas as pd
emp=
pd.DataFrame({‘Name’:[‘Rohan’,’Aman’],’Salary’:[20000,25000]},
index=[101,102]);
print(emp)
or
import pandas as pd
Dic= {‘Name’:[‘Rohan’,’Aman’],’Salary’:[20000,25000]}
emp = pd.DataFrame(Dic,index=[101,102]);
print(emp)
 Iterating in Pandas DataFrame
Iteration is a general term for taking each item of something one after
another. In Pandas DataFrame, we can iterate an element in two ways:
(i) Iterating over rows:

There are three functions to iterate over rows as follows:


 iterrows() : It returns the iterator yielding each index value
along with a series containing the data in each row.
 iteritems() : It iterates over each column as key, value pair
with label as key and column value as series object.
 itertuples(): In DataFrame, it returns a tuple for each row.
The first element of the tuple will be the row’s
corresponding index value, while the remaining value are
the rows values.

35 | P a g e
(ii) Iterating over columns

In order to iterate over columns, we need to create a list of


DataFrame columns and then iterating through that list to pull out
the DataFrame columns.

 Operations on rows and columns

As we know, DataFrame is a two-dimensional data structure means data is


arranged in a tabular format like rows and columns, some basic operations
can be performed like adding, deleting, selecting and renaming. These
operations are as follows:
(i) Addition
 To add a column in Pandas DataFrame, a new list as a
column can be declared and add to an existing DataFrame.
 To add a row in Pandas DataFrame, we can concat the old
DataFrame with new one.
(ii) Selection
 To select a column in Pandas DataFrame, we can either
access the columns by calling them by their column names.
 To retrieve rows from a DataFrame, a special method is used
named DataFrame.loc []. Rows can also be selected by
passing integer location to iloc[] method.
(iii) Deletion
 To delete a column from Pandas DataFrame, drop() method
is used. Columns are deleted by dropping columns with
column names.
 To delete a row from Pandas DataFrame, drop() method is
used. Rows are deleted by dropping rows by index label.

 Head and Tail functions

head() and tail() methods or functions are used to view a small sample of
a DataFrame object. These functions are described below

(i) head():
This function returns the first n rows for the object based on position.
It is useful for quick testing if your object has the right type of data
in it.

Syntax DataFrame.head (n=5)

Parameters: n-is an integer value, number of rows to be returned where


default value is 5.
Return DataFrame with top n rows

36 | P a g e
Q. Give the output:
import pandas as pd
Dic={‘empno’:(101,102,103,104,105,106),’grade’:(‘a’,’b’,’a’,’c’,’b’,’c’) ,
’dept’: (‘sales’,’pur’,’mar’,’sales’,’pur’,’mar’)}
df=pd.DataFrame(Dic)
print(df.head(3))

Output:
empno grade dept
0 101 a sales
1 102 b pur
2 103 a mar

Q. Give the output


Ans.
import pandas as pd
Dic={‘empno’:(101,102,103,104,105,106),’grade’:(‘a’,’b’,’a’,’c’,’b’,’c’),’
dept’: (‘sales’,’pur’,’mar’,’sales’,’pur’,’mar’)}
df=pd.DataFrame(Dic)
print(df.head()[[‘empno’,’dept’]])
Output:
empno dept
0 101 sales
1 102 pur
2 103 mar
3 104 sales
4 105 pur

(ii) tail():
This function returns last n rows from the object based on position. It is
useful for quickly verifying data. e.g. after sorting

Syntax: DataFrame.tail (n=5)


Q. Give the output
import pandas as pd
Dic={‘empno’:(101,102,103,104,105,106),’grade’:(‘a’,’b’,’a’,’c’,’b’,’c’),’
dept’: (‘sales’,’pur’,’mar’,’sales’,’pur’,’mar’)}

37 | P a g e
df=pd.DataFrame(Dic)
print(df.tail())
Ans.
empno grade dept
1 102 b pur
2 103 a mar
3 104 c sales
4 105 b pur
5 106 c mar

 Indexing using Labels


Indexing in Pandas means simply selecting particular rows and columns of
a DataFrame. Indexing can also be known as subset selection.
It is common operation to pick out one of the DataFrame’s columns to work
on.
To select a column by its label, we use the .loc[] function.
Pandas DataFrame.loc attribute access a group of rows and columns by
label(s) or a boolean array in the given DataFrame.

Syntax: DataFrame.loc

loc takes two single/list/range operators separated by ','.


The first one indicates the row and the second one indicates columns.

 Boolean Indexing:
It helps us to select the data from the DataFrames using a boolean vector.
We need a DataFrame with a boolean index to use the boolean indexing.
In boolean indexing, we can filter a data in four ways:
 Accessing a DataFrame with a boolean index
 Applying a boolean mask to a DataFrame
 Masking data based on column value
 Masking data based on index value

38 | P a g e
CSV FILES
CSV (Comma-separated values) files are the comma separated values.
This type of file can be view as an excel file and separated by commas. CSV
file is nothing more than a simple text file. However, it is the most common,
simple and easiest method to store tabular data. This particular format
arranges tables by a specific structure divided into rows and columns.
Once we have the DataFrame, we can persist it in CSV on the local disk. Let’s
first create CSV file using data that is currently present in the DataFrame, we
can store the data of this DataFrame in CSV format using API called to_CSV
(…) of Pandas
Importing/Exporting Data between CSV files and DataFrames
Pandas read_csv() function is used to import a CSV file to DataFrame format.
Syntax:
df.read_csv('file_name.CSV', header=None)
Here, Header allows you to specify which row will be used as column names
for your DataFrame. Expected int value or a list of int values.
If your file does not have a header, then simply set header=None
To export a Pandas DataFrame to a CSV file, use to_csv function.
This saves a DataFrame as a CSV file.
Syntax:
to_csv(parameters)

1. Write python code to write DataFrame data into “a.csv” file.


Ans.
import pandas as pd
Dic={ ‘empno’: (101,102,103,104), ’name’:(‘a’,’b’,’c’,’d’),
’salary’: (3000,5000,8000,9000)}
df=pd.DataFrame(Dic)
df.to_csv(“a.csv”)
Note: csv can be opened in excel, notepad, etc.
2. Modify the above code and write the data in d:\software folder.

39 | P a g e
Ans.
import pandas as pd
Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),
’salary’:(3000,5000,8000,9000)}
df=pd.DataFrame(Dic)
df.to_csv(r”D:\software\a.csv”) # or df.to_csv(“D:\\software\\a.csv”)
Read CSV File as Pandas Using the read_csv() function from the pandas
package, you can import tabular data from CSV files into pandas
DataFrame:
3. Write python code to read a csv file “test.csv” from D:\
Ans.
import pandas as pd
df = pd.read_csv(‘d:\\test.csv’) #read the csv file
print(df)
How to Create CSV File in Excel
Step 1: Open excel and write data in worksheet
Step 2: Select file option from menu and click on save as ...

Step 3: Select drive and folder name where you want to save csv file
Step 4: Click on save as type option and select csv option from list.
Step 5: Click on save button
************

40 | P a g e
Data Visualization
Data visualization is the presentation of data in graphical format. It helps
people understand the significance of data by summarizing and presenting a
huge amount of data in a simple and easy to understand format and helps
communicate information clearly and effectively
Matplotlib
It is an amazing visualization library in Python that used for 2D plots of arrays.
It is a multi-platform data visualization library which build NumPy arrays.
Matplotlib produces publication-quality figures in a variety of hardcopy formats
and interactive environments across platforms. Matplotlib can be used in
Python scripts, the Python and IPython shell, web application servers and
various graphical user interface toolkits.
To get matplotlib up and running in our environment, we need to import it.
import matplotlib.pyplot as plt
Case Study Based MCQs

1. Consider the following program and answer any four questions


from (i) to (v):
1. import _______ as plt
2. plt.bar ([2,3,4,8,1],[2,4,7,3,5], label= _____ )
3. plt.legend( )
4. plt.xlabel(____ )
5. plt.ylabel(‘Height’)
6. plt._______ (‘Vertical Bar Chart’)
7. ________
(i) Which Module will be imported in Line 1 for above code?

(a)matplotlib (b) matplotlib.pyplot


(c)plotlib (d) None of these

Ans: (b)
(ii) Name the label that can be used to represent the bar chart in Line 2.
(a) Data (b) Data Values
(b) Values for X axis (d) All of these

Ans: (d)

(iii) Which message is best suited for xlabel?

41 | P a g e
(a) X values (b) Y values
(c) Legend (d) Vertical
Ans: (a)
(iv) Which method will take place at Line 6 for setting heading on the top
of Chart?

(a)Title () (b) title()


(c) Head() (d) All of these.

Ans: (b)
(v) Choose the statement to be place at Line7 of the above code.

(a)Plt.print() (b) plt.show()


(c) Plt.display() (d) plot.show()

Ans: (b)
2. If you are given to plot a histogram using numpy array as per
the code given below then answer any of four question from (i)
to (v)

from matplotlib import _____ as plt


import numpy as np
fig, ax = plt.______ (1, 1)
a= np.array([26,59,44,39,76,16,23,11,18,78])
ax.hist(a, bins=[0,10,20,30,40])
ax._____ (‘Histogram’)
ax.set_xticks ([0,10,20,30,40, ])
ax.set_xlabel(‘Percentage’)
ax._______ (‘Students’)
______

(i) Choose the correct option to import for given program:

(a) matplotlib (b) matplot

42 | P a g e
(c) pyplot (d) plot

Ans: (c)

(ii) Fill in the blank at Line 3

(a) subplots (b) subplot


(c) plot (d) subplt
Ans: (a)

(iii) Which statement is used to set title in Line 6?

(a) title (b) set_title


(c) set (d) Title

Ans: (b) set_title

(iv) How to set Y-axis label?

(a) label () (b) set_y


(c) set_ylab () (d) set_ylabel

Ans: (d) set_ylabel

(v) To fill in blank on Line 10 for showing histogram what can bee
used?

(a) plt.show() (b) plt_show()


(c) plot_show() (d) plt.show

Ans: plt.show()
3. Consider the following case and answer the from (i) to (v)

import …………. as pd
import matplotlib. _____ as plt
data= {‘Name’ : [‘Karan’, ‘Adi’, ‘Abhinav’, ‘Kirti’, ‘Rahul’ ],
‘Height’ : [60,61,63,65,61],
‘Weight’ : [47,89,52,58,50,47]}
df=pd. _________ (data)

43 | P a g e
df._____ (Kind =’hist’, edgecolor = ‘Green’, linewidth =2, linestyle=’:’ ,
fill= False)
_____________

(i)Fill in the blank in Line 1.

(a) numpy (b) pandas


(c) Python (d) matplot

Ans: (b) pandas

(ii) Fill in the blank in Line 2.

(a) pyplot (b) plot


(c) pyp (d) None of these
Ans: (a) pyplot

(iii) Which of the following is used in Line 6 to represent the data?

(a) Series (b) Matplot


(c) DataFrame (d) Plot
Ans: (c) DataFrame
(iv) For blank of Line 7 command used may be:

(a) plt (b) pyplot


(c) plot (d) figure

Ans: (c)plot

(v) To show the above graph which statement is used in Line 8?

(a) plot.show (b) plot.show()


(c) plt.show (d) plt.show()
Ans: (d) plt.show()

44 | P a g e
1. What is true about Data Visualization?

A. Data Visualization is used to communicate information clearly and


efficiently to users by the usage of information graphics such as tables and
charts.
B. Data Visualization helps users in analyzing a large amount of data in a
simpler way.
C. Data Visualization makes complex data more accessible, understandable,
and usable.
D. All of the above

Ans: D

Explanation: Data Visualization is used to communicate information clearly


and efficiently to users by the usage of information graphics such as tables
and charts. It helps users in analyzing a large amount of data in a simpler
way. It makes complex data more accessible, understandable, and usable.

2. Which method is used to save the output of pyplot in the form of image
file?

A. savefig(‘filename’)
B. save_fig(‘filename)
C. save_figure(‘filename’)
D. save_img(‘filename’)

Answer: A

3. Data visualization is also an element of the broader _____________.

A. deliver presentation architecture


B. data presentation architecture
C. dataset presentation architecture
D. data process architecture

Answer: B

45 | P a g e
4. The command used to give a heading to a graph is _________
A. plt.show()
B. plt.plot()
C. plt.xlabel()
D. plt.title()

Answer: D

5. Common use cases for data visualization include?

A. Politics
B. Sales and marketing
C. Healthcare
D. All of the above

Answer: D

6. Which are pros of data visualization?

A. It can be accessed quickly by a wider audience.


B. It can misrepresent information
C. It can be distracting
D. None Of the above

Ans: A

Explanation: Pros of data visualization: it can be accessed quickly by a wider


audience.

7. Which are cons of data visualization?

A. It conveys a lot of information in a small space.


B. It makes your report more visually appealing.
C. visual data is distorted or excessively used.
D. None Of the above

Ans: C

Explanation: It can be distracting: if the visual data is distorted or


excessively used.

8. Which one of the following is most basic and commonly used techniques?

A. Line charts
B. Scatter plots
C. Population pyramids
D. Area charts

46 | P a g e
Answer: A

Explanation: Line charts. This is one of the most basic and common
techniques used. Line charts display how variables can change over time.

9. Which is a python package used for 2D graphics?

A. matplotlib.pyplot

B. matplotlib.pip

C. matplotlib.numpy

D. matplotlib.plt

ANS: A

10. Observe the output figure. Identify the coding for obtaining this output.

A. import matplotlib.pyplot as plt

plt.plot([1,2,3],[4,5,1])

plt.show()

B. import matplotlib.pyplot as plt

plt.plot([1,2],[4,5])

plt.show()

C. import matplotlib.pyplot as plt

plt.plot([2,3],[5,1])

plt.show()

D. import matplotlib.pyplot as plt

plt.plot([1,3],[4,1])

plt.show()

ANS: A

12. Identify the right type of chart using the following hints.

47 | P a g e
Hint 1: This chart is often used to visualize a trend in data over intervals of
time.

Hint 2: The line in this type of chart is often drawn chronologically.

A. Line chart B. Bar chart

C. Pie chart D. Scatter plot

ANS: A

13. Which of the following method will be add inside the file to display plot?

A. show()

B. display()

C. plot()

D. execute()

ANS: show()

14. Which method is used to plot horizontal bar graph in pyplot?

A. horizontal_bar()

B. barh()

C. hbar()

D. bar()

ANS: C

15. Which method is used to plot histogram in pyplot?

A. his()

B. hist()

C. Hist()

D. histogram()

ANS: B

48 | P a g e
DATABASE USING SQL

Revision of SQL

Database  Is a collection of records , the related data are organized in such


a manner that they can easily be accessed using DBMS.
DBMS  Database Management System
Advantages of DBMS
 Minimize the duplication of data – data redundancy
 Stores large amount of data
 Reliable result
 Allows user to make different queries as per requirement
 Updating easier
RDBMS – Relational Database Management System
Commonly used terms in RDBMS -
 Relation – Table
 Attributes – column of a table
 Tuple – rows of a table
 Cardinality – no of rows in a relation
 Degree – no of attributes in a relation
Primary Key – an attribute which uniquely identifies each and every record of a
table in relational database.
Candidate Key – The attributes which can become primary key but not declared
is called Candidate Key
Alternate Key – Remaining candidate keys are also known as Alternate key
Foreign key – a non key attribute which is derived from primary key of some
other table, then in current table it ‘s called Foreign key.
Structured Query Language (SQL)
(i) DDL - Data Definition Language
- CREATE  To create database or table
- ALTER  To update the structure of a table
- DROP  To delete the database or table
(ii) DML - Data Manipulation Language
- Commands that deals with manipulation of data in the table
- INSERT
- UPDATE
- DELETE
- SELECT
(iii) DCL - Data Control Language
- It deals with the rights , permission and other controls of the
database system.
- Grant  it gives user’s access privilege to a database
- Revoke  It withdraws user’s access privileges given by using
the GRANT command
DATA TYPE OF ATTRIBUTE:

49 | P a g e
 Data type indicates the type of data value that an attribute can have
and the operations that can be performed on the data of that attribute

CHAR  Fixed length


 Declaring CHAR (10) implies to reserve spaces for 10
characters. If data does not have 10 characters MySQL fills the
remaining characters with spaces padded on the right.

VARCHAR  Variable length


 declaring VARCHAR (30) means a maximum of 30 characters
can be stored but the actual allocated bytes will depend on the
length of entered string
INT Integer value. Each INT value occupies 4 bytes of storage

FLOAT Holds numbers with decimal points. Each FLOAT value occupies 4
bytes.
DATE The DATE type is used for dates in 'YYYY-MM-DD' format. YYYY is the
4 digit year, MM is the 2 digit month and DD is the 2 digit date

Difference between Char and Varchar

CHAR data type VARCHAR Data type


1. It simply represents a 1. It represents a variable
character data type. character data type
2. It stores values in fixed 2. It stores values in variable
lengths and are occupied with lengths and are not occupied
space characters to match the with any characters.
specified length.
3. It uses static memory 3. It uses dynamic memory
allocation allocation
4. It can hold a maximum of 255 4. It can hold a maximum of
character 65535 character.

CONSTRAINTS:

 Constraints are certain types of restrictions on the data values that an


attribute can have. They are used to ensure the accuracy and reliability
of data.

50 | P a g e
 SQL queries:

DDL Commands
1. CREATE DATABASE Syntax : Example :
CREATE DATABASE CREATE DATABASE EMP_DATA;
<DBNAME>;
2. For using /opening Syntax : Example :
Database USE <DBNAME>; USE EMP_DATA;
3. To show all available Syntax : Example :
databases SHOW DATABASES; SHOW DATABASES;
4. To create table Syntax : Example :
CREATE TABLE CREATE TABLE EMP
<table_name> (EMPNO INT ,
(<col_name> ENAME VARCHAR(20),
<datatype> <size> SALARY INT);
constraint,
<col_name> CREATE TABLE EMP
<datatype> <size> (EMPNO INT PRIMARY KEY,
constraint,---------- ENAME VARCHAR(20),
); SALARY INT);

51 | P a g e
5. Describe table Syntax : Example :
DESCRIBE
– can view the <TABLE_NAME>;
structure of the table

6. Alter table – to Syntax : Example :


change the structure ALTER TABLE (a) Add an attribute to an existing
of the table like <TABLE_NAME> table
Adding new column, ADD/MODIFY/DROP
deleting a column etc. <COLUMN_NAME>…; ALTER TABLE STUDENT
ADD MARKS INT;

(b) Modify datatype of an attribute

ALTER TABLE STUDENT


MODIFY MARKS FLOAT;

(c) Remove an attribute

ALTER TABLE STUDENT


DROP MARKS;
7. Drop table - DROP Syntax : Example :
statement to remove DROP TABLE Command to delete a database
a database or a table <table_name>; EMP_DATA.
permanently from the DROP DATABASE EMP_DATA;
system. Syntax to drop a
database: DROP Command to delete a table
DATABASE db_name; STUDENT.
DROP TABLE STUDENT;
DML Commands
8. Insertion of Record Syntax : Example :
INSERT INTO INSERT INTO STUDENT
<TABLE_NAME> VALUES (11, ‘MEENU’, ‘2005-10-
(<col_name>,<col_na 25’ , ‘ABC’);
me>,…)
VALUES OR
(<val1>,<val2>,…);
INSERT INTO STUDENT
(ROLLNO,SNAME,SDOB,GUID)
VALUES (11, ‘MEENU’, ‘2005-10-
25’ , ‘ABC’);

OR

52 | P a g e
INSERT INTO STUDENT
(ROLLNO,SNAME,SDOB)
VALUES (20, ‘SHEENA’, ‘2009-10-
13’);

9. Select statement 1) To display all record To display all details of students.

Syntax: Example :
SELECT * FROM SELECT * FROM STUDENT;
tablename;
To display only ROLLNO and
2) To display selected SNAME from STUDENT table.
columns and all
rows SELECT ROLLNO, SNAME FROM
Syntax: STUDENT;
SELECT
<colname>,<colname
>.. FROM To display all details whose rollno
<tablename>; is less than 15.

3) To display selected SELECT * FROM STUDENT


rows and all WHERE ROLLNO<15;
columns
Syntax :
SELECT * FROM To display name of student whose
<tablename> roll no is 20.
WHERE <condition>;
SELECT SNAME FROM STUDENT
4) To display selected WHERE ROLLNO=20;
rows and selected
columns
Syntax :
SELECT
<colname>,<colname
>
FROM <tablename>
WHERE <condition>;
10. Column Aliases – Syntax: Example: Display names of all
renaming a column SELECT <COLNAME> employees along with their annual
AS “<new name>” salary (Salary*12). While
FROM <tablename>;
displaying query result, rename
EName as Name.

mysql> SELECT EName AS Name,


Salary*12 FROM EMPLOYEE;

53 | P a g e
Output:-

11. DISTINCT clause - Syntax : To display unique department


The SELECT SELECT DISTINCT number for all the employees.
statement when <COLNAME> FROM
<tablename>;
combined with mysql> SELECT DISTINCT DeptId
DISTINCT clause, FROM EMPLOYEE;
returns records
without repetition Output:-
(distinct records)

12. WHERE clause - The Syntax : To display distinct salaries of


WHERE clause is the employees working in the
used to retrieve data SELECT * FROM department number D01.
that meet some <tablename>
specified conditions WHERE <condition>; mysql> SELECT DISTINCT Salary
FROM EMPLOYEE WHERE
Deptid='D01';

Output:-

54 | P a g e
13. Membership Syntax:
Operator – IN SELECT * FROM
<tablename>
The IN operator WHERE <colname> IN
(<val1>,<val2>…);
compares a value
with a set of values
and returns true if
the value belongs to
that set.

14. ORDER BY clause – Syntax : Example :


used to display data
in an ordered SELECT <colname>… SELECT * FROM EMP
FROM <tablename>
(arranged) form with ORDER BY ORDER BY SALARY;
respect to a specified <colname>;
column. Output:-

By default displays
records in ascending
order

To display the records


in descending order,
the DESC keyword
written

The following query displays


details of all the employees in
descending order of their salaries.

mysql> SELECT * FROM


EMPLOYEE ORDER BY Salary
DESC;

Output:-

15. Handling NULL Syntax :  Displays details of all those


Values employees who have not been
SELECT * FROM given a bonus. This implies that the
55 | P a g e
<tablename> bonus column will be blank.
WHERE <colname> IS
NULL/ IS NOT NULL;
mysql> SELECT * FROM
EMPLOYEE WHERE Bonus IS NULL;

Output:-

 Displays names of all the


employees who have been given a
bonus. This implies that the bonus
column will not be blank.

mysql> SELECT EName FROM


EMPLOYEE WHERE Bonus IS NOT
NULL;

Output:-

16. Substring pattern • % (percent)— used  Displays details of all those


matching to represent zero, employees whose name starts with
one, or multiple 'K'.
characters
• _ (underscore)—
used to represent mysql> SELECT * FROM
a single char EMPLOYEE WHERE Ename LIKE
'K%';

56 | P a g e
 Displays details of all those
employees whose name ends with
'a'.

mysql> SELECT * -> FROM


EMPLOYEE -> WHERE Ename LIKE
'%a';

 Displays details of all those


employees whose name consists of
exactly 5 letters and starts with any
letter but has ‘ANYA’ after that.

mysql> SELECT * FROM


EMPLOYEE WHERE Ename LIKE
'_ANYA';

 Displays names of all the


employees containing 'se' as a
substring in name.

mysql> SELECT Ename FROM


EMPLOYEE WHERE Ename LIKE
'%se%';

 Displays names of all


employees containing 'a' as the
second character.

mysql> SELECT EName FROM


EMPLOYEE WHERE Ename LIKE
'_a%';
17. Data Updation – Syntax:  To update the name of
to make changes in UPDATE table_name student to ‘SANJAY’ whose Roll no
the value(s) of one or SET is 3 in table STUDENT.
attribute1 = value1,
more columns of attribute2 = value2,
existing records in a .. mysql> UPDATE STUDENT
table. WHERE condition; SET SNAME = ‘SANJAY’
WHERE RollNumber = 3;
18. Data Deletion - The Syntax:  To delete the details of
DELETE statement isDELETE FROM student whose Roll number is 2.
used to delete one or table_name WHERE
condition;
more record(s) from a mysql> DELETE FROM STUDENT
table WHERE RollNumber = 2;

57 | P a g e
SQL Joins:
 Process of accessing data from multiple tables is called Join in SQL
 JOIN operation combines tuples from two tables on specified
conditions. This is unlike cartesian product, which make all possible
combinations of tuples
 Example : List the Ucode, Uname, Ucolor, size and Price of related
tuples of table UNIFORM and COST.
(a) SELECT * FROM UNIFORM U, COST C where U.Ucode = C.Ucode;

(b) Explicit use of JOIN clause:

SELECT * FROM UNIFORM U JOIN COST C ON U.Ucode=C.Ucode;


c) Explicit use of NATURAL JOIN clause
SELECT * FROM UNIFORM NATURAL JOIN COST;
Following are some of the points to be considered while applying JOIN
operations on two or more relations:
• If two tables are to be joined on equality condition on the common
attribute, then one may use JOIN with ON clause or NATURAL JOIN in FROM
clause. If three tables are to be joined on equality condition, then two JOIN
or NATURAL JOIN are required.
• In general, N-1 joins are needed to combine N tables on equality condition.
• With JOIN clause, we may use any relational operators to combine tuples
of two tables.

Equi Join

 The SQL Equi join is a simple join clause where the relation is
established using equal to sign as the relational operator to mention
the condition.

58 | P a g e
 The join in which columns are compared for equality is called equi-join.
A non equi join specifies condition with non-equality operator. In equi-
join we put (*) in the select list will print common column twice in the
output.
Example :

Equi Join – Inner join is used to return the records which are having
matching values in both the tables
An Equi Join is a type of join that combines tables based on matching values
in the specified columns.
❖ The column names do not need to be the same.
❖ The resultant table can contain repeated columns.
❖ It is possible to perform an equi join on more than two
Equi Join- ❖ It performs a JOIN against equality or matching column(s)
values of the associated tables.
SELECT * /Column_list
FROM Table1, Table 2
WHERE table1.column=Table2.column;

Or

SELECT * /Column_list
FROM Table1 join Table2 on Table1.Column=Table2.Column;

59 | P a g e
Example: SELECT * FROM emp JOIN dept ON emp.deptno=dept.deptno;Or
SELECT * FROM emp, dept WHERE emp.deptno=dept.deptno;

Example 1: Display the employee name, sal and name of department name
Ans: In the above query ename and sal belong to emp table whereas
dname belongs
toDEPT table. So, to retrieve data in this we will use join
SELECT emp.ename, emp.sal, dept.dname
FROM emp, dept WHERE emp.deptno=dept.deptno;

Output:
++++
| ename | sal | dname |
++++
| SMITH | 800.00 | RESEARCH |
| ALLEN | 1600.00 | SALES |
| WARD | 1250.00 | SALES |
| JONES | 2975.00 | RESEARCH |
| MARTIN | 1250.00 | SALES |
| BLAKE | 2850.00 | SALES |
| CLARK | 2450.00 | ACCOUNTING |
| SCOTT | 3000.00 | RESEARCH |
| KING | 5000.00 | ACCOUNTING |
| TURNER | 1500.00 | SALES |
| ADAMS | 1100.00 | RESEARCH |
| JAMES | 950.00 | SALES |
| FORD | 3000.00 | RESEARCH |
| MILLER | 1300.00 | ACCOUNTING |

Note:

❖ In case of join full qualified (table_name.column_name) name is used to


avoid
ambiguity as both table contains common columns as PRIMARY KEY and
FOREIGN KEY.
❖ Table Alias – Like column alias table alias can be used in case of join as
given
below.
SELECT e.ename, e.sal FROM emp e, dept d WHERE
emp.deptno=dept.deptno;
❖ Here ‘e’ & ‘d’ are table alias for EMP & DEPT table respectively.

60 | P a g e
FUNCTION in MySQL

 Function:
A function is a predefined command set that performs some operation and
returns the single value. A function can have single, multiple or no arguments
at all.

 Types of SQL Functions:

1) Single Row Functions:


 Single row function in SQL can be character, numeric, date, and
conversion functions.
 These functions are used to modify data items. These functions need one
or more input and operate on each row, thereby returning one output
value for each row

2) Multiple row Functions (Aggregate Functions):


 The Multiple Row Functions in SQL are used to return either group of
values (or) a single value.
 These functions are basically operated on a set of rows and return one
result or one result per group.
 The Multiple row function in Oracle is also called group functions or it is
also called aggregate functions.

Single Row Functions:


There are three types of Single Row Functions in SQL
1) Character / String Functions
2) Numeric Functions
3) Date and Time Functions
1) Character / String Functions:
i. CONCAT()

61 | P a g e
ii. LOWER() / LCASE()
iii. UPPER()/UCASE()
iv. LTRIM()
v. TRIM()
vi. RTRIM()
vii. SUBSTR()/MID()
viii. INSTR(),
ix. LENGTH()
x. RIGHT()
xi. LEFT()

2) Numeric / Math Functions:


i. POWER(),
ii. ROUND(),
iii. MOD()

3) Date Functions:
i. SYSDATE()
ii. NOW()
iii. DATE()
iv. MONTH()
v. YEAR()
vi. DAYNAME()
vii. MONTHNAME()
viii. DAY()

Math Functions:
1.Pow(x,y )/power(x,y): Returns the value of X raised to the power
of Y.
Example:
(i)Select POW(2,4); Result:16

62 | P a g e
(ii)SELECT POW(2,-2; Result:0.25
(iii)SELECT POW(-2,3); Result: -8
(iv)SELECT id, salary, POWER(salary,2) FROM employee;
Result:
+----+----------+-----------------+
| id | salary | power(salary,2) |
+----+----------+-----------------+
| 1 | 25000.00 | 625000000 |
| 2 | 30000.00 | 900000000 |
| 3 | 32000.50 | 1024032000.25 |
| 4 | 37500.50 | 1406287500.25 |
| 5 | 42389.50 | 1796869710.25 |
+----+----------+-----------------+
2.ROUND(X): Rounds the argument to zero decimal place, whereas
ROUND(X, d) rounds X to d decimal places.
Example:
(i) ROUND(-1.23); Result: -1
(ii) ROUND(-1.68); Result: -2
(iii) ROUND(1.58); Result: 2
(iv) ROUND(3.798, 1); Result: 3.8
(v) ROUND(1.298, 0); Result: 1
(vi) ROUND(76823.298, -1); Result: 76820
(vii) ROUND( 25.298,-1); Result: 30
(viii) ROUND(3.798, 1); Result: 3.8
(ix) ROUND(4536.78965,-3) Result: 5000
(X) ROUND(4536.564553,-2): Result: 4500
(XI) ROUND(4586.564553,-2): Result: 4600
(XII)ROUND(76823.298, -2); Result:76800
XII)ROUND(76823.298, 2); Result: 76823.30
(XIII) ROUND(3.798, 2); Result: 3.80

63 | P a g e
3. MOD(x,y): Divides x by y and gives the remainder.
(i)SELECT MOD(12,5); Result: 2

CHARACTER / STRING FUNCTIONS


1. LENGTH(): Returns the length of a string in bytes/no. of characters in
string.
Example:
(i) SELECT LENGTH(‘#INFOR MATICS#’); Result:14
(ii)SELECT LENGTH(First_Name) FROM Employee;
Result:

+--------------------+
| LENGTH(First_Name) |
+--------------------+
|4|
|7|
|8|
|5|
|6|
+--------------------+
5 rows in set (0.00 sec)

2. INSTR(): Returns the index of the first occurrence of substring.


Example:
(i) SELECT INSTR(‘Informatics’,’ mat’);
Result: 6 (since ‘m’ of ‘mat’ is at 6th place)
(ii) SELECT INSTR ('Computers', 'pet');
Result: 0
(iii) mysql> SELECT INSTR (First_Name,'Kiran') FROM Employee;
Result:
+---------------------------+

64 | P a g e
| INSTR(First_Name,'Kiran') |
+---------------------------+
|0|
|0|
| 4 | Select instr(“good morning to all”,”or”)
|0|
|0|
+---------------------------+

(iv) Select instr(“good morning to all”,”or”) Result: 7

5. LOWER()/ LCASE(): Convert the string in lowercase.


Example:
SELECT LOWER(‘INFORMATICS’); Result: informatics

6. UPPER()/ UCASE(): Convert the string in uppercase.

Example:
SELECT UCASE(‘informatics’); Result: INFORMATICS

7.LEFT(): Returns the given number of characters by extracting them from


the left side of the given string
Example:
SELECT LEFT(‘INFORMATICS PRACTICES’, 3); Result: INF

8. RIGHT(): Returns the given number of characters by extracting them from


the right side of the given string
Example:
SELECT RIGHT(‘INFORMATICS PRACTICES’,3); Result: CES

65 | P a g e
9. MID()/ SUBSTR(): Returns a substring starting from the specified
position in a given string.
Example:
(i) SUBSTR(‘INFORMATICS PRACTICES’,3,4); Result: FORM
(ii) SELECT SUBSTRING('Informatics',3); Result:'formatics'
(iii) SELECT SUBSTRING('Computers', -3); Result: 'ers'
(iv) SELECT SUBSTRING('Computers', -5, 3); Result: 'ute'
(v) SELECT MID('Informatics',3,4); Result: 'form'
(vi) SELECT MID(first_name,3,2) FROM Employee;
Result:
+---------------------+
| MID(first_name,3,2) |
+---------------------+
| it |
| ek |
| vk |
| mt |
| aw |
+---------------------+
10. LTRIM(): Removes leading spaces.
Example:
SELECT LTRIM(' INFORMATICS '); Result: 'INFORMATICS’

11. RTRIM(): Removes trailing spaces.


Example:
SELECT RTRIM(‘ INFOR MATICS '); Result: ‘ INFOR MATICS’

12. TRIM(): Removes leading and trailing spaces.


Example:
SELECT TRIM(' $$INFOR MATICS$$ '); Result: ‘$$INFOR MATICS$$’

66 | P a g e
Date/Time Functions
1. NOW(): Returns the current date and time
Example:
select NOW(); Result: '2020-04-06 13:58:11'

3. DATE(): Extracts the date part of a date or datetime expression


Example:
SELECT DATE('2020-04-06 01:02:03'); Result: '2020-04-06'

3. MONTH(): Returns the month from the date passed as argument.


Example:
SELECT MONTH('2020-03-21'); Result:3

4. YEAR(): Returns the year.


Example:
SELECT YEAR('2020-03-21'); Result: 2020

5. DAYNAME(): Returns the name of the weekday.


Example:
SELECT DAYNAME('2010-07-21'); Result: WEDNESDAY
6. DAY(): Returns the day of the month
Example:
SELECT DAY(‘2022-07-14’); Result: 14
7. MONTHNAME(): Returns the name of the month
Example:
SELECT MONTHNAME(‘2022-07-14’); Result: July

Multiple Row Functions


(Aggregate Function)

67 | P a g e
 Aggregate functions summarize the results of a query and return a
single value calculated from values in a column instead of providing
the listing of all of the rows.
Syntax:
SELECT <FUNCION> (column_name) FROM <table_name>;
The following are aggregate functions:

1) SUM(): returns the total sum of a numeric column. It gives the


arithmetic sum of all the values present in a particular column. It can take
only one argument. NULL values are not included in the calculations.
Example: SELECT SUM(MARKS) FROM STUDENT;
It displays sum of all the marks in the table student

2) AVG(): returns the average value of any column or expression based on


a column. NULL value not included
Example: SELECT AVG(MARKS) FROM STUDENT;
It displays average of all the marks in the table student

3) MAX(): It returns the maximum value among the given set of values of
any column or expression based on column.
Example: SELECT MAX(MARKS) FROM STUDENT;
It displays maximum marks from the column marks of student table.

4) MIN(): It returns the minimum value among the given set of values of
any column or expression based on column.
Example: SELECT MIN (MARKS) FROM STUDENT;
It displays minimum marks from the column marks of student table.

5) COUNT(): It count the number of non-null values in a column. It can


take one argument, which can be a column name or *. When the argument
is a column name then COUNT() returns the non-null values in that column.

68 | P a g e
If the argument is an * then COUNT() counts the total number of records /
rows along with the NULL values satisfying the condition, if any, in the table.
So, it returns the total number of records or rows from the table.

Syntax: SELECT COUNT(COLUMN_NAME) FROM <TABLE_NAME>;


Example: SELECT COUNT(*) FROM STUDENT ;

It will give output as 10 rows.


But while writing SELECT COUNT(MARKS) FROM STUDENT;
Will give output as 7 because there will be 3 null values which is ignored by
COUNT()

SORTING IN SQL – ORDER BY

 The SQL ORDER BY clause is used to sort data in ascending or


descending order based on one or more columns.
 It sorts record in ascending order by default.
 To sort data in descending order DESC keyword is used.
Syntax:
SELECT <column_name> FROM <table_name>
[where <condition>]
ORDER BY <column_name> [ASC/DESC];
Example: To display the roll number, name and marks of students on
the basis of their marks in ascending order.

SELECT ROLLNO, NAME, MARKS FROM STUDENT


ORDER BY NAME;

Sorting data on Multiple columns:


Syntax:
SELECT <column_name> FROM <table_name>

69 | P a g e
[where <condition>]
ORDER BY <column_name> [ASC/DESC] , <column_name> [ASC/DESC];

Example: To display the roll number, name and marks of all the
students in descending order of their marks and ascending order of
their names.
SELECT ROLLNO, NAME , MARKS FROM STUDENT
ORDER BY MARKS DESC, NAME;

GROUP BY in SQL
 At times we need to fetch a group of rows on the basis of common
values in a column. This can be done using a GROUP BY clause.
 It groups the rows tog-ether that contain the same values in a
specified column. We can use the aggregate functions (COUNT, MAX,
MIN, AVG and SUM) to work on the grouped values.
 HAVING Clause in SQL is used to specify conditions on the rows with
GROUP BY clause.

Syntax:
SELECT <column1, column2…..> , aggregate function(colname)
FROM <tablename>
WHERE <condition>
GROUP BY <column1>
HAVING <condition>;

Consider the SALE table is given below.

70 | P a g e
(i) Write a query to display number of cars purchased by each
customer from the SALE Table.
mysql> SELECT CustID, COUNT(*) "Number of Cars" FROM SALE
GROUP BY CustID;

(ii) Write a query to display customer id and number of cars


purchased if the customer purchased more than one car
from the sale table.
mysql> SELECT CustID, COUNT(*) FROM SALE GROUP BY CustID
HAVING Count(*)>1;

(iii) Display number of people in each category of payment mode


from the table SALE.
mysql> SELECT PaymentMode, COUNT(PaymentMode) FROM SALE
GROUP BY Paymentmode ORDER BY Paymentmode;

71 | P a g e
(iv) Display the payment mode and number of payments made
using that mode more than once.
mysql> SELECT PaymentMode, Count(PaymentMode) FROM SALE
GROUP BY Paymentmode HAVING COUNT(*)>1 ORDER BY
Paymentmode;

TOPIC – SQL QUERIES USING HAVING AND


GROUP BY CLAUSE

1 Write down name of four functions that can be used with Group by?

Ans Count(), sum(), min(), max()

2. What is Group By clause?


Ans The GROUP BY Clause is utilized in SQL with the SELECT statement to
organize similar data into groups. It combines the multiple records in single or
more columns using some functions. Generally, these functions are aggregate
functions such as min (), max (), avg (), count (), and sum () to combine into
single or multiple columns.
3. Why we use Having clause?
Ans The HAVING clause was added to SQL because the WHERE keyword could
not be used with aggregate functions.
4. What is the purpose of Group By clause?
Ans Group by clause is used in a Select statement in conjunction with
aggregate functions to group the result based on distinct values in column.

72 | P a g e
5.You have a table “Company” having column cno, cname, department
and salary. Write SQL statement to display average salary of each
department.
Ans SELECT department, avg(salary) from company
Group by department;
6. Can a Group by clause be used for more than one column? If yes,
given an example.
Ans Yes.
Select name, grade, class
From student
Group by Class, grade
7. Anis has given the following command to arrange the data in
ascending order of date.
Select * from travel where order by tdate;
But he is not getting the desired result.
Help him by choosing the correct command.
a. Select * from travel order by tdate;
b. Select * from travel in ascending order;
c. Select tdate from travel order by tdate;
Ans. Select * from travel order by tdate;
8. Find the output of the following SQL queries:
i. SELECT ROUND(7658.345,2);  O/P – 7658.35
ii. SELECT MOD(ROUND(13.9,0),3);  o/p - 2
9. Give any two differences between POWER() and SUM().
Ans: POWER(x,y) – will return value x power to y
SUM() – Aggregate function, and returns sum of values of one column
10. Find the output of the following SQL queries:
i. SELECT SUBSTR(‘FIT INDIA MOVEMENT’,5);
 O/P – INDIA MOVEMEMNT
ii. SELECT INSTR(‘ARTIFICIAL INTELLIGENCE’, ‘IA’);
 O/P - 8

73 | P a g e
UNSOLVED QUESTIONS

1) Identify the errors in the following queries.


i. Select * from stock where price = NULL;
ii. Select sum[price] from stock;

2) Mr. Das has created the following table ‘Furniture’


F_id Type Price Qty Date_of_purchase

F12 Double Bed 40000 3 2020-08-19

F22 Sofa 35000 4 2021-11-23

F41 Dining Table 20000 2 2021-12-30


Write the output of the following queries:
i. Select * from Furniture where month(Date_of_purchase) = 8;
ii. Select F_id, Type from Furniture where year(Date_of_purchase) =
2021;
OR
Write the queries of the following:
i. Display the details of furniture which are purchased in month of
December.
ii. Display the average price of furniture.

3) Write the output of the following:


i. Select substr(“BoardExam@2021”, 4, 7);
ii. Select length(“BoardExam@2021”);
iii. Select left(upper(“BoardExam@2021”),5);
OR
Consider the table ‘School’ whose fields are shown below.
Admno, Class, Mobile, Fees, Name
Write the queries to perform the following task.
i. Display all names in uppercase.
ii. Display the last two characters from column Name.
iii. Display the lowest fees.

4) Identify the following functions:


i. I am a mathematical function and return the remainder.
ii. I am a string function and help to convert lower case string to upper
case.
iii. I am a date and time function, returns the month name from the
specified date.
5) Explain the following function with examples.
i. dayname( )

74 | P a g e
ii. instr( )
iii. now( )

5) Explain the difference between group by and order by clause with


example.
6) When we use having clause? Explain with example.
7) Write the SQL queries to do the following:
i. Add a new column “Name” of data type Varchar(30) in table “Hotel”.
ii. Delete a record from table “emp” whose empid is 101.
iii. Delete all the records of table “stock” along with structure.
iv. Display the total of column “Salary” from table “emp”.
v.
8) Based on the table: “Emp” given below:

Empid Salary

1 45000

2 50000

3 55000

4 40000

5 NULL
Write the output of the following:
i. Select mod(Salary, 100) from emp;
ii. Select average(Salary) from emp;
iii. Select sum(Salary) from emp where empid > 3;
iv. Select max(Salary) from emp;

9) Predict the output:


i. select substr(‘Informatics Practices’,12,5);
ii. select year(curdate()) + year(yourbirthdate);
10) Write your birthdate in the query then write the output.
i. select round(32.567890);
ii. select lower(‘pre-board I’);

11) Predict the output for following query:


i. select pow(month(now()),2);

75 | P a g e
ii. select left(dayname(now()),5)
iii. select length('Informatics Practice Class 12’);
OR
Explain the functions with suitable example to do this:
i. To find the position of specific word or character in the given text
ii. Display the total number characters from the text
iii. To display remainder of given two numbers
12) Vats is working with functions of MySQL. Explain him the following with
example:
i. To remove extra leading spaces from the text
ii. To return only day part from today’s date
iii. To return average of particular column from the table
13) Om has written following queries:
i. select count(*) from student;
ii. select count(std_no) from student;
He was surprised with the output as query (i) returns 5 rows whereas
Query(ii) returns only 3 rows. Explain why?
14) Which functions in MySQL extract words from specified character to n
number of character from given string. Write the function names and explain
them with example.
15) Anuj is student of class XII, trying to execute the following queries, help
him to predict the output.
i. select round (45.9,-2);
ii. select round ( -101.86,0)

76 | P a g e
INTRODUCTION TO COMPUTER NETWORK

Introduction to Networks:
A group of two or more similar things or people interconnected with each
other is called network

 Types of networks
o Social network
o Mobile network
o Network of computers
o Airlines, railway, banks, hospitals networks
 A computer network is an interconnection among two or more
computers or computing devices which allows computers to share data
and resources among each other.
 Apart from computers, networks include networking devices like switch,
router, modem, etc. Networking devices are used to connect multiple
computers in different settings.

Types of Networks

 various types of computer networks ranging from network of handheld


devices (like mobile phones or tablets) connected through Wi-Fi or
Bluetooth within a single room to the millions of computers spread
across the globe.
 computer networks are broadly categorised as:

• LAN (Local Area Network)


• MAN (Metropolitan Area Network)
• WAN (Wide Area Network)

 Local Area Network (LAN):


 It is a network that connects computers, mobile phones, tablet, mouse,
printer, etc., placed at a limited distance.

77 | P a g e
 The geographical area covered by a LAN
can range from a single room, a floor, an
office having one or more buildings in the
same premise, laboratory, a school,
college, or university campus
 Connected with wires, Ethernet cables,
fibre optics or Wi-Fi
 LANs provide the short-range communication with the high-speed data
transfer rates
 Can be extended up to 1 km
 Data transfer from 10 Mbps to 1000 Mbps (Mbps- Megabits per
Second)
 Metropolitan Area Network (MAN)
 Metropolitan Area Network (MAN) is an
extended form of LAN which covers a larger
geographical area like a city or a town.
 Data transfer rate is less than LAN
 E.g.: Cable TV Network, Cable based
broadband internet
 Can be extended up to 30-40 kms
 many LANs are connected together to form MAN

 Wide Area Network (WAN)


 connects computers and others LANs and MANs, which are spread
across different geographical locations of a country or in different
countries or continents
 The Internet is the largest WAN that connects billions of computers,
smartphones and millions of LANs from different continents.

78 | P a g e
x

 PAN (Personal Area Network): A PAN is a network of


local devices for personal network. A PAN can be set up using
guided media (USB cable) or unguided media (Bluetooth,
Infrared).

Network Devices:
To communicate data through different transmission media and to configure
networks with different functionality, we require different devices like Modem,
Hub, Switch, Repeater, Router, Gateway, etc.
Modem:

 stands for ‘MOdulator DEMolulator


 device used for conversion between analog signals and digital bits.
 modems connected to both the source and destination nodes

79 | P a g e
 The modem at the sender’s end acts as a modulator that converts the
digital data into analog signals. The modem at the receiver’s end acts
as a demodulator that converts the analog signals into digital data for
the destination node

Ethernet Card

 Also known as Network Interface Card (NIC card in short) is a network


adaptor used to set up a wired network.
 interface between computer and the network
 circuit board mounted on the motherboard of a
computer
 Ethernet cable connects the computer to the network
through NIC.
 Data transfer between 10Mbps to 1 Gbps
 Each NIC has a MAC address, which helps in uniquely identifying the
computer on the network.

Repeater

 Data are carried in the form of signals over the cable


 Signals lose their strength beyond 100 m limit and become weak.
 The weakened signal appearing on the cable is regenerated and put
back on the cable by a repeater

Hub

 An Ethernet hub is a network device used to connect different devices


through wires.
 Data arriving on any of the lines are sent out on all the others.

80 | P a g e
 The limitation of hub is that if data from two devices come at the same
time, they will collide

Types of Hub-

Passive Hub: This type of does not amplify or boost the


signal. Itdoes not manipulate or view the traffic that crosses it.
Active Hub: It amplifies the incoming signal before passing it to
the other ports.

Switch

 Like a hub, a network switch is used to connect multiple computers or


communicating devices.
 When data arrives, the switch extracts the destination address from
the data packet and looks it up in a table to see where to send the
packet. Thus, it sends signals to only selected devices instead of
sending to all.
 can forward multiple packets at the same time

Difference between Hub and Switch

1. The main difference between hub and switch is that hub replicates
what it receives on one port ontoall the other ports while switch
keeps a record of the MAC addresses of the devices attached to it and
forwards data packets onto the ports for which it is addressed across a
network, that’s why switch is intelligent Hub.
81 | P a g e
Router

 A network device that can receive the data, analyse it and transmit it
to other networks.
 Compared to a hub or a switch, a router has advanced capabilities as it
can analyse the data being carried over a network, decide or alter how
it is packaged, and send it to another network of a different type.
 A router can be wired or wireless.
 A wireless router can provide Wi-Fi access to smartphones and other
devices.
 Wi-Fi routers perform the dual task of a router and a modem/switch
 It connects to incoming broadband lines, from ISP (Internet Service
Provider), and converts them to digital data for computing devices to
process.

Gateway

 A gateway is a device that connects dissimilar networks


(Networks with different software and hardware configurations
and with different transmission protocol).
 Gateway serves as the entry and exit point of
a network, as all data coming in or going out
of a network must first pass through the
gateway in order to use routing paths.
 also maintain information about the host
network's internal connection paths and the identified paths of other
remote networks.

82 | P a g e
 it can be implemented as software, hardware, or a combination of both
because network gateway is placed at the edge of a network and the
firewall is usually integrated with it.

Network Topologies

 The arrangement of computers and other peripherals in a network is


called its topology. Some common topologies are as follows:

1 Mesh Topology

 each communicating device is connected with every other device in the


network
 can handle large amounts of traffic since multiple nodes can transmit
data simultaneously
 if any node gets down doesn’t affect other nodes
 secure than other topologies as each cable carries
different data

Disadvantages:

 wiring is complex and cabling cost is high in creating such networks


 there are many redundant or unutilised connections

2 Ring Topology

 each node is connected to two other devices, one


each on either side
 The link in a ring topology is unidirectional
 Failure of one node breaks down the network

3 Bus Topology

 each communicating device connects to a transmission medium,


known as bus

83 | P a g e
 data transmitted in both directions
 data can be received by any of
the nodes of network
 single backbone wire /bus
used to connect computers so
cheaper and easy to maintain
Disadvantages:
 less secure
 less reliable

4 Star Topology

 each communicating device is connected to a central node, which is a


networking device like a hub or a switch

Advantages:

 Easy to troubleshoot
 very effective, efficient and fast
 A single node failure does not affect the
entire network.
 Fault detection and removal of faulty parts is easier.
 In case a workstation fails, the network is not affected.

Disadvantages: -

 Difficult to expand. Longer cable is required.


 The cost of the hub and the longer cables makes it expensive
over others.
 In case hub fails, the entire network stop working.

84 | P a g e
5 Tree or Hybrid Topology

 It is a hierarchical topology, in which


there are multiple branches and each
branch can have one or more basic
topologies like star, ring and bus.

Features of Tree Topology

 Ideal if workstations are located in groups.


 Used in Wide Area Network.

Advantages of Tree Topology

 Extension of bus and star topologies.


 Expansion of nodes is possible and easy.
 Easily managed and maintained.

The Internet

 it is the global network of computing devices including desktop,


laptop, servers, tablets, mobile phones, other handheld devices as
well as peripheral devices such as printers, scanners, etc.
 also consists of networking devices such as routers, switches,
gateways, etc.

 The Internet provides a capability so powerful and general that it can


be used for almost any purpose that depends on information, and it
is accessible by every individual who connects to one of its associated
networks.
Applications of Internet:
Following are some of the broad areas or services provided through
Internet:
• The World Wide Web (WWW)

85 | P a g e
• Electronic mail (Email)
• Chat
• Voice Over Internet Protocol (VoIP)
1 The World Wide Web (WWW)

 It is an ocean of information, stored in the form of trillions of interlinked


web pages and web resources
 a British computer scientist invented the revolutionary World Wide Web
in 1990 by defining three fundamental technologies that lead to creation
of web:
 HTML — Hyper Text Markup Language
 language which is used to design standardised Web Pages so that
the Web contents can be read and understood from any computer
across the globe
 URI — Uniform Resource Identifier
 unique identifier to identify a resource located on the web

 URL: - URL stands for Uniform Resource Locator. A URL is


nothing more than the address of a given unique resource on the
Web or address of a website. The URL is an address that matches
users to a specific resource online, such as webpage.
 Example- http://www.cbse.nic.in

 HTTP — The Hyper Text Transfer Protocol


 set of rules which is used to retrieve linked web pages across
the web
 more secure and advanced version is HTTPS.

2 Electronic Mail (Email)

86 | P a g e
 It is one of the ways of sending and receiving message(s) using the
Internet.
 can be sent anytime to any number of recipients at anywhere
 To use email service, one needs to register with an email service
provider by creating a mail account. These services may be free or paid.
 Some of the popular email service providers are Google (Gmail), Yahoo
(yahoo mail), Microsoft (outlook), etc.

Application of Internet
Web 2.0:
The term web 2.0 is used to refer to a new generation of websites that
are supposed to let people to publish and share information online. It
aims to encourage the sharing of information and views, creativity that
can be consume by the other users. E.g.: YouTube

The Main characteristics of web 2.0 are:

 Makes web more interactive through online social media web- based
forums, communities, social networking sites.
 It is a website design and development world which aim to encourage
sharing of information and views, creativity and user interactivity
between the users.
 Video sharing possible in the websites

Web 3.0: It refers to the 3rd Generation of web where user will interact by
using artificial intelligence and with 3-D portals.
Web 3.0
keywords
supports andweb
semantic numbers.
which improves web technologies to create,
connect and share content through the intelligent search and the
analysis based on the meaning of the words, instead of on the

87 | P a g e
3 Chat

 Chatting or Instant Messaging (IM) over the Internet means


communicating to people at different geographic locations in real time
through text message(s).
 With ever increasing internet speed, it is now possible to send image,
document, audio, video as well through instant messengers. I
 Applications such as WhatsApp, Slack, Skype, Yahoo Messenger, Google
Talk, Facebook Messenger, Google Hangout, etc., are examples of
instant messengers.

4 VoIP

 Voice over Internet Protocol - allows us to have voice call (telephone


service) over the Internet
 VoIP works on the simple principle of converting the analogue voice
signals into digital and then transmitting them over the broadband line.
These services are either free or very economical
 VoIP call(s) can be received and made using IP phones from any place
having Internet access.

Advantage of VoIP:
 Save a lot of money.
 More than two people can communicate or speak.
 Supports great audio transfer.
 Provide conferencing facility.
 can transfer text, image, video along w ithvoice

Disadvantages of VoIP:

 Reliable Internet connection required.


 No location tracking for emergency calls.

88 | P a g e
7 Website

 A website in general contains information organized in multiple pages


about an organization.
 website can be created for a particular purpose, theme or to provide a
service
 collection of web pages related through hyperlinks, and saved on a web
server

1 Purpose of a Website

 to make the information available to people at large


 helps to communicate with people in a specific, transparent and user-
friendly manner
 common purposes for which websites are designed are listed below:
• Selling products and delivering services
• Posting and finding information on the internet
• Communicating with each other & Entertainment purposes
• Disseminating contents and software
8 Web Page

 A web page (also referred to as a page) is a document on the WWW that


is viewed in a web browser.
 structure of a web page is created using HTML (HyperText Markup
Language) and CSS (Cascaded Style Sheet).
 contain information in different forms, such as: text in the form of
paragraphs, lists, tables, images, audio, video, software application,
other interactive content
 The first page of the website is called a home page
 Static and Dynamic Web Pages
 A static webpage is one whose content always remains static, i.e., does
not change for person to person.

89 | P a g e
 Static web pages are generally written in HTML, JavaScript and/or CSS
and have the extension .htm or .html.
 a dynamic web page is one in which the content of the web page can be
different for different users.
 Dynamic web pages can be created using various languages such as
JavaScript, PHP, ASP.NET, Python, Java, Ruby, etc.
 Difference between Static and Dynamic webpage: -

Static Webpage Dynamic Webpage

The static web pages display the In the dynamic Web pages, thepage
same content each time when content changes according to the
someone visits it. user.

It takes less time to load over Dynamic web pages take more
internet. time while loading.

No Database used. A database is used in at the


server end in a dynamic web
page.

Changes rarely. Changes frequently.

 Difference between Website and Webpage: -

Website Webpage

1. A collection of web pages which A document which can be


are grouped together and displayed in a web browser suchas
usually connected together in Firefox, Google Chrome,
various ways, often called a "web Opera, Microsoft Internet Explorer
site" or etc.
simply a "site."

90 | P a g e
2. Has content about various Has content about single entity.
entity.

3. More development time is Less development time is


required. required.

4. Website address does not Webpage address depends on


depend on Webpage address. Website address.

9 Web Server

 Used to store and deliver the contents of a website to clients such as a


browser that request it. A web server can be software or hardware.
 The server needs to be connected to the Internet so that its contents
can be made accessible to others.
 The web browser from the client computer sends a request (HTTP
request) for a page containing the desired data or service. The web
server then accepts, interprets, searches and responds (HTTP response)
to the request made by the web browser.
 If the server is not able to locate the page, it sends the error message
(Error 404 – page not found) to the client’s browser.

 Web Hosting: -
 online service that enables user to publish website or web
application on the internet. When user sign up for a hosting
service, basically rent some space on a server on which user can
store all the files and data necessary for website to work properly.
 A server is a physical computer that runs without any interruption
so that website is available all the time for anyone who wants to
see it.
11 Browser:
 software application that helps us to view the web page(s).

91 | P a g e
 Helps to view different contents retrieved from different web servers
on the internet
 Mosaic was the first web
browser developed by the
National Centre for
Supercomputing Application
(NCSA).
 Mozilla Firefox is an open source
web browser which is available free of cost and can be easily
downloaded from the Internet.

 Browser Setting
 Every web browser has got certain settings that define the manner in
which the browser will behave. These settings may be with respect to
privacy, search engine preferences, download options, auto signature,
autofill and autocomplete feature, theme and much more.

2 Add-Ons and Plug-ins

 Add-ons and plug-ins are the tools that help to extend and modify the
functionality of the browser.
 Both the tools boost the performance of the browser, but are different
from each other.
 A plug-in is a complete program or may be a third-party software. For
example, Flash and Java are plug-ins. A Flash player is required to play
a video in the browser. A plug-in is a software that is installed on the
host computer and can be used by the browser for multiple
functionalities and can even be used by other applications as well.
 an add-on is not a complete program and so is used to add only a
particular functionality to the browser. An add-on is also referred to as
extension in some browsers

92 | P a g e
 Cookies
 A cookie is a text file, containing a string of information, which is
transferred by the website to the browser when we browse it.
 This string of information gets stored in the form of a text file in the
browser.
 The information stored is retransmitted to the server to recognize the
user, by identifying pages that were visited, choices that were made
while browsing various menu(s) on a particular website.
 It helps in customizing the information that will be displayed, for
example the choice of language for browsing, allowing the user to auto
login, remembering the shopping preference, displaying
advertisements of one’s interest, etc. Cookies are usually harmless and
they can’t access information from the hard disk of a user or transmit
virus or malware.

93 | P a g e
SOLVED QUESTIONS
NETWORKING (4 MARKS QUESTIONS)
1. Multipurpose Public School, Bengaluru is setting up the
network between its different wings of school campus. There are 4
wings named as: -

SENIOR(S), JUNIOR(J), ADMIN(A) and HOSTEL(H)

(i) Suggest the best wired medium and draw the cable layout to
efficiently connect various wings of Multipurpose Public School,
Bengaluru.
(ii) Name the most suitable wing where the servers should be installed.
Justify your answer.
(iii) Suggest a device/software and its placement that would provide data
security for the entire network of the school.
(iv) Suggest a device and a protocol that shall be needed to provide
wireless internet access to all smartphone/laptop users in the campus
of Multipurpose Public School, Bengaluru.

b
(i) Best wired medium: Optical fibre/CAT5/CAT6/CAT7/CAT8/Ethernet
Cable.
Layout:

94 | P a g e
(ii) Wing Senior (S)- Because it has maximum number of computers.
(iii) Firewall- Placed with the Server at SENIOR(S).
(iv) DEVICE NAME: WiFi Router/WiMax/Wireless modem
Protocol: WAP/TCP-IP/VoIP/MACP

2. Intelligent Hub India is a knowledge community aimed to uplift


the standard of skills and knowledge in the society. It is planning
to setup its training centres in multiple towns and villages pan
India with its head offices in the nearest cities. They have created
a model of their network with a city, a town and 3 villages as
given.
As a network consultant, you have to suggest the best network
related solution for their issues/problems raised
in (i) to (iv) keeping in mind the distance between various
locations and given parameters.

95 | P a g e
Note:
• In Villages, there are community centres, in which one room has been
given as training center to this organiza¬tion to install computers.
• The organization has got financial support from the government and top IT
companies.

1. Suggest the most appropriate location of the SERVER in the YHUB (out
of the 4 locations), to get the best and effective connectivity. Justify
your answer.
2. Suggest the best wired medium and draw the cable layout (location to
location) to efficiently connect vari¬ous locations within the YHUB.
96 | P a g e
3. Which hardware device will you suggest to connect all the computers
within each location of YHUB?
4. Which server/protocol will be most helpful to conduct live interaction of
Experts from Head office and people at YHUB locations?

Answers:
(i) YTOWN
Justification

1. Since it has the maximum number of computers.


2. It is closet to all other locations.
(ii) Optical Fiber

Layout:

(iii) Switch or Hub


(iv) Video conferencing or VoIP or any other correct service/protocol

3. Indian School, in Mumbai is starting up the network between its


different wings. There are four Buildings named as SENIOR, JUNIOR,
ADMIN and HOSTEL as shown below:

97 | P a g e
The distance between various buildings is as follows:

Number of Computers in Each Building:

1. Suggest the cable layout of connections between the buildings.


2. Suggest the most suitable place (i.e., building) to house the server of
this school, provide a suitable reason.
3. Suggest the placement of the following devices with justification.
o Repeater
o Hub/Switch
4. The organization also has inquiry office in another city about 50-60 km
away in hilly region. Suggest the suitable transmission media to
interconnect to school and inquiry office out of the following:
o Fiber optic cable
o Microwave
o Radiowave

98 | P a g e
Answers:
1.

2. Server can be placed in the ADMIN building as it has the maximum


number of computers.
3. Repeater can be placed between ADMIN
and SENIOR building as the distance is more than 110 m.
4. Radiowaves can be used in hilly regions as they can travel through
obstacles.

4) Vidya Senior Secondary Public School in Nainital is setting up the


network between its different wings. There are 4 wings named as
SENIOR(S), JUNIOR(J), ADMIN(A) and HOSTEL(H).
Distance between various wings are given below:

99 | P a g e
1. Suggest a suitable Topology for networking the computers of all wings.
2. Name the most suitable wing where the Server should be installed.
Justify your answer.
3. Suggest where all should Hub(s)/Switch(es) be placed in the network.
4. Which communication medium would you suggest to connect this
school with its main branch in Delhi?
Answers:

1.
2. Server should be in Wing S as it has the maxi-mum number of
computers. 1
3. All Wings need hub/switch as it has more than
one computer.
4. Since the distance is more, wireless transmission would be better.
Radiowaves are reliable and can travel through obstacles.

5) Trine Tech Corporation (TTC) is a professional consultancy


company. The company is planning to set up their new offices in India
with its hub at Hyderabad. As a network adviser, you have to
understand their requirement and suggest them the best available
solutions. Their queries are mentioned as (i) to (iv) below.
Physical Locations of the blocked of TTC

100 | P a g e
1. What will be the most appropriate block, where TTC should plan to
install their server?
2. Draw a block to cable layout to connect all the buildings in the most
appropriate manner for efficient communication.
3. What will be the best possible connectivity out of the following, you will
suggest to connect the new setup of offices in Bangalore with its
London based office:
o Satellite Link
o Infrared
o Ethernet Cable
4. Which of the following device will be suggested by you to connect each
computer in each of the buildings:
o Switch
o Modem
o Gateway
o

101 | P a g e
Answers:
1. Finance block because it has maximum
number of computers.

2. Satellite link
3. Switch

6) G.R.K International Inc. is planning to connect its Bengaluru Office


Setup with its Head Office in Delhi. The Bengaluru Office G.R.K.
international Inc. is spread across and area of approx. 1 square
kilometer, consisting of 3 blocks – Human Resources, Academics and
Administration.
You as a network expert have to suggest answers to the four queries
(i) to (iv) raised by them.
Notes: Keep the distance between blocks and number of computers in
each block in mind, while providing them the solutions.

102 | P a g e
1. Suggest the most suitable block in the Bengaluru Office Setup, to host
the server.
Give a suitable reason with your suggestion.
2. Suggest the cable layout among the various blocks within the
Bengaluru Office Setup for
connecting the Blocks.
3. Suggest a suitable networking device to be installed in each of the
blocks essentially required for connecting computers inside the blocks
with fast and efficient connectivity.
4. Suggest the most suitable media to provide secure, fast and reliable
data connectivity between Delhi Head Office and the Bengaluru Office
Setup.

103 | P a g e
Answers:
1. Human Resources because it has maximum number of computers.

2. Switch 1
3. Satellite link

7) Rovenza Communications International (RCI) is an online


corporate training provider company for IT related courses. The
company is setting up their new campus in Kolkata. You as a network
expert have to study the physical locations of various blocks and the
number of computers to be installed. In the planning phase, provide
the best possible answers for the queries (i) to (iv) raised by them.

104 | P a g e
Block to Block Distances (in Mtrs.)

Expected computers to be installed in each block

1. Suggest the most appropriate block, where RCI should plan to install
the server.
2. Suggest the most appropriate block to block cable layout to connect all
three blocks for efficient communication.
3. Which type of network out of the following is formed by connecting the
computers of these three blocks?
o LAN
o MAN
o WAN
4. Which wireless channel out of the following should be opted by RCI to
connect to students from all over the world?
o Infrared
o Microwave
o Satellite

105 | P a g e
Answers:
1. Faculty Recording Block.
2. Star topology
3. LAN
4. Satellite connection

8) To provide telemedicine faculty in a hilly state, a computer network


is to be setup to connect hospitals in 6 small villages (VI, V2, …, V6)
to the base hospital (H) in the state capital. This is shown in the
following diagram.

106 | P a g e
No village is more than 20 km away from the state capital.
Imagine yourself as a computer consultant for this project and answer the
following questions with justification:

1. Out of the following what kind of link should be provided to setup this
network: Microwave link, Radio Link, Wired Link?
2. What kind of network will be formed; LAN, MAN, or WAN?
3. Many times, doctors at village hospital will have to consult senior
doctors at the base hospital. For this purpose, how should they contact
them: using email, SMS, telephone, or video conference?
Answers:
1. Radio Link
2. MAN
3. e-mail

9) Workalot Consultants are setting up a secured network for their


office campus at Gurgaon for their day-to-day office and web-based
activities. They are planning to have connectivity between three
buildings and the head office situated in Mumbai. Answer the
questions (i) to (iv) after going through the building positions in the
campus and other details, which are given below:

107 | P a g e
1. Suggest the most suitable place (i.e., building) to house the server of
this organization. Also give a reason to justify your suggested location.
2. Suggest a cable layout of connections between the buildings inside the
campus.
3. Suggest the placement of the following devices with justification:
o Repeater.
o Switch.
4. The organization is planning to provide a high-speed link with its head
office situated in Mumbai using a wired connection. Which of the
following cables will be most suitable for this job?
o Optical Fiber
o Co-axial Cable
o Ethernet Cable
Answer:
108 | P a g e
1. The most suitable place to install server is building “RED” because this
building has maximum computer which reduce communication delay.

2. (a) Since the cabling distance between buildings GREEN, BLUE and RED
are quite large, so a repeater each, would ideally be need along their
path to avoid loss of signals during the course of data flow in their
routes.

109 | P a g e
(b) In the layout a switch each, would be needed in all the buildings, to
interconnect the group of cables from the different computers in each
building.

(iv) Optical fiber

110 | P a g e
10) Granuda Consultants are setting up a secured network for their
office campus at Faridabad for their day to day office and web-based
activities. They are planning to have connectivity between 3 building
and the head office situated in Kolkata. Answer the questions (i) to
(iv) after going through the building positions in the campus and
other details, which are given below:

111 | P a g e
1. Suggest the most suitable place (i.e., block) to house the server of this
organization. Also give a reason to justify your suggested location.
2. Suggest a cable layout of connections between the buildings inside the
campus.
3. Suggest the placement of the following devices with justification:
o Repeater
o Switch
4. The organization is planning to provide a high-speed link with its head
office situated in the KOLKATA using a wired connection. Which of the
following cable will be most suitable for this job?
o Optical Fibre
o Co-axial Cable
o Ethernet Cable
Answer:
1. The most suitable place to install server is building “JAMUNA” because
this building has maximum computer which reduce the communication
delay.
2. Cable layout. (Bus topology).

112 | P a g e
3. (a) Since the cabling distance between buildings GANGA and JAMUNA
are quite large, so a repeater each, would ideally be needed along their
path to avoid loss of signals during the course of data flow in these
routes.

(b) In the layout a switch each would be needed in all the building, to
interconnect the group of cables from the different computers in
each building.

4. Optical fiber

11) Mudra publishing is a group of companies engaged in publishing IT related


books located in the hilly area of Shimla. The companies are located in four
different, blocks whose layout is shown in the following figure. Answer the
questions (i) to (iv) with the relevant justify-cations.

Mudra publishing

113 | P a g e
Distance between various Blocks:

1. Block A to Block C is 50 m
2. Block A to Block D is 100 m
3. Block B to Block C is 40 m
4. Block B to Block D is 70 m
5. Block C to Block D is 125 m
Number of Computers
6. Block A is 25
7. Block B is 50
8. Block C is 20
9. Block D is 120

1. Suggest a suitable network topology between the blocks.


2. Which is the most suitable block to house the server of this
organization?
3. Suggest the placement of the following devices with justification
o Repeater
o Switch

114 | P a g e
4. The organization is planning to link the whole blocks to its marketing
Office in Delhi. Since cable connection is not possible from Shimla,
suggest a way to connect it with high speed.

Answer:

1. Suitable topology is bus topology.


2. The most suitable block for hosting server is BLOCK-D because this
block has maximum number of computers.
Mudra Publishing

3. Switch is a device used to segment network into different sub-networks


so switch will exist in all the blocks. Since distance between BLOCK-D
and BLOCK-C is large so repeater will be install between BLOCK-D and
BLOCK-C.
4. The most economical way to connect it with a reasonable high speed
would be the use radio wave transmission, as they are easy to install,
can travel long distance and penetrate buildings easily, so they are used
for communication, both indoors and outdoors. Radio waves also have
the advantage of being Omni-directional. They can travel in all the
directions from the source, so that the transmitter and receiver do not
have to be carefully aligned physically.

115 | P a g e
4 Marks Unsolved Questions
[ CASE STUDY]

1) Laxmi Marketing Ltd. has four branches in its campus named


Udaipur, Kota, Jodhpur and Ajmer. Laxmi Marketing Ltd. wants
to establish the networking between all the four offices.

Approximate distances between these offices as per network survey team


are as follows:

City No. of
Computers

116 | P a g e
In continuation of the above, the company experts have planned to install the
following number of computers in each of their offices:
i. Suggest the most suitable place (i.e., Block/Center) to install the server of
this organization with a suitable reason.
ii. Suggest an ideal layout for connecting these blocks/centers for a wired
connectivity.
iii. Which device will you suggest to be placed/installed in each of these offices
to efficiently connect all the computers within these offices?
iv. Suggest the placement of a Repeater in the network with justification.
v. The organization is planning to connect its new office in Delhi, which is more
than 1250 km current location. Which type of network out of LAN, MAN, or
WAN will be formed? Justify your answer.

2. ABC CONSULTANTS is a professional consultancy company. The


company is planning to set up new offices in India with its hub at
Gurugram. As a network adviser, you have to understand their
requirements and suggest to them the best available solutions.

117 | P a g e
(a) What will be the most appropriate block where organization should plan to
install their server?
(b) Draw a block-to-block cable layout to connect all the buildings in the most
appropriate manner for efficient communication.
(c) Which of the following devices will you suggest to connect each computer
in each of the above buildings?
(i) Gateway
(ii) Switch
(iii) Modem
(d) Write names of any two popular web browsers.

3. MyPace University is setting up its academic blocks at Naya Raipur


and is planning to set up a network. The University has 3 academic
blocks and one Human Resource Center as shown in the diagram
below:

118 | P a g e
Center to Center distances between various blocks/center is as follows

a) Suggest the most suitable place (i.e., Block/Center) to install the server of
this University with a suitable reason.
b) Suggest an ideal layout for connecting these blocks/centers for a wired
connectivity.

119 | P a g e
c) Which device will you suggest to be placed/installed in each of these
blocks/centers to efficiently connect all the computers within these
blocks/centers.
d) Suggest the placement of a Repeater in the network with justification.
e) The university is planning to connect its admission office in Delhi, which is
more than 1250km from university.
Which type of network out of LAN, MAN, or WAN will be formed? Justify your
answer.

4) Zigma is a knowledge and skill community which has an aim to


uplift the standard of knowledge and skills in the society. It is
planning to set-up its training centers in multiple towns and villages
in India with its head offices in the nearest cities. They have created
a model of their network with a city, a town and 3 villages as follows.
As a network consultant, you have to suggest the best network
related solutions for their issues/problems raised in (i) to (v) keeping
in mind the distances between various locations and other given
parameters.

120 | P a g e
5)Quick Learn University is setting up its academic blocks at Prayag
Nagar and planning to set up a network. The university has 3
academic blocks and one human resource Centre as shown in the
diagram given below:

121 | P a g e
(a) Suggest a cable layout of connection between the blocks.
(b) Suggest the most suitable place to house the server of the organization
with suitable reason.
(c) Which device should be placed/installed in each of these blocks to
efficiently connect all the computers within these blocks?

122 | P a g e
(d) The university is planning to link its sales counters situated in various parts
of the other cities. Which type of network out of LAN, MAN or WAN will be
formed?
(e) Which network topology may be preferred in each of these blocks?

6) Rehaana Medicos Center has set up its new center in Dubai. It has
four buildings as shown in the diagram given below:

123 | P a g e
As a network expert, provide the best possible answer for the following
queries:

i) Suggest a cable layout of connections between the buildings.


ii) Suggest the most suitable place (i.e. buildings) to house the server
of this organization.
iii) Suggest the placement of the following device with justification: a)
Repeater b) Hub/Switch

7) “VidyaDaan” an NGO is planning to setup its new campus at


Nagpur for its web-based activities. The campus has four (04) UNITS
as shown below:

124 | P a g e
(i) Suggest an ideal cable layout for connecting the above UNITs.
(ii) Suggest the most suitable place i.e. UNIT to install the server for the above
NGO.
(iii) Which network device is used to connect the computers in all UNITs?
(iv) Suggest the placement of Repeater in the UNITs of above network.

8) “China Middleton Fashion” is planning to expand their network in


India, starting with two cities in India to provide infrastructure for
distribution of their product. The company has planned to set up their
main office units in Chennai at three locations and have named their
offices as “Production Unit”, “Finance Unit” and “Media Unit”. The
company has its corporate unit in New Delhi. A rough layout of the
same is as follows: INDIA

125 | P a g e
i) Suggest the kind of network required (out of LAN, MAN, WAN) for
connecting each of the following office units:
a. Production Unit and Media Unit
b. Production Unit and Finance Unit
ii) Which of the following devices will you suggest for connecting all the
computers within each of their office units?

126 | P a g e
*Switch/Hub *Modem *Telephone
iii) Suggest a cable layout for connecting the company’s local office units in
Chennai.
iv) Suggest the most suitable place to house the server for the organization
with suitable reason.

9)Rehaana Medicos Center has set up its new center in Dubai. It has
four buildings as shown in the diagram given below:

127 | P a g e
As a network expert, provide the best possible answer for the following
queries:
i) Suggest a cable layout of connections between the buildings.
ii) Suggest the most suitable place (i.e. buildings) to house the server of
this organization.
iii) Suggest the placement of the Repeater device with justification.

iv) Suggest the placement of the Hub/ Switch with justification.

10) PVS Computers decided to open a new office at Ernakulum,


the office consist of Five Buildings and each contains number of
computers. The details are shown below.

128 | P a g e
Computers in each building are networked but buildings are not networked
so far. The Company has now decided to connect building also.
(i) Suggest a cable layout for connecting the buildings
(ii) Do you think anywhere Repeaters required in the campus? Why
(iii) Where server is to be installed? Why?

11) Intelligent Hub India is a knowledge community aimed to uplift


the standard of skills and knowledge in the society. It is planning
to setup its training centres in multiple towns and villages of India
with its head offices in the nearest cities. They have created a
model of their network with a city, a town and 3 villages as given.
As a network consultant, you have to suggest the best network
related solution for their issues/problems raised in (i) to (v)
keeping in mind the distance between various locations and given
parameters.

129 | P a g e
130 | P a g e
Note:
* In Villages, there are community centres, in which one room has been given
as training center to this organization to install computers.
* The organization has got financial support from the government and top IT
companies.
1. Suggest the most appropriate location of the SERVER in the YHUB (out of
the 4 locations), to get the best and effective connectivity. Justify your
answer.
2. Suggest the best cable layout (location to location) to efficiently connect
various locations within the YHUB.
3. Which hardware device will you suggest to connect all the computers within
each location of YHUB?

131 | P a g e
ABBREVIATIONS RELATED TO COMPUTER NETWORK
1 NIU Network Interface Unit

2 MAC Media Access Control

3 TCP/IP Transmission Control Protocol/Internet Protocol

4 PAN Personal Area Network

5 LAN Local Area Network

6 MAN Metropolitan Area Network

7 WAN Wide Area Network

8 UTP Unshielded Twisted Pair

9 STP Shielded Twisted Pair

10 Mbps Megabits per sec

11 EMI Electro Magnetic Interference

12 RJ Registered Jack

13 Wi-Fi Wireless Fidelity

14 VPN Virtual Private Network

15 IAAS Infrastructure as A Service

16 PAAS Platform as A Service

17 SAAS Software as A Service

18 DAAS Desktop as A Service

19 IOT Internet Of Things

20 NIC Network Interface Card


Carrier Sense Multiple Access/Collision
21 CSMA/CD
Detection
Carrier Sense Multiple Access/Collision
22 CSMA/CA
Avoidance
23 DNS Domain Name System

24 DHCP Dynamic Host Configuration Protocol

25 ISP Internet Service Provider

26 URL Uniform Resource Locator

132 | P a g e
27 HTTP Hyper Text Transfer Protocol

28 FTP File Transfer Protocol

29 FDMA Frequency Division Multiple Access

30 TDMA Time division Multiple Access

31 CDMA Code Division Multiple Access

32 SIM Subscriber Identity Module

33 EDGE Enhanced Data rates for GSM Evolution

34 UMTS Universal Mobile Telecommunications System

35 LTE Long Term Evolution

36 GPRS General Packet Radio Service

37 ICMP Internet Control Message Protocol

38 OSI Open Systems Interconnection

39 SMTP Simple Mail Transfer Protocol

40 VoIP Voice Over Internet Protocol

41 SIP Session Initiation Protocol

42 QoS Quality of Service

43 POP Post Office Protocol

44 IMAP Internet Mail Access Protocol

45 SCP Secure Copy Protocol

46 SSH Secure Shell

47 IEEE Institute of Electrical & Electronic Engineering

48 NFC Near-Field Communication

49 NFS Network File System

50 NTP Network Time Protocol

51 SLIP Serial Line Internet Protocol

52 PPP Point to Point Protocol

53 UDP User Datagram Protocol

54 SNMP Simple Network Management Protocol

133 | P a g e
SOCIETAL IMPACTS

Societal Impacts

In the past few decades there has been a revolution in computing and
communications, and all indications are that technological progress and use
of information technology will continue at a rapid pace. Accompanying and
supporting the dramatic increases in the power and use of new information
technologies has been the declining cost of communications as a result of both
technological improvements and increased competition. According to Moore’s
law the processing power of microchips is doubling every 18 months. These
advances present many significant opportunities but also pose major
challenges. Today, innovations in information technology are having wide-
ranging effects across numerous domains of society, and policy makers are
acting on issues involving economic productivity, intellectual property rights,
privacy protection, and affordability of and access to information. Choices
made now will have long lasting consequences, and attention must be paid to
their social and economic impacts. One of the most significant outcomes of
the progress of information technology is probably electronic commerce over
the Internet, a new way of conducting business. Though only a few years old,
it may radically alter economic activities and the social environment. Already,
it affects such large sectors as communications, finance and retail trade and
might expand to areas such as education and health services. It implies the
seamless application of information and communication technology along the
entire value chain of a business that is conducted electronically. The following
sections will focus on the impacts of information technology and electronic
commerce on business models, commerce, market structure, workplace, labor
market, education, private life and society as a whole.

Digital Footprint

A digital footprint is data that is left behind when users have been online.
There are two types of digital footprints which are passive and active.
A passive footprint is made when information is collected from the user
without the person knowing this is happening.
An active digital footprint is where the user has deliberately shared
information about themselves either by using social media sites or by using
websites.
An example of a passive digital footprint would be where a user has been
online and information has been stored on an online database. This can include
where they came from, when the footprint was created and a user IP address.
A footprint can also be analyzed offline and can be stored in files which an
administrator can access. These would include information on what that
machine might have been used for, but not who had performed the actions.

134 | P a g e
An example of an active digital footprint is where a user might have logged
into a site when editing or making comments such as on an online forum or a
social media site. The registered name or profile can be linked to the posts
that have been made and it is surprisingly easy to find out a lot about a person
from the trails you leave behind.

Net and Communication Etiquettes

1. Be respectful.
2. Be aware of how your comments might be read:
3. Be careful with humor and sarcasm
4. Think about who can see what you have shared.
5. Remember to check friend requests and group invites before accepting
them.
6. Take time to have a read of the rules of conduct/ community standards.
7. Be forgiving.

Data Protection

Data protection is a set of strategies and processes you can use to secure the
privacy, availability, and integrity of your data. It is sometimes also called
data security or information privacy. A data protection strategy is vital for any
organization that collects, handles, or stores sensitive data.

Data Protection vs Data Privacy

Although both data protection and privacy are important and the two often
come together, these terms do not represent the same thing.
One addresses policies, the other mechanisms
Data privacy is focused on defining who has access to data while data
protection focuses on applying those restrictions. Data privacy defines the
policies that data protection tools and processes employ.
Creating data privacy guidelines does not ensure that unauthorized users don’t
have access. Likewise, you can restrict access with data protections while still
leaving sensitive data vulnerable. Both are needed to ensure that data
remains secure.
Another important distinction between privacy and protection is who is
typically in control. For privacy, users can often control how much of their data
is shared and with whom. For protection, it is up to the companies handling
data to ensure that it remains private. Compliance regulations reflect this
difference and are created to help ensure that users’ privacy requests are
enacted by companies.

135 | P a g e
Data Protection Technologies and Practices that Can Help You Protect
User Data
When it comes to protecting your data, there are many storage and
management options you can choose from. Solutions can help you restrict
access, monitor activity, and respond to threats. Here are some of the most
commonly used practices and technologies:

1. Data loss prevention (DLP)—a set of strategies and tools that you can use
to prevent data from being stolen, lost, or accidentally deleted. Data loss
prevention solutions often include several tools to protect against and recover
from data loss.

2. Storage with built-in data protection—modern storage equipment provides


built-in disk clustering and redundancy. For example, Cloudian’s Hyperstore
provides up to 14 nines of durability, low cost enabling storage of large
volumes of data, and fast access for minimal RTO / RPO.

3. Firewalls—utilities that enable you to monitor and filter network traffic. You
can use firewalls to ensure that only authorized users are allowed to access or
transfer data.

4. Authentication and authorization—controls that help you verify credentials


and assure that user privileges are applied correctly. These measures are
typically used as part of an identity and access management (IAM) solution
and in combination with role-based access controls (RBAC).

5. Encryption—alters data content according to an algorithm that can only be


reversed with the right encryption key. Encryption protects your data from
unauthorized access even if data is stolen by making it unreadable. Learn
more in our article: Data Encryption: An Introduction.

6. Endpoint protection—protects gateways to your network, including ports,


routers, and connected devices. Endpoint protection software typically enables
you to monitor your network perimeter and to filter traffic as needed.

7. Data erasure—limits liability by deleting data that is no longer needed. This


can be done after data is processed and analyzed or periodically when data is
no longer relevant. Erasing unnecessary data is a requirement of many
compliance regulations, such as GDPR. For more information about GDPR,
check out our guide: GDPR Data Protection.

136 | P a g e
Intellectual Property Rights

Property

The word property is generally used to mean a possession or, more


specifically, something to which the owner has legal rights.

Intellectual Property

It refers to creations of the intellect used in commerce:


 Inventions
 Literary and Artistic work
 Symbols
 Names Images and designs

It is a property which is scientific, innovatory invention created by a person or


group of persons using their own intellect for ultimate use in commerce and
which is already not available in the public domain.

Following are examples of intellectual property: -


These are an invention relating to a product or any process, a new design, a
literary or artistic work and a trademark (a word, a symbol and /or a logo
etc.),
Intellectual property (IP) is a term referring to a brand, invention, design or
other kind of creation, which a person or business has legal rights over. Almost
all businesses own some form of IP, which could be a business asset.
Common types of IP include:
Copyright – this protects written or published works such as books, songs,
films, web content and artistic works;
Patents – this protects commercial inventions, for example, a new business
product or process;
Designs – this protects designs, such as drawings or computer models;
Trademarks – this protects signs, symbols, logos, words or sounds that
distinguish your products and services from those of your competitors. IP can
be either registered or unregistered.

It is intellectual property rights is privileges of ownership of any and all rights


associated with intangible assets owned by a person or company and
protected against use without consent or license amount paid. All proprietary,
shareware nag ware software and branded computer hardware are
categorized under IPR.

These are certain rights or privileges granted for the owner ship of scholarly,
intelligent, knowledgeable logical work is referred as Proprietary when it
becomes Copyrighted or Registered.

137 | P a g e
Proprietary is synonyms for Trademarked, Branded, Patented or private
operated usually for commercial purposes.
 Antonym of proprietary is Generic.
 Work like registered Domain names, Industrial designs, confidential
information, Inventions, Program and Database rights and literacy
works of authorship or recorded performances in physical or abstract
forms.

Patents may refer to permission granted to privilege the exclusive legal


ownership of the work as mentioned above.

Copyright laws protect intellectual property

Copyright

It is a legal concept, enacted by most governments giving creator of original


work exclusive rights to it, usually for a limited period.

Plagiarism

It is stealing someone’s intellectual work and representing it as your own work


without citing the source of information.
Copying someone’s work and then passing it off as one’s own
 Act of stealing
 Copying information and not giving the author credit for it
 Copying programs written by other programmers and claiming them as
your own
 Involves lying, cheating, theft and dishonesty

138 | P a g e
It is presenting someone else's work in form of words, views, ideas, images,
sounds or the creative expression and performance as your own work in
following ways: -
i. Whether it is an idea or either published or unpublished material;
ii. Whether in hard copy manuscript, design or softcopy or electronic form;

Measure to avoid Plagiarism?


 Plagiarism is a bad practice and should be avoided by the following
measures:
 Use your own words and ideas.
 Always provide reference or give credit to the source from where you
have received your information.
 You must give credit whenever you use
 Another person’s idea, opinion, or theory.
 Quotations of another person’s actual spoken or written words
 Paraphrase of another person’s spoken or written words.

Licensing:

Software Licensing is the legal right to run or the privilege gives to you by a
company to access their application or program or software.

For example: When we purchase for proprietary software such as Windows


OS, then we must have noticed that it comes with a license agreement which
is to be read first and to be agreed upon for the successful installation and
usage of the software.

License agreements typically allow the software to run on a limited


number of computers and allow copies to be made only for backup
purpose.
Licenses provide rules and guidelines for others to use your work.

Advantages of using Licensed software

1. By using licensed software, you are able to contribute to the further


development of the program you are using.
2. It comes with the outright support not found in “pirated” software.

Free and open-source software

Free and open-source software (FOSS) is software that can be classified as


both free software and open-source software. That is, anyone is freely licensed

139 | P a g e
to use, copy, study, and change the software in any way, and the source code
is openly shared so that people are encouraged to voluntarily improve the
design of the software. This is in contrast to proprietary software, where the
software is under restrictive copyright licensing and the source code is usually
hidden from the users.

Free software

Free Software Foundation (FSF), defines free software as a matter of


liberty not price, and it upholds the Four Essential Freedoms.

Four essential freedoms of Free Software

 The freedom to run the program as you wish, for any purpose (freedom
0).
 The freedom to study how the program works and change it so it does
your computing as you wish (freedom 1). Access to the source code is
a precondition for this.
 The freedom to redistribute copies so you can help others (freedom 2).
 The freedom to distribute copies of your modified versions to others
(freedom 3). By doing this you can give the whole community a chance
to benefit from your changes. Access to the source code is a precondition
for this.

Open Source Software

Open-source software is computer software that is released under a license in


which the copyright holder grants users the rights to use, study, change, and
distribute the software and its source code to anyone and for any purpose.
Open-source software may be developed in a collaborative public manner.

Cyber Crime:

Cybercrime or computer- oriented crime is a crime that includes a computer


and a network. The computer may have been used in the execution of a crime
or it may be the target. It is the use of a computer as a weapon for committing
crimes such as committing fraud, identity theft or breaching privacy. It
especially through the Internet, has grown in importance as the computer has
become central to every field like commerce, entertainment and government.
It may endanger a person or a nation’s security and financial health.
Criminal activities or offences carried out in a digital environment can be
considered as cybercrime. In such crimes, either the computer itself is the
target or the computer is used as a tool to commit a crime. Cybercrimes are
carried out against either an individual, or a group, or an organization or even
against a country, with the intent to directly or indirectly cause physical harm,
financial loss or mental harassment. A cybercriminal attacks a computer or a

140 | P a g e
network to reach other computers in order to disable or damage data or
services.
Apart from this, a cybercriminal may spread viruses and other malwares in
order to steal private and confidential data for blackmailing and extortion. A
computer virus is some lines of malicious code that can copy itself and can
have detrimental effect on the computers, by destroying data or corrupting
the system. Similarly, malware is a software designed to specifically gain
unauthorized access to computer systems. The nature of criminal activities
are alarmingly increasing day-by-day, with frequent reports of hacking,
ransomware attacks, denial-of-service, phishing, email fraud, banking fraud
and identity theft.

Cybercrime encloses a wide range of activities but these can generally be


divided in to two categories:
 Crimes that aim at computer networks or devices. These types of
crimes
involves different threats (like virus, bugs etc.) and denial-of-service(DoS)
attacks.
 Crimes that use computer networks to commit other criminal activities.
These types of crimes include cyber stalking, financial fraud or identity
theft.

Classification of Cyber Crime:


1. Cyber Terrorism:
Cyber terrorism is the use of the computer and internet to perform violent
acts that result in loss of life. This may include different type of activities either
by software or hardware for threatening life of citizens.
In general, Cyber terrorism can be defined as an act of terrorism committed
through the use of cyberspace or computer resources.
2. Cyber Extortion:
Cyber extortion occurs when a website, e-mail server or computer system is
subjected to or threatened with repeated denial of service or other attacks
by
malicious hackers. These hackers demand huge money in return for
assurance to
stop the attacks and to offer protection.
3. Cyber Warfare:
Cyber warfare is the use or targeting in a battle space or warfare context of
computers, online control systems and networks. It involves both offensive
and
defensive operations, threat of cyber-attacks, espionage and sabotage.
4. Internet Fraud:
Internet fraud is a type of fraud or deceit which makes use of the Internet and
could include hiding of information or providing incorrect information for the
purpose of deceiving victims for money or property. Internet fraud is not

141 | P a g e
considered a single, distinctive crime but covers a range of illegal and illicit
actions that are committed in cyberspace.
5. Cyber Stalking:
This is a kind of online harassment wherein the victim is subjected to a barrage
of
online messages and emails. In this case, these stalkers know their victims
and
instead of offline stalking, they use the Internet to stalk. However, if they
notice that cyber stalking is not having the desired effect, they begin offline
stalking along with cyber stalking to make the victims’ lives more miserable.

Prevention of Cyber Crime:


Below are some points by means of which we can prevent cybercrime:

1. Use strong password:


Maintain different password and username combinations for each account and
resist the temptation to write them down. Weak passwords can be easily
cracked using certain attacking methods like Brute force attack, Rainbow table
attack etc.
.
2. Use trusted antivirus in devices:
Always use trustworthy and highly advanced antivirus software in mobile and
personal computers. This leads to the prevention of different virus attack on
devices.
3. Keep social media private:
Always keep your social media accounts data privacy only to your friends. Also
make sure only to make friend who are known to you.
4. Keep your device software updated:
Whenever you get the updates of the system software, update it at the same
time
because sometimes the previous version can be easily attacked.

Hacking:

Hacking is the act of unauthorized access to a computer, computer network


or any digital system. Hackers usually have technical expertise of the
hardware and software.
They look for bugs to exploit and break into the system. Hacking, when done
with a positive intent, is called ethical hacking. Such ethical hackers are known
as white hat hackers. They are specialists in exploring any vulnerability or
loophole by during testing of the software. Thus, they help in improving the
security of a software. An ethical hacker may exploit a website in order to
discover its security loopholes or vulnerabilities. He then reports his findings

142 | P a g e
to the website owner. Thus, ethical hacking is actually preparing the owner
against any cyber-attack.

Phishing and Fraud Emails:

Phishing is an unlawful activity where fake websites or emails that look original
or authentic are presented to the user to fraudulently collect sensitive and
personal details, particularly usernames, passwords, banking and credit card
details. The most common phishing method is through email spoofing where
a fake or forged email address is used and the user presumes it to be from an
authentic source. So, you might get an email from an address that looks
similar to your bank or educational institution, asking for your information.

Cyber Bullying
Any insulting, degrading or intimidating online behaviour like repeated posting
of rumors, giving threats online, posting the victim’s personal information,
sexual harassment or comments aimed to publicly ridicule a victim is termed
as cyber bullying. It implies repeatedly targeting someone with intentions to
hurt or embarrass. We need to realize that bullying online can have very
serious implications on the other person (victim).

Identity Theft:

Identity thieves increasingly use personal information stolen from computers


or computer networks, to commit fraud by using the data gained unlawfully.
A user’s identifiable personal data like demographic details, email ID, banking
credentials, passport, PAN, Aadhaar number and various such personal data
are stolen and misused by the hacker on behalf of the victim. This is one type
of phishing attack where the intention is largely for monetary gain.

Indian Information Technology Act (IT Act):

With the growth of Internet, many cases of cybercrimes, frauds, cyber-attacks


and cyber bullying are reported. The nature of fraudulent activities and crimes
keeps changing. To deal with such menaces, many countries have come up
with legal measures for protection of sensitive personal data and to safeguard
the rights of Internet users. The Government of India’s The Information
Technology Act, 2000 (also known as IT Act), amended in 2008, provides
guidelines to the user on the processing, storage and transmission of sensitive
information.
In many Indian states, there are cyber cells in police stations where one can
report any cybercrime. The act provides legal framework for electronic
governance by giving recognition to electronic records and digital signatures.
The act outlines cybercrimes and penalties for them.
Cyber Appellate Tribunal has been established to resolve disputes arising from
cybercrime, such as tampering with computer source documents, hacking the

143 | P a g e
computer system, using password of another person, publishing sensitive
personal data of others without their consent, etc. The act is needed so that
people can perform transactions over the Internet through credit cards
without fear of misuse.

E-Waste: Hazards and Management

E-waste broadly covers waste from all electronic and electrical appliances and
comprises of items such as computers, mobile phones, digital music
recorders/players, refrigerators, washing machines, televisions (TVs) and
many other household consumer items.

E-Waste Hazards

 Mostly all electronic waste comprises of toxic chemicals such as lead,


beryllium, mercury etc.
 Improper disposing of gadgets and devices increases the amount of
these toxic chemicals thus contaminated the soil, causing air and
water pollution.
 The contaminated water which is highly polluted it thus making it
harmful for drinking purposes.
 Improper e-waste recycling, such as by open burning and acid baths
creates hazardous and toxic compounds like- dioxins, furans and acids.
 Damage to the immune system
 Skin disease.
 Multi ailments.
 Skin problems

E-Waste Management

E-waste management requires proper recycling and recovery of the disposed


material. The recycling and recovery process includes following steps-

1. Dismantling: - removal of parts containing valuable items such as- copper,


silver, gold, steel and removal of parts containing dangerous substance like-
mercury, lead, Beryllium etc.

2. Separation metal and plastic

3. Refurbishment and reuse: it means used electrical and electronic items


that can be easily remodel to make it’s to reuse.

4. Recovery of valuable materials

5. Disposal of dangerous materials like- mercury, lead, Beryllium etc. and


disposed off in underground landfill sites.

144 | P a g e
Awareness about health concerns related to the use of Technology

Today, computer technologies provide people with many benefits, educational


activities can be designed, online shopping is available, it is possible to get in
touch with people overseas and to chat with them. It is possible to search for
anything and sometimes. It is even possible to do one’s job at home without
going to his or her office. If these technologies, which dominate our lives more
each passing day, are not used carefully. Then it is inevitable for people
to end up with certain illnesses like-

1. Neck strain

2. Vision Problem

3. Sense of isolation

4. Sleeping disorder

5. Stress

6. Loss of attention

7. Problem in social relationships of individuals.

8. Computer anxiety

9. Internet addiction etc.

In order to avoid these problems-

 One should learn how to use these technologies without experiencing


any problem rather than avoiding using them.
 Some of the users of computer technologies are not even aware of
their health-related problems that they have.

Case Based MCQs on Societal Impacts

Q1. Aniruddha is studying the concepts of digital footprints. Help


him to clarify the concepts of digital footprints.
(i) Digital footprints are also known as _____________
a. Digital data c. Digital tattoos
b. Plagiarism d. Digital print

(ii) Digital footprints are stored ______________


a. Temporarily (for few days) c. for 7 days only

b. Permanently d. for 3 days

145 | P a g e
(iii) Whenever we surf the Internet using smartphones we leave a trail of
data reflecting the activities performed by us online, which is our
___________
a. Digital footprint c. Online handprint
b. Digital activities d. Internet activities

(iv) There are _________ kinds of Digital footprints.


a. 1 c. 3
b. 2 d. 4

(v) Which is the correct type(s) of digital footprint?


a. Active digital footprint c. Both a and b
b. passive digital footprint d. None

Q2. Shobhit is eager to know the best way to behave on internet. Help him
to know the concepts of net and communication etiquettes.

(i) Digital communication includes ________


a. Email c. Instant messaging
b. Texting d. All of the above

(ii) _______ is a person who deliberately sows discord on the Internet by


starting quarrels or upsetting people, by posting inflammatory or off topic
messages in an online community.
a. Netizen c. Internet troll
b. Digital Citizen d. None of the above

(iii) Online posting of rumors, giving threats online, posting the victim’s
personal information, comments aimed to publicly ridicule a victim is termed
as __________
a. Cyber bullying c. Cyber insult
b. Cybercrime d. All of the above

(iv) Being a responsible digital citizen, we should ______


a. not use copyrighted materials c. respect privacy of others
b. avoids cyber bullying d. All of the above

(v) Which of the following is Net Etiquette?


a. Be Ethical c. Be Responsible
b. Be Respectful d. All of the above

146 | P a g e
Q.3 Namita has recently shifted to new city and new school. She does not
know many people in her new city and school. But all of a student, someone
is posting negative, demeaning comments on her social networking profile,
school site’s forum etc.
She is also getting repeated mails from unknown people. Every time she goes
online, she finds someone chasing her online.
a) What is this happening to Namita?
i. Namita has become a victim of cyber bullying and cyber stalking.
ii. Eaves dropping
iii. Scam
iv. Violation of IPR

b) What action should be taken by her to stop them?


i. Discuss with Parents
ii. Discuss in peer group
iii. Hide and get herself emotionally hurt
iv. She must immediately bring it to the notice of her parents and
school authorities. And she must report this cybercrime to local police with
the help of her parents.

c) The act of fraudulently acquiring someone’s personal and private


information, such as online account names, login information and passwords
is called as __________.
i. Phishing iii. Identity Theft
ii. Fraud iv. Plagiarism

d) Namita needs to protect her personal information or data from


unintentional and intentional attacks and disclosure which is termed as
____________.

i.Digital right iii. Privacy


ii. Copyright iv. Intellectual property

e) A set of moral principles that governs the behaviour of a group or


individual and regulates the use of computers.

i.Copyright ii. Computer ethics


iii.Property rights iv. Privacy law

147 | P a g e
Very Short Answer Type Questions (1 mark)
1. In which year the Indian IT Act, 2000 got updated?
2. What is data privacy?
3. Which of the following is not a type of cyber-crime?
a) Data theft c) Damage to data and systems
b) Forgery d) Installing antivirus for protection

Answer: d
Explanation: Cyber-crimes is one of the most threatening terms that is an
evolving phase. It is said that major percentage of the World War III will be
based on cyber-attacks by cyber armies of different countries.

4. Cyber-laws are incorporated for punishing all criminals only.


a) True
b) False
Answer: b
Explanation: Cyber-laws were incorporated in our law book not only to
punish cyber criminals but to reduce cyber-crimes and tie the hands of
citizens from doing illicit digital acts that harm or damage other’s digital
property or identity.

5. Cyber-crime can be categorized into types.


a) 4 c) 2
b) 3 d) 6

Answer:c
Explanation: Cyber-crime can be categorized into 2 types. These are peer-
to-peer attack and computer as weapon. In peer-to-peer attack, attackers
target the victim users; and in computer as weapon attack technique,
computers are used by attackers for a mass attack such as illegal and
banned photo leak, IPR violation, pornography, cyber terrorism etc.

6. In which year the Indian IT Act, 2000 got updated?


a)2006 c)2010
b)2008 d)2012

Answer: b
Explanation: In the year 2008, the IT Act, 2000 was updated and came up
with a much broader and precise law on different computer-related crimes
and cyber offenses.

148 | P a g e
MLL BASED QUESTIONS (Short Answer Type Questions-2 MARKS)

1. What is identity theft? How can we prevent identity theft?


2. Define e- waste. What are the various methods for effective e- waste
management?
3. What do you mean by plagiarism? Tell 2 acts which can be termed as
plagiarism.
4. What do you mean by Digital property rights? Explain.
5. State any 2 measures of digital property rights protection.
6. Differentiate between shareware and proprietary software.
7. What is cyber-crime? Explain “information theft”.
8. Give any 2 benefits of ICT on today’s society?
9. State 2 benefits of e-waste recycling?
10. Differentiate between Free Software and Open-source software.

Long Answer Type Questions :( 3/4 Marks)

1. Sumit got good marks in all the subjects. His father gifted him a laptop. He
would like to make Sumit aware of health hazards associated with
inappropriate and excessive use of laptop. Help his father to list the points
which he should discuss with Sumit.

2. What do you mean by Cyber Crime, explain its types and write the
measures to avoid it?

3. What are the social and cultural changes induced by technology?

4. What is the problem of internet addiction? How to overcome it?

5. Give any 2 benefits of ICT on today’s society?

6. According to a survey, one of the major Asian country generates


approximately about 2 million tonnes of electronic waste per year. Only 1.5
% of the total e-waste gets recycled. Suggest a method to manage e-waste

7. What do you understand by Net Etiquettes? Explain any two such


etiquettes.
8. Priyanka is using her internet connection to book a flight ticket. This is a
classic example of leaving a trail of web activities carried by her. What do we
call this type of activity? What is the risk involved by such kind of activity?
And will find an add-on and the man on the bay of the need for ease within a
layer of the mentality of anonymity that is moving in and year.

149 | P a g e
Practical List
1. Write a python program to create a series to print scalar value
“5” five times.

2. Write a python program to create a series object house using a


dictionary that stores the number of students in each house of
CLASS 12B of your school.

Note: Assume four house names are Raman, Shivaji, Ashok and Tagor
having 34, 42, 29, 58 students respectively.

3. Write a python program to create a series object comp using a


list that stores the number of quantity of computer item in lab
of your school.
Note: Assume four computer item names as index are KB, Mouse,
computer and printer having values are 30, 25, 20, 2 items
respectively

4. Write a python program to create a Series to store total 6 name


of students as key along with Percentage as value using
dictionary and print all the elements that are above 75
percentage.

5. Write a python program to perform following mathematical


Operations on Two Series objects: (i) Addition (ii) Subtraction
(iii) Multiplication (iv) Division.
S1 S2

6. Write python program to create series and


display various attributes of the Series.

7. Write a Python code to create a DataFrame stock with


appropriate column headings from the list given below:
[[101,'Gurman',98], [102,'Rajveer',95], [103,'Samar' ,96],
[104,'Yuvraj',88]]

8. Write a Python code to create a DataFrame ‘Stock’ by using


dictionary method:
Name Price
0 Nancy Drew 150
150 | P a g e
1 Hardy boys 180
2 Diary of a wimpy kid 225
3 Harry Potter 500

9. Write a Python code to create a DataFrame with appropriate


column headings from the csv file given below:
city Maxtemp Mintemp Rainfall
0 Delhi 40 32 24.1
1 Bengaluru 31 25 36.2
2 Chennai 35 27 40.8
3 Mumbai 29 21 35.2

10. Write a Python code to create a DataFrame ‘lib’ by using Series


method:
Pcd title Price qty
0 P01 Notebook 85 500
1 P02 Pencilbox 76 200
2 P03 WaterBottle 129 50
3 P04 SchoolBag 730 70

11. Consider the given DataFrame:


Pcd title Price qty
0 P01 Notebook 85 500
1 P02 Pencilbox 76 200
2 P03 WaterBottle 129 50
3 P04 SchoolBag 730 70
Write suitable Python statements for the following:
i. Add a column called ACC_NO with the following data:
[135,153,225,442].
ii. Add a new Record
iii. Remove the column qty.
iv. Remove first and third rows from DataFrame

12. Consider the following dataframe: student_df


Name CLASS marks
Anamay XI 95
Aditi XI 82
Mehak XI 65

151 | P a g e
Kriti XI 45
1. Write a statement to get the minimum value of the column marks.
2. Write a statement to get the maximum value of the column marks.
3. Write a statement to get the sum value of the column marks.
4. write a statement to get the average value of the column marks.
5. Write a statement to get Transpose of DataFrame student_df
6. Write a statement to get the sorted value of the column marks.
7. Write a statement to get the sorted value of the column name ascending.
8. Write a statement to get the sorted value of the column name descending.
9. Write a statement to get the sort index of DataFrame
10. Write a statement to get the sorted column index of DataFrame.
11. Write a statement to get top 3 rows and bottom 2 rows from dataframe

13. Write the code in pandas to create the following DataFrames:


df1 df2
mark1 mark2 mark1 mark2
0 10 15 0 30 20
1 40 45 1 20 25
2 15 30 2 20 30
3 40 70 4 40 10
5 10 50 3 50 30
Write the commands to do the following operations on the DataFrames given
above:
1.To add DataFrames df1 and df2.
2.To add 10 values into df1 DataFrame
3.To add 5 values into mark1 columns of DataFrame
4.To subtract df2 from df1
5.To rename column mark1 as m1 in df2.
6.To change index label of df1 from 0 to zero and from 1 to one
7.To rename column mark1 as m1, mark2 as m2 and row 0 to 00 and 1 to 01
of df2 DataFrame
8 To change the column heading of df1 to m11 for mark1 and m12 for
mark2
152 | P a g e
14. AIM: Plot the following data using a line plot:

 Before displaying the plot display “Monday, Tuesday, Wednesday,


Thursday, Friday, Saturday, Sunday” in place of Day 1, 2, 3, 4, 5, 6, 7
 Change the color of the line to ‘Magenta’.

15.Collect the minimum and maximum temperature of your city for a


month and present it using a histogram plot.

16. Write a program to create a horizontal bar chart for India's medal
tally.

Country Gold Silver Bronze Total

Australia 80 59 59 198

England 45 45 46 136

India 26 20 20 66

Canada 15 40 27 82

153 | P a g e
17. Manisha has created following table named exam:

Help her in writing SQL queries to the perform the following task:
i. Insert a new record in the table having following values:
[6,'Khushi','CS',85]
ii. To change the value “IP” to “Informatics Practices” in subject column.
iii. To remove the records of those students whose marks are less than 30.
iv. To add a new column Grade of suitable datatype.
v. To display records of “Informatics Practices” subject.
18. Rasha creates a table STOCK to maintain computer stock in
vidyalaya. After creation of the table, she has entered data of 8 items
in the table.
Table : STOCK

Based on the data given above answer the following questions:


i. Identify the most appropriate column, which can be considered as Primary
ii. Add a column STATUS in the table with datatype as char with 1 characters

154 | P a g e
iii. If three columns are added and 5 rows are deleted from the table stock, what will be
the new degree and cardinality of the above table?
iv. Write the query to Insert the following record into the table
Stockid - 201, dateofpurchase – 18-OCT-2022, name – neckphone
Make – BoAT, price – 500.
v. Decrease the price of stock by 5% whose were purchased in year 2020.
vi. Delete the record of stock which were purchased before year 2015.
key.

19. Write suitable SQL queries for the following:


i. To calculate the exponent for 3 raised to the power of 4.
ii. To display current date and time.
iii. To round off the value -34.4567 to 2 decimal place.
iv. To remove all the probable leading and trailing spaces from the
column userid of the table named user.
v. To display the length of the string ‘FIFA World Cup’
20. AIM: Freya Perform the following operations in MySQL using SQL
command
i.Create a table emp with attributes empno, ename, salary
ii. Add following columns using alter table command
Age
City
MobileNo
iii. Add primary key to the above table.
iv. Change the data type size of salary column.
v. Remove the column 'City' and ‘MobileNo’ from the above table.
vi. Show the structure of table emp.
21. Create a student table with the student id, name and marks as
attributes where the student id is the primary key.

155 | P a g e
22. Insert the details of 5 students in the above table
23. Delete the details of a student in the above table whose marks are
less than 40.
24. Use the select command to get the details of the students with
marks more than 80.
25. Find the min, max, sum and average of the marks in a student
marks table.
26. Find the total number of customers from each country in the
table(customer id, customer name, country) using group by.
27. Write a SQL query to order the (student id, marks) table in
aescending order of the marks.

156 | P a g e

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy