Ip Study Material
Ip Study Material
Informatics Practices(065)
Class XII
2022-2023
CHIEF PATRON
Mr R Senthil Kumar
Deputy Commissioner
PATRON
IN-CHARGE
K V CRPF PALLIPURAM
1 Mrs. AMBILY KRISHNAN CO-ORDINATOR
5
“Success is no accident. It is hard work,
perseverance, learning, studying, sacrifice
and most of all, love of what you are doing
or learning to do.”
6
INDEX
Sl. No TOPIC PAGE
No:
1 Data Handling Using Pandas 8
Series 14
Data Frames 24
2 Importing/Exporting CSV Files 47
3 Visualisation 54
4 Database – SQL 71
5 Computer Networking 90
6 Societal Impacts 113
7 Sample Question Papers 129
SQP 1 130
SQP 2 143
SQP 3 157
SQP 4 (CBSE) 170
8. Other References 185
7
Index
UNIT 1
Data Handling Using Pandas
Python module- A python module is a python script file(.py file) containing
variables, python classes, functions, statements etc.
Python Library/package- A Python library is a collection of modules that together cater
to a specific type of need or application. The advantage of using libraries is that we can
directly use functions/methods for performing specific type of application instead of rewriting
the code for that particular use. They are used by using the import command as-
import libraryname
at the top of the python code/script file.
Some examples of Python Libraries-
1. Python standard library-It is a collection of library which is normally distributed
along with Python installation. Some of them are-
a. math module- provides mathematical functions
b. random module- provides functions for generating pseudo-random numbers.
c. statistics module- provides statistical functions
2. Numpy (Numerical Python) library- It provides functions for working with large
multi-dimensional arrays(ndarrays) and matrices. NumPy provides a large set of
mathematical functions that can operate quickly on the entries of the ndarray
without the need of loops.
3. Pandas (PANel + DAta) library- Pandas is a fast, powerful, flexible and easy to use
open source data analysis and manipulation tool. Pandas is built on top of NumPy,
relying on ndarrayand its fast and efficient array based mathematical functions.
4. Matplotlib library- It provides functions for plotting and drawing graphs.
Data Structure- Data structure is the arrangement of data in such a way that
permits efficient access and modification.
Pandas Data Structures- Pandas offers the following data structures-
a) Series - 1D array
b) DataFrame - 2D array
Series- Series is a one-dimensional array with homogeneous data.
Index/Label
0 1 2 3 4
abc def ghi Jkl mno 1D Data values
Key features of Series-
8
A Series has only one dimension, i.e. one axis
Each element of the Series can be associated with an index/label that can be used
to access the data value. By default the index starts with 0,1,2,3… but it can be set
to any other data type also.
Series is data mutable i.e. the data values can be changed in-place in memory
Series is size immutable i.e. once a series object is created in memory with a fixed
number of elements, then the number of elements cannot be changed in place.
Although the series object can be assigned a different set of values it will refer to a
different location in memory.
All the elements of the Series are homogenous data i.e. their data type is the same. For
example.
0 1 2 3 4
223 367 456 339 927
all data is of int type
a b c de fg
1 def 10.5 Jkl True
Creating a Series- A series object can be created by calling the Series() method in the
following ways-
a) Create an empty Series- A Series object not containing any elements is an
empty Series. It can be created as follows-
import pandas as pd
s1=pd.Series() print(s1)
o/p-
Series([], dtype: float64)
b) Create a series from array without index- A numpy 1D array can be used
to create a Series object as shown below. The default index is 0, 1, 2, …
9
c) Create a series from array with index- The default index for a Series
object can be changed and specified by the programmer by using the index
parameter and enclosing the index in square brackets. The number of elements of
the array must match the number of index specified otherwise python gives an
error.
#Creating a Series object using numpy array and specifying index
import pandas as pd
import numpy as np
a1=np.array(['hello', 'world', 'good', 'morning'])
s1=pd.Series(a1, index=[101, 111, 121, 131])
print(s1)
o/p-
101 hello
111 world
121 good
131 morning
dtype: object
o/p-
101 hello
111 world
121 good
131 morning
dtype: object
10
If the index argument contains a key not present in the dictionary then a
value of NaN is assigned to that particular index.
The order in which the index arguments are specified determines the order
of the elements in the Series object.
#5 Creating a Series object from dictionary reordering
the index
import pandas as pd
o/p-
131 morning
111 world
121 good
199 NaN
dtype: object
Create a Series from a scalar value- A Series object can be created from a single value
i.e. a scalar value and that scalar value can be repeated many times by specifying the index
arguments that many number of times.
#6 Creating a Series object from scalar value
import pandas as pd
o/p-
101 7
111 7
121 7
dtype: int64
a) Create a Series from a List- A Series object can be created from a list as shown
below.
o/p-
0 abc
1 def ghi
2 jkl
3
dtype: object
11
b) Create a Series from a Numpy Array (using various array creation methods) -
A Series object can be created from a numpy array as shown below. All the
methods of numpy array creation can be used to create a Series object.
#7a Creating a Series object from list
import pandas as pd
import numpy as np
#e. Create an array of 10 elements which are linearly spaced between 1 and 10
(both inclusive)
a5=np.linspace(1,10,4)
s5=pd.Series(a5) print('s5=', s5)
#f. Create an array containing each of the characters of the word ‘helloworld’
a6=np.fromiter('helloworld', dtype='U1')
s6=pd.Series(a6) print('s6=', s6)
o/p:
s1= 0 2.0
1 4.0
2 7.0
3 10.0
4 13.5
5 20.4
dtype: float64
12
s2= 101 0.0
102 0.0
103 0.0
104 0.0
105 0.0
106 0.0
107 0.0
108 0.0
109 0.0
110 0.0
dtype: float64
s3= 0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
dtype: float64
s4= 0 1.1
1 1.2
2 1.3
3 1.4
4 1.5
5 1.6
6 1.7
dtype: float64
s5= 01.0
1 4.0
2 2 7.0
3 3 10.0
dtype: float64
s6= 0 h
1 e
2 l
3 l
4 o
5 w
6 o
7 r
8 l
9 d
dtype: object
13
Index
SERIES : Operations on Series objects-
1. Accessing elements of a Series object
The elements of a series object can be accessed using different methods as shown below-
a) Using the indexing operator []
The square brackets [] can be used to access a data value stored in a
Series object. The index of the element must be entered within the square
brackets. If the index is a string then the index must be written in quotes. If
the index is a number then the index must be written without the quotes.
Attempting to use an index which does not exist leads to error.
o/p- world
morning
L=[101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 201, 211]
s=pd.Series(L)
x=s.head()
print('x=\n', x)
y=s.head(3)
print('y=\n', y)
o/p:
x=
0 101
1 111
2 121
3 131
4 141
dtype: int64 y=
0 101
1 111
2 121
dtype: int64
L=[101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 201, 211]
s=pd.Series(L)
x=s.tail()
15
print('x=\n', x)
y=s.tail(3)
print('y=\n', y)
o/p: y=
x= 9 191
7 171 10 201
8 181 11 211
9 191 dtype: int64
10 201
11 211
dtype: int64
o/p:
102
Using multiple labels- We can pass multiple labels in any order that is present in the
Series object. The multiple labels must be passed as a list i.e. the multiple labels must be
separated by commas and enclosed in double square brackets. Passing a label is passed
that is not present in the Series object, should be avoided as it right now gives NaN as the
value but in future will be considered as an error by Python.
# 17 indexing a Series object
multiple labels import pandas as pd
o/p:
b 102
a 101
f 106
dtype: int64
ii) Using slice notation startlabel:endlabel- Inside the index operator we can pass
startlabel:endlabel. Here contrary to the slice concept all the items from startlabel
values till the endlabel values including the endlabel values is returned back.
# 18 indexing a Series object using startlabel:endlabel
import pandas as pd
o/p:
b 102
c 103
d 104
e 105
dtype: int64
17
forward
indexing---> 0 1 2 3 4 5
a b c d e f
101 111 121 131 141 151
<-----backward
-6 -5 -4 -3 -2 -1 indexing
Slice concept-
The basic concept of slicing using integer index positions are common to Python object
such as strings, list, tuples, Series, Dataframe etc. Slice creates a new object using
elements of an existing object. It is created as: ExistingObjectName[start : stop : step]
where start, stop , step are integers
18
QUESTION AND ANSWER SECTION
1 What will be the output of following code-
import pandas as pd
s1=pd.Series([1,2,2,7,’Sachin’,77.5])
print(s1.head())
print(s1.head(3))
Ans:
0 1
1 2
2 2
3 7
4 Sachin
dtype: object
0 1
1 2
2 2
dtype: object
Ans:
S=pd.Series([5,10,15,20,25],index=['a','b','c','d','e'])
19
5 Write the output of the following code :
import pandas as pd
S1 = pd.Series([31, 28, 31, 30, 31], index = ["Jan", "Feb", "Mar", "Apr", "May"])
print("-----------")
print(S1[1:3])
print("-----------")
print(S1[:5])
print("-----------")
print(S1[3:3])
print("-----------")
print(S1["Jan":"May"])
Ans.
-----------
Feb 28
Mar 31
dtype: int64
-----------
Jan 31
Feb 28
Mar 31
Apr 30
May 31
dtype: int64
-----------
Series([ ], dtype: int64)
-----------
Jan 31
Feb 28
Mar 31
Apr 30
May 31
dtype: int64
6 Differentiate between Pandas Series and NumPy Arrays
Ans. Differences are
Pandas Series NumPy Arrays
The elements can be indexed in The indexing starts with zero for the
descending order also. firstelement and the index is fixed
20
7 1. What do you mean by Pandas in Python?
Ans. PANDAS (PANel DAta) is a high-level data manipulation tool used for analyzing
data. Pandas library has a very rich set of functions.
1. Series
2. DataFrame
3. Panel
8 Name three data structures available in Pandas.
Ans. Three data structures available in Pandas are :
1. Series
2. DataFrame
3. Panel
9 Write the code in python to create an empty Series.
Ans.
import pandas as pd
S1 = pd.Series( )
print(S1)
OR
import pandas as pd
S1 = pd.Series( None)
print(S1)
21
12 Write command to install pandas in python.
Ans. pip install pandas
My 100
name 110
is 120
Amit 130
Gandhi 140
dtype: int64
14 Write the output of the following :
import pandas as pd
L1=[1,"A",21]
S1 = pd.Series(data=2*L1)
print(S1)
Ans.
0 1
1 A
2 21
3 1
4 A
5 21
dtype: object
s 1
u 4
p 7
e 10
r 13
dtype: int64
22
17 Complete the code to get the required output :
import ______ as pd
________ = pd.Series([31, 28, 31], index = ["Jan", "Feb", "Mar"] )
print(S1["_______"])
OUTPUT :
28
Ans.
import pandas as pd
S1 = pd.Series([31,28,31], index = ["Jan","Feb","Mar"])
print(S1["Feb"])
18 Fill in the blank of given code, if the output is 71.
import pandas as pd
S1 = pd.Series([10, 20, 30, 40, 71,50])
print(S1[ __________ ])
Ans.
import pandas as pd
S1 = pd.Series([10, 20, 30, 40, 71,50])
print(S1[ 4 ])
19 Write a program to modify the value 5000 to 7000 in the following Series “S1”
A 25000
B 12000
C 8000
D 5000
Ans.
import pandas as pd
S1[3]=7000
print(S1)
20 Write a program to display only those values greater than 200 in the given Series “S1”
0 300
1 100
2 1200
3 1700
Ans.
import pandas as pd
S1 = pd.Series([300, 100, 1200, 1700])
print(S1[S1>200])
23
Index
DATA FRAMES
DataFrame Data Structure
It is two dimensional (tabular) heterogeneous data labeled array.
It has two indices or two axes : a row index (axis=0) and a column index (axis=1)
The row index is known as index and the column index is called the column name.
The indices can be of any data type.
It is both value mutable and size mutable.
We can perform arithmetic operations on rows and columns.
Creating and Displaying a DataFrame
To create a DataFrame object, we can use the syntax:
<dataframe object> = pandas.DataFrame( <a 2D datastructure> , [columns=<column
sequence>] , [index=<index sequence>] )
where the 2D data structure passed to it, contains the data values.
Empty DataFrame
import pandas as pd
df=pd.DataFrame()
print(df)
DataFrame from 2D dictionary
A 2D dictionary is a dictionary having items as (key : value) where value part is a data
structure of any type : a list, a series, a dictionary etc. But the value parts of all the keys
should have similar structure and equal lengths.
Creating a DataFrame from 2D dictionary having values as lists:
dict1={'Students':['Neha','Maya','Reena'],
'Marks':[20,40,30],
'Sports':['Cricket', 'Football','Badminton']}
df1=pd.DataFrame(dict1)
print(df1)
The keys of the dictionary has become columns.
The columns are placed in sorted order.
The index is assigned automatically (0 onwards).
We can specify our own index too by using the index argument.
df2=pd.DataFrame(dict1,index=['I','II','III'])
print(df2)
The number of indexes given in the index
sequence must match the length of the
dictionary’s values, otherwise Python will
give error.
24
print(df3)
or
smarks=pd.Series([80,90,70],index=['Neha','Maya','Reena'])
sage=pd.Series([25,30,29],index=['Neha','Maya','Reena'])
dict={'Marks':smarks,'Age':sage}
df3=pd.DataFrame(dict)
print(df3)
DataFrame object created has columns assigned from
the keys of the dictionary object and its index assigned from the indexes
of the Series object which are the values of the dictionary object.
25
Make sure not to miss the colon after comma.
print(df5.loc['Ammu', :])
print(df5.loc[:,'ACC':'IP'])
26
<dataframe object>.at[<row label>,<column label>]
Or
<dataframeobject>.iat[<numeric row index>,
<numeric column index>]
print(df5.at['Achu','ACC']) 67
or
print(df5.iat[1,1])
If you want to add a column that has different values for all its rows, then we
can assign the data values for each row of the column in the form of a list.
df5[‘ENG’]=[50,60,40,30,70]
There are some other ways for adding a column to a database.
<dataframe object>.at[ : , <column name>]=value
Or
<dataframe object>.loc[ : ,<column name>]=value
df5.at[ : ,'ENG']=60
print(df5)
or
df5.loc[ : ,'ENG']=60
print(df5)
27
To change or modify a single data
value
<dataframe object>.<column>[<row
label or row index>] = value
df5.BS['Ammu']=100
print(df5)
or
df5.BS[0]=100
print(df5)
29
rename() renames the existing index or column labels
in a dataframe/series.
The old and new index/column labels are to be
provided in the form of a dictionary where keys are
the old indexes/row labels and the values are the
new names for the same.
Syntax:
<DF>.rename(index=None, columns=None, inplace=False)
where index and columns are dictionary like.
inplace, a boolean by default False (which returns a new dataframe with
renamed index/labels).
If True then changes are made in the current dataframe.
import pandas as pd
dict={'p_id':[101,102],'p_name':['Hard disk','Pen Drive']}
df=pd.DataFrame(dict)
print(df,"\n")
#df.rename(columns={'p_id':'Product_ID','p_name':'product_name'},inplace=True)
#or
df=df.rename(columns={'p_id':'Product_ID','p_name':'product_name'})
print(df)
Reindexing
reindex() used to change the order of the rows or
columns in DataFrame/Series and returns
DataFrame/Series after changes.
Syntax:
<DF>.reindex(index=None, columns=None, fill_value=NaN)
df=df.reindex(columns=['product_name','Product_ID'])
print(df)
If the mentioned indexes/columns do not
exist in dataframe, these will be added as
per the mentioned order with NaN
values.
df=df.reindex(columns=['product_name','Product_ID','product_category'])
print(df)
30
By using fill_value, we can specify
which will be filled in the newly added
row/column.
df=df.reindex(columns=['product_name','Product_ID','product_category'],
index=[1,0],fill_value='Home')
print(df)
Boolean indexing
Like default indexing (0,1,2…) or labeled
indexing , there is one more way to index –
Boolean Indexing (Setting row index to True/
False etc.) .
This helps in displaying the rows of Data Frame,
according to True or False as specified in the
command.
import pandas as pd
dict={'p_id':[101,102,103],'p_name':['Hard disk','Pen Drive','Camera']}
df=pd.DataFrame(dict)
df.index=[True,False,True]
print(df,"\n")
print(df.loc[True])
DataFrame attributes
All information related to a DataFrame object is available through attributes.
<DataFrane object> . <attribute name>
Attribute Description
index Returns the index (row labels) of the DataFrame
columns Returns the column labels of the DataFrame
axes Returns a list representing both the axes of the Data
Frame (axis=0 i.e. index and axis=1 i.e. columns)
values Returns a Numpy representation of the DataFrame
dtypes Returns the dtypes of data in the DataFrame
shape Returns tuple of the shape of the DataFrame
ndim Returns number of dimensions of the dataframe
size Returns the number of elements in the dataframe
empty Returns True if the DataFrame object is empty, otherwise
False
T Transpose index and columns of DataFrame
Answers :=
i. del df['A']
ii. A B C
ENAME ABC PQR LMN
SALARY 200000 100000 20000
iii. df=df.drop(['SALARY'],axis=0)
iv. df['A']=100
v. df.B['DEPT']='MECH'
vi. print(df.loc[['DEPT','SALARY'],["A","B"]])
vii. df.rename(columns={"A":"D"},inplace=False)
viii. df['E']=["CS",104,"XYZ",300000]
ix. df.loc['COMM']=[3000,4000,5000]
x. df.rename(index={"DEPT":"DEPARTMENT"},inplace=True)
xi. print(df.A[‘DEPT’])
xii. 4
2. Consider the following Data Frame df and answer questions
ACC BST ECO IP
S1 90 91 92 93
S2 94 95 96 97
S3 98 99 100 100
S4 91 92 93 94
32
i. Create a new column total TOT by adding marks
ii. Find the highest marks scored by student s1
iii. Find the lowest marks scored by student s1
iv. Find the highest marks in ACC
v. Find the lowest marks in IP
Answers:=
i. df['TOT']=df['ACC']+df['BST']+df['ECO']+df['IP']
ii. print(max(df.loc['S1',:]))
iii. print(min(df.loc['S1',:]))
iv. print(max(df['ACC']))
v. print(min(df['IP']))
Ans:
1. It displays the names of columns of the Dataframe.
2. It will display all columns except the last 5 columns.
3. It displays all columns with row index 2 to 7.
4. It will display entire dataframe with all rows and columns.
5. It will display all rows except the last 4 four rows
34
2. What will be the output of df.iloc[3:7,3:6]?
Ans:
It will display the rows with index 3 to 6 and columns with index 3 to 5 in a dataframe ‘df’.
3. Write a python program to create a data frame with headings (CS and IP) from the list
given below-
[[79,92][86,96],[85,91],[80,99]]
Ans:
l=[[10,20],[20,30],[30,40]]
df=pd.DataFrame(l,columns=['CS','IP'])
print(df)
4. Write python statement to delete the 3rd and 5th rows from dataframe df.
df1=df.drop(index=[2,4],axis=0)
or
df1=df.drop([2,4])
Sl
MCQ QUESTIONS
No
To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe
you can write
ANS : (iii) 5
To change the 5th column's value at 3rd row as 35 in dataframe DF, you can
write
4
(a) DF[4, 6] = 35
(b) DF.iat[4, 6] = 35
(c) DF[3, 5] = 35
35
(d) DF.iat[3, 5] = 35
ANS:- d) DF.iat[3, 5] = 35
Which function is used to find values from a DataFrame D using the index
number?
a) D.loc
b) D.iloc
5
c) D.index
d) None of these
ANS: b) D.iloc
In a DataFrame, Axis= 0 represents the elements
a.rows
b.columns
6
c.both
d.None of these.
ANS: a.rows
In DataFrame, by default new column added as the _____________ column
(i) First (Left Side)
(ii) Second
7 (iii)Last (Right Side)
(iv) Any where in dataframe
a.Df2=Df2.append(Df1)
b. Df2=Df2+Df1
9
c. Df2=Df2.appendwith.Df1
d. Df2=Df1.append(Df1)
ANS: a.Df2=Df2.append(Df1)
When we create DataFrame from List of Dictionaries, then number of columns in
DataFrame isequal to the _______
10 a. maximum number of keys in first dictionary of the list
b. maximum number of different keys in all dictionaries of the list
c. maximum number of dictionaries in the list
36
d. None of the above
ANS: (iii)DF.T
In DataFrame, by default new column added as the _____________ column
a. First (Left Side)
b. Second
14 c. Last (Right Side)
d. Any where in dataframe
(i) read.csv( )
16
(ii) readcsv( )
(iii) read_csv( )
(iv) Read_csv( )
37
ANS: (iii) read_csv( )
Which of the following function is not a Boolean reduction function
(i) Empty
(ii) Any()
17 (iii) All()
(iv) Fillna()
ANS: a) T
When we create DataFrame from List of Dictionaries, then number of columns in
DataFrame is equal to the _______
(i) maximum number of keys in first dictionary of the list
(ii) maximum number of different keys in all dictionaries of the list
20
(iii) maximum number of dictionaries in the list
(iv) None of the above
ANS: (ii) maximum number of different keys in all dictionaries of the list
Which of the following is/are characteristics of DataFrame?
a) Columns are of different types
b) Can Perform Arithmetic operations
21 c) Axes are labeled (rows and columns)
d) All of the above
(a) print(SHOP[City==’Delhi’])
22
(b) print(SHOP[SHOP.City==’Delhi’])
(c) print(SHOP[SHOP.’City’==’Delhi’])
(d) print(SHOP[SHOP[City]==’Delhi’])
38
ANS: (b) print(SHOP[SHOP.City==’Delhi’])
Which of the following commands is used to install pandas?
(i)pip install python –pandas
(ii)pip install pandas
23 (iii)python install python
(iv)python install pandas
ANS: b.Ndim
ANS: (iii)3, 5
39
ANS:- (c) drop
In the following statement, if column ‘mark’ already exists in the DataFrame ‘Df1’
then the assignment statement will __________ Df1['mark'] = [95,98,100] #There
are only three rows in DataFrame Df1
(i) Return error
29 (ii) Replace the already existing values.
(iii)Add new column
(iv)None of the above
(a) skip_rows = 5
30 (b) skiprows = 5
(c) skip - 5
(d) noread - 5
ANS: (i) 0
Which of the following function is used to load the data from the CSV file to
DataFrame?
34 (i) read.csv( )
(ii) readcsv( )
(iii)read_csv( )
40
(iv)Read_csv( )
ANS: (iii)read_csv( )
Write code to delete rows those getting 5000 salary.
(a) df=df.drop[salary==5000]
(b) df=df[df.salary!=5000]
35 (c) df.drop[df.salary==5000,axis=0]
(d) df=df.drop[salary!=5000]
Write code to delete the row whose index value is A1 from dataframe df.
(a) df=df.drop(‘A1’)
(b) df=df.drop(index=‘A1’)
38
(c) df=df.drop(‘A1,axis=index’)
(d) df=df.del(‘A1’)
ANS: b. Index
To get top 5 rows of a dataframe, you may use
(a) head( )
(b) head(5)
45 (c) top( )
(d) top(5)
42
ANS:- (b) iterrows( ) function may be used.
Write code to delete the row whose index value is A1 from dataframe df.
(a) df=df.drop(‘A1’)
(b) df=df.drop(index=‘A1’)
(c) df=df.drop(‘A1,axis=index’)
47
(d) df=df.del(‘A1’)
43
(b) . read_csv( )()
(c) = pandas.read()
(d) = pandas.read_csv()
ANS: (i) 1
To delete a row from dataframe, you may use _______ statement.
i. remove()
ii. ii. del()
56 iii. iii. drop()
iv. iv. cancel()
ANS: a. Row
___________ method in Pandas can be used to change the index of rows and
columns of a Series or Dataframe
(a) rename()
(b) reindex()
58
(c) reframe()
(d) none of these
44
(b) df=df.drop(‘marks’,axis=col)
(c) df=df.drop(‘marks’,axis=0)
(d) df=df.drop(‘marks’,axis=1)
ANS:- a. delete three columns having labels ‘Name’, ‘Class’ and ‘Rollno’
Difference between loc() and iloc().:
a. Both are Label indexed based functions.
b. Both are Integer position-based functions.
c. loc() is label based function and iloc() integer position based function.
62
d. loc() is integer position based function and iloc() index position based function.
ANS: c. loc() is label based function and iloc() integer position based
function.
Which command will be used to delete 3 and 5 rows of the data frame. Assuming
the data frame name as DF.
a. DF.drop([2,4],axis=0)
b. DF.drop([2,4],axis=1)
63
c. DF.drop([3,5],axis=1)
d. DF.drop([3,5])
ANS: a DF.drop([2,4],axis=0)
Assuming the given structure, which command will give us the given output:
Output Required: (3,4)
ANS: b. print(df.shape)
Write the output of the given command: df1.loc[:0,'Name'] Consider the given
dataframe.
EmpCode Name Desig
0 1405 VINAY Clerk
1 1985 MANISH Works Manager
2 1636 SMINA Sales Manager
65
3 1689 RINU Clerk
46
Index
Importing/Exporting Data between CSV files and Data Frames
Basics of CSV Files
CSV Files : A CSV file is a delimited value file. All CSV files are simple text files, can contain only numbers
and letters and structure the data contained in them in tabular form.
Files with the CSV extension are usually used to exchange data between different applications. Database
programs, analytical software, and other applications that store large amounts of information (for
example, contacts and customer data) usually support the CSV format.
All CSV files have the same general format: each column is separated by a comma and each new row
indicates a new row. Some programs that export data to a CSV file may use a different character to
separate values, such as a tab, semicolon, or space.
For example consider the data regarding medals won by India at Commonwealth Games 2022 stored in
a csv file medaltally.csv created using a spreadsheet software like Microsoft Excel or Libreoffice Calc.
When opened with spreadsheet like Excel. When opened with text editor like Notepad.
Example 1 : Consider the following file medaltally.csv. Here header argument is 0 and index_col is
None. Hence index becomes 0,1,2,3,...,12 and first row as column labels.
Example 2 : Consider the following file medaltally.csv. Here header argument is 0 and index_col is
0. Hence, first column values are taken as index labels and first row as column labels.
48
Example 3 : Consider the following file medaltally2.csv with the data regarding some events missing.
Those missing data are read as NaN.
Example 5 : Consider the following file medaltally.csv to be read with rows 1,3,4,5 to be skipped.
Example 6 Consider the following file medaltally.csv to be read with user specified column names 'Gold',
'Silver', and 'Bronze'.
49
Note : Here rows numbers are taken as weightlifting 1, Judo
2, and so on.
Example 7 : Consider the following file processed5_medaltally.csv to be read with separator as '#'.
50
Example 1 : Consider the dataframe medaltally. Here header and index arguments are True;
Hence the index and column labels are written to the csv file processed_medaltally.csv.
Example 2 : Consider the dataframe medaltally. Here header is False and index argument is
True; Hence the columns labels are not present in file processed2_medaltally.csv.
Example 3 : Consider the dataframe medaltally. Here header is True and index argument is
False; Hence the index labels are not present in the file processed3_medaltally.csv but column labels
are present.
51
Example 4 : Consider the dataframe medaltally. Here header is False and index argument is
False; Hence the index labels as well as the header are not present in written file
processed4_medaltally.csv. Only data is present in the file processed4_medaltally.csv.
Example 5 : Consider the dataframe medaltally. The default delimiter ',' in a csv file can be
changed by setting the sep argument in to_csv. Here delimiter is changed to '#'.
Exercises
1. Given the following csv file which of the command will correctly read the details into a dataframe from
csv file sectors_economy.csv.
2. Which of the commands will correctly write literacy to literacy.csv with index and column labels.
5. The argument to be set in read_csv for reading user specified number of rows from a csv file is:
Answers
1. a
2. d
3. a
4. a
5. c
53
Index
Data Visualization
What is Data Visualization ?
Data visualization is the technique to present the data in a pictorial or graphical format. It
enables stakeholders and decision makers to analyze data visually. The data in a graphical
format allows them to identify new trends and patterns easily.
Importing PyPlot
54
To import Pyplot following syntax is
import matplotlib.pyplot
or
import matplotlib.pyplot as plt
After importing matplotlib in the form of plt we can use plt for accessing any function of
matplotlib
Line Plot:
A line plot/chart is a graph that shows the frequency of data occurring along a number line.
The line plot is represented by a series of data points called markers connected with a
straight line. Generally, line plots are used to display trends over time. A line plot or line
graph can be created using the plot () function available in pyplot library.
We can, not only just plot a line but we can explicitly define the grid, the x and y axis scale
and labels, title and display options etc.
• We can create line graph with x coordinate only or with x and y coordinates.
• Function to draw line chart – plot()
• Default colour of line- blue
55
The default width for each bar is .0.8 units, which can be changed.
• Syntax: plt.plot(x,y)
Line Plot customization
• Custom line color
plt.plot(x,y,'red')
Change the value in color argument like ‘b’ for blue,’r’,’c’,…..
• Label-
plt.xlabel(‘TIme') – to set the x axis label
plt.ylabel(‘Temp') – to set the y axis label
Changing Marker Type, Size and Color
plt.plot(x,y,'blue',marker='*',markersize=10,markeredgecolor='magenta')
56
Bar Graph
A graph drawn using rectangular bars to show how large each value is. The bars can be
horizontal or vertical. A bar graph makes it easy to compare data between different groups
at a glance. Bar graph represents categories on one axis and a discrete value in the other.
The goal of bar graph is to show the relationship between the two axes. Bar graph can
also show big changes in data over time.
Syntax : plt.bar(x,y)
Bar graph customization
• Custom bar color
plt.bar(x,y, color="color code/color name")
To se different colors for different bars
plt.bar(x,y, color="color code/color name sequence")
• Custom bar width
plt.bar(x,y, width=float value)
To set different widths for different bars
plt.bar(x,y, width=float value sequence)
• Title
plt.title(' Bar Graph ') – Change it as per requirement
• Label-
plt.xlabel(‘Overs') – to set the x axis label
plt.ylabel(‘Runs') – to set the y axis label
PROGRAM :
import matplotlib.pyplot as plt
overs=['1-10','11-20','21-30','31-40','41-50']
runs=[65,55,70,60,90]
plt.xlabel('Over Range')
plt.ylabel('Runs Scored')
plt.title('India Scoring Rate')
plt.bar(overs,runs)
plt.show( )
57
HISTOGRAM
Creating a Histogram :
It is a type of bar plot where X-axis represents the bin ranges while Y-axis gives information
about frequency.
To create a histogram the first step is to create bin of the ranges, then distribute the whole
range of the values into a series of intervals, and count the values which fall into each of
the intervals.
58
Bins are clearly identified as consecutive, non-overlapping intervals of variables.
Syntax:
plt.hist(x,other parameters)
Optional Parameters
x array or sequence of array
PROGRAM :
59
• Title
plt.title('Histogram ') – Change it as per requirement
• Label-
plt.xlabel(‘Data') – to set the x axis label
plt.ylabel(‘Frequency') – to set the y axis label
• Legend - A legend is an area describing the elements of the graph. In the matplotlib library
there is a function named legend() which is used to place a legend on the axes .
When we plot multiple ranges in a single plot ,it becomes necessary that legends are specified.It
is a color or mark linked to a specific data range plotted .
i)In the plotting function like bar() or plot() , give a specific label to the data range using label
ii)Add legend to the plot using legend ( ) as per the sytax given below .
position number can be u1,2,3,4 specifying the position strings upper right/'upper left/'lower
left/lower right respectively .
60
Default position is upper right or 1
To save any plot savefig() method is used. Plots can be saved in various formats like
pdf,png,eps etc .
plt.savefig('line_plot.pdf') // save plot in the current directory
plt.savefig('d:\\plot\\line_plot.pdf') // save plot in the given path
WORKSHEET 1
1.What is data visualization?
a) It is the numerical representation of information and data
b) It is the graphical representation of information and data
c) It is the character representation of information and data
d) None of the above
ANSWERS
1. b) It is the graphical representation of information and data
2. a) matplotlib.pyplot
3. d) plt.title()
4. c) histogram
5. c)hist
6. c) pyplot
7. c) import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,5,1])
plt.show()
63
8. a) Line chart
9. d) All the above
10. import matplotlib.pyplot as plt
a = [1,2,3,4,5]
b = [10,31,26,24,20]
plt.plot(a,b)
plt.show()
WORKSHEET 2
2.To change the width of bars in bar chart, which of the following argument
with a float value is used?
a) thick
b) thickness
c) width
d) barwidth
7. A histogram is used:
a) for continuous data
b) for grouped data
c) for time series data
d) to compare two sets of data
8.Which function is used to show legend ?
a) display ( )
b) show( )
c) legend( )
d) legends( )
10.Write code to draw the following bar graph representing the classes and number of students
in each class.
65
Answers:
1. b) plt.xlabel(“title”)
2. c) width
3. a) A legend is an area describing the elements of the graph.
4. b) savefig( )
5. d) ‘<’
6. c) plt.barh()
7. a) for continuous data
8. c) legend( )
9. a)Markers
10.
import matplotlib.pyplot as plt
classes = ['VII','VIII','IX','X']
students = [40,45,35,44]
plt.barh(classes, students)
plt.show()
WORKSHEET 3
1.To specify the style of line as dashed , which argument of plot() needs to be set ?
a) line
b) width
c) Style
d) linestyle
3.Observe the following figure. Identify the coding for obtaining this as output.
4.Read the statements given below and identify the right option to draw a histogram.
Statement A: To make a Histogram with Matplotlib, we can use the plt.hist() function.
Statement B: The bin parameter is compulsory to create histogram.
a) Statement A is correct
b) Statement B is correct
c) Statement A is correct, but Statement B is incorrect
d) d. Statement A is incorrect, but Statement B is correct
5. Which graph should be used where each column represents a range of values, and the
height of a column corresponds to how many values are in that range?
a) plot
b) line
c) bar
d) histogram
Go through the following case study and answer the questions 6 to 10.
67
Mr. Sharma is working in a game development industry and he was comparing the given
chart on the basis of the rating of the various games available on the play store. He is trying
to write a code to plot the graph. Help Mr. Sharma to fill in the blanks of the code and get
the desired output.
import__________________________ #Statement 1
Games=[“Subway Surfer”,”Temple Run”,”Candy Crush”,”Bottle hot”,”Runner Best”]
Rating=[4.2,4.8,5.0,3.8,4.1]
plt.______________(Games,Rating) #Statement 2
plt.xlabel(“Games”)
plt.______________(“Rating”) #Statement 3
plt._______________ #Statement 4
6) Choose the right code from the following for statement 1.
(a) matplotlib as plt
(b) pyplot as plt
(c) matplotlib.pyplot as plt
(d) matplotlib.plt as pyplot
7) Identify the name of the function that should be used in statement 2 to plot the above
graph.
(a) line()
68
(b) bar()
(c) hist()
d) barh()
8) Choose the correct option for the statement 3.
(a) title(“Rating”)
(b) ytitle(“Rating”)
(c) ylabel(“Rating”)
(d) yaxis(“Rating”)
9) Choose the right function/method from the following for the statement 4.
(a) display()
(b) print()
(c) bar()
(d) show()
10) In case Mr. Sharma wants to change the above plot to any other shape, which
statement, should he change.
(a) Statement 1
(b) Statement 2
(c) Statement 3
(d) Statement 4
11.Write a program to generate a histogram with the following values
X=[25,28,35,46,57,68,73]
Include the following parameters/arguments along with historam
1.It should be a horizontal histogram
2.Number of bins should be 20
ANSWERS
1. d) linestyle
2. c)histh( )
69
3. import matplotlib.pyplot as plt
eng_marks=[10,55,30,80,50]
st_name=["amit","dinesh","abhishek","piyush","rita"]
plt.plot(st_name,eng_marks)
plt.show()
4. c) Statement A is correct, but Statement B is incorrect
5. d). histogram
6. c) matplotlib.pyplot as plt
7. b) bar()
8. c) ylabel(“Rating”)
9. d) show()
10. b) Statement 2
11.
import matplotlib.pyplot as plt
X=[25,28,35,46,57,68,73]
plt.hist(X,orientation='horizontal',bins=20)
plt.show()
70
Index
UNIT 2
Database Query and SQL Math Functions
POW( ) or POWER( )
POWER( A, B) or POW( A, B) returns the number A raised to the power of another
number B. Here the number A is the base and the number B is the exponent.
Needs two numbers as parameters.
SYNTAX: SELECT POW(A, B);
Examples:
1) mysql> select power(2,3);
+ +
| power(2,3) |
+ +
| 8 |
+ +
1 row in set (0.05 sec)
2) mysql>select pow(2,3);
+ +
| pow(2,3) |
+ +
| 8 |
+ +
1 row in set (0.00 sec)
+
1 row in set (0.00
sec)
14) mysql>select round(1444.45, -3);
+ +
| round(1444.45, -3) |
+ +
| 1000 |
+ + 1 row in set (0.00 sec)
73
15) mysql>select round(1544.45, -3);
+ +
| round(1544.45, -3) |
+ +
| 2000 |
+ +
1 row in set (0.00 sec)
MOD( )
This function can be used to find modulus (remainder) when one number is divided
by another.
Examples:
mysql>select mod(5,3)
+ +
| mod(5,3) |
+ +
| 2 |
+ +
1 row in set (0.00 sec)
2) mysql>select mod(4,2);
+ -+
| mod(4,2) |
+ +
| 0 |
+ +
1 row in set (0.00 sec)
Text/String/Character Functions:
UCASE( ) / UPPER( )
Used to convert a character or text to uppercase.
Examples:
1) mysql>SELECT UCASE('hello');
+ +
| UCASE('hello') |
+ +
| HELLO |
+ +
1 row in set (0.00 sec)
74
2) mysql>SELECT Upper('hello');
+ +
| Upper('hello') |
+ +
| HELLO |
+ +
1 row in set (0.00 sec)
LCASE( ) / LOWER( ) :
Used to convert a character or text to lowercase.
Examples:
1) mysql>select lcase('HELLO');
+ +
| lcase('HELLO') |
+ +
| hello |
+ +
1 row in set (0.00 sec)
2) mysql>select LOWER('HELLO');
+ +
| LOWER('HELLO') |
+ +
| hello |
+ +
1 row in set (0.00 sec)
MID( ) : To extract a specified number of characters from the string.
First parameter is the text/string. Second parameter is the starting index
and the thirdparameter is the number of characters required.
(Note: index starts with 1 and not 0.)
Examples:
1) mysql>SELECT MID('ABCDEFGHIJKLMNOP', 1,4);
+ +
| MID('ABCDEFGHIJKLMNOP', 1,4) |
+ +
| ABCD |
1 row in set (0.00
sec)
2) mysql>SELECT MID('ABCDEFGHIJKLMNOP', 1);
+ +
| MID('ABCDEFGHIJKLMNOP', 1) |
+ +
| ABCDEFGHIJKLMNOP |
+ 1 row in set (0.00 sec)
75
3) mysql> SELECT MID('ABCDEFGHIJKLMNOP', -2,-1);
+ +
| MID('ABCDEFGHIJKLMNOP', -2,-1) |
+ +
| |
+ 1 row in set (0.00
sec)
4) mysql>SELECT MID('ABCDEFGHIJKLMNOP', 0,4);
+ +
| MID('ABCDEFGHIJKLMNOP', 0,4) |
+ +
| |
1 row in set (0.00
sec)
(Please note the output of example 3, 4 )
5) mysql>SELECT MID('ABCDEFGHIJKLMNOP', 3,4);
+ +
| MID('ABCDEFGHIJKLMNOP', 3,4) |
+ +
| CDEF |
+ 1 row in set (0.00 sec)
6) mysql>SELECT MID('ABCDEFGHIJKLMNOP', -4,2);
+ +
| MID('ABCDEFGHIJKLMNOP', -4,2) |
+ +
| MN |
+ + 1 row in set (0.00 sec)
SUBSTRING( ) : Same as MID( ) function
To extract a specified number of characters from thestring.
Examples:
1) mysql>SELECT SUBSTRING('ABCDEFGHIJKLMNOP', 3,4);
+ +
| SUBSTRING('ABCDEFGHIJKLMNOP', 3,4) |
+ +
| CDEF |
+ 1 row in set (0.00 sec)
76
3) mysql>SELECT SUBSTRING('ABCDEFGHIJKLMNOP', 1,4);
+ +
| SUBSTRING('ABCDEFGHIJKLMNOP', 1,4) |
+ +
| ABCD |
+ 1 row in set (0.00 sec)
4) mysql>SELECT SUBSTRING('ABCDEFGHIJKLMNOP', 4,2);
+ +
| SUBSTRING('ABCDEFGHIJKLMNOP', 4,2) |
+ +
| DE |
+ 1 row in set (0.00 sec)
5) mysql>SELECT SUBSTRING('ABCDEFGHIJKLMNOP', -4,2);
+ +
| SUBSTRING('ABCDEFGHIJKLMNOP', -4,2) |
+ +
| MN |
+ 1 row in set (0.00 sec)
SUBSTR( ) : Same as that of MID( ) and SUBSTRING( )
Examples:
1) mysql>SELECT SUBSTR('ABCDEFGHIJKLMNOP', -4,3);
+ +
| SUBSTR('ABCDEFGHIJKLMNOP', -4,3) |
+ +
| MNO |
+ 1 row in set (0.00 sec)
2) mysql>SELECT SUBSTR('ABCDEFGHIJKLMNOP', 1,3);
+ +
| SUBSTR('ABCDEFGHIJKLMNOP', 1,3) |
+ +
| ABC |
+ 1 row in set (0.00 sec)
3) mysql>SELECT SUBSTR('ABCDEFGHIJKLMNOP', 4,3);
+ +
| SUBSTR('ABCDEFGHIJKLMNOP', 4,3) |
+ +
| DEF |
+ 1 row in set (0.00 sec)
LENGTH( ) :
This function returns the number of characters in the given text.
Examples:
1) mysql> SELECT LENGTH('HELLO WORLD');
+ +
| LENGTH('HELLO WORLD') |
+ +
| 11 |
77
+ 1 row in set (0.00 sec)
2) mysql> SELECT LENGTH(' ');
+ +
| LENGTH(' ') |
+ +
| 3 |
+1 row in set (0.00 sec)
3) mysql> SELECT LENGTH(' ');
+ +
| LENGTH(' ') |
+ +
| 1 |
+ +
1 row in set (0.00 sec)
78
RIGHT( ) :Returns the specified number of characters including space starting
from the right of the text.
Parameters required : text, number of characters to be extracted.
Examples:
1) mysql> SELECT RIGHT('ABCDEFGHIJKLMNOP',1);
+ +
| RIGHT('ABCDEFGHIJKLMNOP',1) |
+ +
|P |
+ 1 row in set (0.00 sec)
(Extracting 1 character)
2) mysql> SELECT RIGHT('ABCDEFGHIJKLMNOP',2);
+ +
| RIGHT('ABCDEFGHIJKLMNOP',2) |
+ +
| OP |
+ 1 row in set (0.00 sec)
(Extracting 2 characters)
3) mysql> SELECT RIGHT('ABCDEFGHIJKLMNOP',3);
+ +
| RIGHT('ABCDEFGHIJKLMNOP',3) |
+ +
| NOP |
+ 1 row in set (0.00 sec)
4) mysql> SELECT RIGHT('ABCDEFGHIJKLMNOP',4);
+ +
| RIGHT('ABCDEFGHIJKLMNOP',4) |
+ +
| MNOP |
+ 1 row in set (0.00 sec)
5) mysql> SELECT RIGHT('ABCDEFGHIJKLMNOP',-1);
+ +
| RIGHT('ABCDEFGHIJKLMNOP',-1) |
+ +
INSTR( ) : Checks whether the second string/text is present in the first string.
If present it returns the starting index.Otherwise returns 0.
Examples:
1) mysql> SELECT INSTR('ABCDEFGHIJKLMNOP','ABC');
+ +
| INSTR('ABCDEFGHIJKLMNOP','ABC') |
+ +
| 1 |
+ 1 row in set (0.00 sec)
79
2) mysql> SELECT INSTR('ABCDEFGHIJKLMNOP','BC');
+ +
| INSTR('ABCDEFGHIJKLMNOP','BC') |
+ +
| 2 |
+ 1 row in set (0.00 sec)
3) mysql> SELECT INSTR('ABCDEFGHIJKLMNOP','EFG');
+ +
| INSTR('ABCDEFGHIJKLMNOP','EFG') |
+ +
| 5 |
+ 1 row in set (0.00 sec)
4) mysql> SELECT INSTR('ABCDEFGHIJKLMNOP','QRST');
+ +
| INSTR('ABCDEFGHIJKLMNOP','QRST') |
+ +
| 0 |
+ 1 row in set (0.00 sec)
LTRIM( ) :To trim the spaces, if any, from the beginning of the text.
Examples:
1) mysql> SELECT LTRIM(' HELLO');
+ +
| LTRIM(' HELLO') |
+ +
| HELLO |
+
RTRIM( ) : To trim the spaces, if any, from the end of the text.
Examples:
1) mysql> SELECT RTRIM('HELLO ');
+ +
| RTRIM('HELLO ') |
+ +
| HELLO |
+ 1 row in set (0.00 sec)
TRIM( ): To trim the spaces, if any, from the beginning and end of the text.
Examples:
80
1) mysql> SELECT CONCAT(TRIM('HELLO '), 'WORLD');
+ +
| CONCAT(TRIM('HELLO '), 'WORLD') |
+ +
| HELLOWORLD |
+ + 1 row in set (0.00 sec)
Try yourself:
Give the output of the following:
1. SELECT POWER(3,3);
2. SELECT POW(3,2);
3. SELECT ROUND(123.45,1);
4. SELECT ROUND(123.45,-1);
5. SELECT ROUND(123.45,0);
6. SELECT ROUND(153.45,2);
7. SELECT ROUND(155.45,0);
8. SELECT ROUND(245,-2);
9. SELECT ROUND(255,- 2);
10. SELECT ROUND(897,3);
11. SELECT ROUND(457,-3);
12. SELECT
ROUND(1567,-3);
13. SELECT RIGHT(‘MORNING’, 2);
14.SELECT MID( TRIM(‘GOOD ‘) , 1,
4);
15. SELECT INSTR( ‘GOOD MORNING’ ,
‘GOOD’ );
Answers
1) 27, 2)9, 3)123.5 4)120, 5)123 6)200, 7)155, 8)200, 9)300, 10)1000, 11)0, 12)2000,
13)NG , 14)GOOD, 15)1
81
Date Functions
1 NOW():- Function that returns the current date and time.
2 DATE():- This function returns the date part from Date and time.
82
7 DAYNAME():- Returns the weekday name of a date.
Aggregate functions:- It perform calculation on multiple values and return a single value. It is also
know as Multi-row functions
List of aggregate functions
MAX(),MIN(),AVG(),SUM(),COUNT()
Aggregate function will not consider NULL values for calculation.
Conside the following table named student.
83
4 SUM():- It returns the sum of values in a dataset.
6 COUNT( Field Name) will count the number of values(excluding NULL) present in the dataset.
Here answer 4 is displyed even though 5 rows are present in the student table because one NULL
value is present in the column named mark.
Group By clause:- The GROUP BY statement groups rows that have the same values into
summary rows. The GROUP BY statement is often used with aggregate functions ( COUNT() ,
MAX() , MIN() , SUM() , AVG() ) to group the result-set by one or more columns.
84
The WHERE clause in MySQL is used with SELECT, INSERT, UPDATE, and DELETE queries to
filter rows from the table or relation. It describes a specific condition when retrieving records from
tables.
2 Display number of employees in each subject whose experience is more than 2.
select count(*) from teacher where experience>2 group by subject;
WHERE clause is coming before group by.
Having Clause
The HAVING clause is often used with the GROUP BY clause to filter rows based on a specified
condition. If we omit the GROUP BY clause, the HAVING clause behaves like the WHERE clause.
1 Display the subject and number of teachers in each subject where group count is more than 1.
select subject, count(*) from teacher group by subject having count(*)>1;
HAVING clause is coming after group by
2 Display details of teacher whose tid more than 3
select * from teacher having tid>3;
OR
select * from teacher where tid>3;
HAVING clause is behaving like WHERE clause in this example.
ORDER BY
Order by clause is used to arrange the rows in Ascending or Descending order of values in a
Column.
1 Display the details of teachers ascending of experience.
select * from teacher order by experience;
OR
select * from teacher order by experience ASC;
85
Questions
1. Which of the following would arrange the rows in ascending order in SQL.
a. SORT BY b. ALIGN BY c. GROUP BY d. ORDER BY
2. Prachi has given the following command to obtain the highest marksSelect
max(marks) from student where group by class;
but she is not getting the desired result. Help her by writing the correct command.
a. Select max(marks) from student where group by class;
b. Select class, max(marks) from student group by marks;
c. Select class, max(marks) group by class from student;
d. Select class, max(marks) from student group by class;
3. Help Ritesh to write the command to display the name of the youngest student?
a. select name,min(DOB) from student ;
b. select name,max(DOB) from student ;
c. select name,min(DOB) from student group by name ;
d. select name,maximum(DOB) from student;
86
6. Write commands in SQL for (i) and (ii) and output for (iii)
Answers
1. d
2. d
3. b
4
a. select Type, avg(Price) from Vehicle group by Type having Qty>20;
b. select Company, count(distinct Type) from Vehicle group by Company;
c. Select Type, sum(Price* Qty) from Vehicle group by Type;
5.
i. SELECT * FROM FANS ORDER BY FAN_DOB DESC;
ii. SELECT FAN_MODE, COUNT(*) FROM FANS GROUP BY FAN_MODE;
iii. SELECT MAX(FAN_DOB) FROM FANS;
6.
(i) SELECT * FROM STORE ORDER BY NAME;
(ii) SELECT CITY, COUNT(*) FROM STORE GROUP BY STORE HAVING COUNT(*)>2;
(iii) Count(StoreId) | NoOfEmp |
+ + +
|1 | 10 |
|1 | 11 |
|1 | 5 |
|1 | 7 |
87
Worksheet 1
A. Give output of the following:
1. Select Round(546.345, -2);
2. Select Round(546.345, -3);
3. Select Truncate(124.56, 1);
4. Select Truncate(124.56, -2);
5. Select SIGN(-341.45);
6. Select SIGN(0);
7. Select MOD(34,5);
8. Select MOD(6,8);
9. Select MOD(12.6, 8);
10. Select Pow(2,4);
11. Select Char(78,65,77,65,78);
12. Select Char(76.5,65.3,'77.6',65,78);
13. Select Substr('JS09876/XII-H/12',-8,7);
14. Select Trim(Leading 'Pp' from 'PppProgram Features');
15. Select Instr('COORDINATION COMMITTEE ORDER','OR');
16. Select left('COORDINATION COMMITTEE ORDER', length('committee'));
17. Select right('COORDINATION COMMITTEE ORDER', length('committee order'));
Worksheet 2
1. select Char(70,65,67,69);
2. select Char(65, 67.3, '69.3');
3. SELECT CONCAT(NAME,dept) AS 'NAME DEPT' FROM Employee;
4. SELECT LOWER(NAME) FROM Employee
5. select substr('ABCDEFGH', 3,4);
6. select substr('ABCDEFGH', -3,4);
7. SELECT UCASE('pqrxyz');
8. SELECT RTRIM('abcdefgh ');
9. select trim(' pqr Periodic Test 1 is over pqr ');
10. select instr('O P JINDAL SCHOOL, KHARSIA ROAD RAIGARH, JINDAL STEEL AND
POWER LIMITED','JINDAL');
11. SELECT LENGTH('O P JINDAL SCHOOL, RAIGARH');
12. SELECT LENGTH(12345 );
13. select left('JS12345/OPJS/XII/A',7);
14. select substr('JS12345/OPJS/XII/A',9,4);
15. select right('JS12345/OPJS/XII/A',5);
88
16. select MOD(23,5);
17. select power(3,4);
18. select ROUND(20.392,1);
19. select sign(-945);
20. select sqrt(25);
21. select truncate(129.345,1);
Worksheet 3
1. select pow(2,3), power(-2,3), pow(3,4);
2. select round(12345.789,2), round(1434.56,-1);
3. select round(62.789),round(6.89,0);
4. select truncate(466.789,1), truncate(645.56,-1);
5. select sqrt(81)+20 from dual;
6. select mod(23,2), mod(78,4);
7. select sign(15,-15), sign(-25), sign(70);
8. select char(65,67,69) from dual;
9. select concat(“info”,”rmatics”);
10. select concat(“ISM -”,concat(“xii”,”I”));
11. select lower(“INFORM”),lcase(“Class XII”);
12. select upper(“Class xii”),ucase(“informatics”);
13. select substring(“India is the Best”,3,2),substr(“Indian”,-2,1);
14. select length(trim(“ abcde defe “));
15. select instr(“Informatics”,”r”);
16. select length(“ab cde fge”);
17. select left(“Informatics”,4) from dual;
18. select right(“Informatics”,6);
19. select mid(“Indian School Muscat”,8,6);
20. Select curdate(), current_date();
21. Select date(now());
22. Select month(now());
23. Select year(“2012-02-21”);
24. Select dayname(now());
25. Select dayofmonth(“2011-03-23”);
26. Select dayofweek(now());
27. Select dayofyear(“2016-02-04”);
28. Select dayofyear(“2012-02-02”);
29. Select NOW(),SLEEP(3),SYSDATE();
89
Index
Unit 3
Introduction to Computer Networks
Consider a standalone computer connected to a printer.
This computer is useful for a particular person at a time. Every time we need to access the files from this PC the
user needs to personally sit by it and work.
Concept of networking – Interconnection of Computers
Now we have connected PC 1 with PC 2. This is the most simple form of a computer network. The data/information
in PC 1 can be accessed from PC 2 and vice-versa. Also printer can be used from both PC 1 and PC 2.
Two or more autonomous computing device connected to one another in order to exchange information or
resources form a computer network.
Resource sharing:-Resource sharing makes it possible to use resources economically, for example, to
manage peripheral devices, such as laser printers, from all connected systems.
Data separation :-Data separation provides the ability to access and manage databases fromperipheral
workstations that need information
Separation of software tools:- The separation of software tools provides the possibility of simultaneous
use of centralized, previously installed software tools.
CPU resource sharing:- With the separation of processor resources, it is possible to usecomputing power
for data processing by other systems that are part of the network.
Multiuser mode:-The multi-user properties of the system facilitate the simultaneous use of centralized
application software tools previously installed and managed, for example, if the user of the system is
working with another task, then the current work performed is pushed into the background.
Where to connect the network cable while networking and form of cabling
90
The network cable is connected to a RJ-45 connector(RJ – Registered Jack
The following is the different types of network based on size of computer networks:
PAN
A Personal Area Network (PAN) allows devices to exchange data over short distances. PAN combines devices
such as mice, keyboards, printers, smartphones, tablets, etc. The most common connection technology is
Bluetooth. Bluetooth can give a range of upto 10metres.
LAN
A Local Area Network (LAN) is a computer network that, as a rule, covers a small area, located in one or
morebuildings
The term "local" in this context refers to joint local management (does not mean the mandatory physical
proximity of components to each other). A local network can be a home network, a combination of
computers and other devices of a small office or a large enterprise
91
Wired connections are widely used in LAN, most of which are made using copper wires, and some are fiber—
optic. Usually, wired networks operate at speeds from 100 Mbit/s to 1 Gbit/s. More modern LAN can operate at
a speed of 10 Gbit/s. The most common wired connection standard is the IEEE 802.3 standard, commonly
referred to asEthernet.
In local area networks, along with wired technologies, wireless connections according to the IEEE 802.11
standard,better known as Wi-Fi, are widely used.
Wireless Wi-Fi networks operate at speeds from several to hundreds of megabits per second.
The size of LAN networks ranges from 10metres to 1
KmMAN
Metropolitan area network(MAN) unite computers within a city. As an example, we can consider a cable
television
system in which it became possible to transmit digital data and, over time, the system turned into a
computernetwork.
10Km.WAN
The Wide Area Network(WAN) covers significant territories, connects local networks that can be located
in
geographically remote areas. A global network is similar to a large wired local area network, but there are
importantdifferences:
management of local networks and provision of access to the inter-network data transmission environment is
carried out by various organizations;
with the help of communication channels, individual computers can communicate with local networks, or entire
networks.
The Internet can be considered as a WAN. A WAN ranges from 100km to 10000km.
Network devices
We cannot always make sure that there is a dedicated connection from one computer to another one
in a computer network. Further the data travels over the telephone network. Hence there arises the
92
need for different types of devices in computer networks. Network devices provide transportation of
data that needs to be transferred between end-user devices. They extend and combine cable
connections, convert data from one format to another, and control data transmission. Examples of
devices that perform these functions are repeaters, hubs, switches, and routers.
A network adapter is a printed circuit board that is inserted into a slot on the motherboard of a
computer, or an external device. Each NIC adapter has a unique code called a MAC address. This
address is used to organize the operation of these devices on the network.
Repeater
Repeaters are network devices operating at the first (physical) level of the OSI reference model. As the
data leaves the sender's device and enters the network, they are converted into electrical or light pulses,
which are then transmitted over the network transmission medium. Such pulses are called signals.
When the signals leave the transmitting station, they are clear and easily recognizable. However, the
longer the cable length, the weaker and less distinguishable the signal becomes as it passes through
the network transmission medium. The purpose of using a repeater is to regenerate and resynchronize
network signals, which allows them to be transmitted over a longer distance through the medium.
Hub
Hub is a network device used to combine devices. The hub can have from 8 to 32 ports for connecting
computers. All the information that comes to the connector of one port will be copied automatically and
sent to ALL other ports. The simplest hub is a multiport repeater.
Router
A router is a network device that facilitates and establishes a connection between a local network and
the Internet by transmitting information to and from packet-switched networks. It performs this function
by analyzing the data packet header, which contains the IP address of the packet destination. Based
on the data packet, the router determines the most efficient route to the destination address. Simply
put, a router routes information between connected networks.
The router is physically connected to the modem and other devices. The router creates a private
network by receiving data from the Internet from the modem, which is connected via cable, DSL or other
wired connection from an Internet service provider. Routers have several ports from which you can
connect to devices to distribute Internet connectivity. By means of communication between modems
and devices in the local network, the router facilitates communication with the Internet and within the
network. The router provides connectivity at the network level of the system and thus functions at the
third level of the OSI model.
93
Working of a Router
This device also performs the functions of the Dynamic Host Configuration Protocol (DHCP), distributing
private IP addresses between devices connected to the network. Routers for home or office have a
private or local address obtained from a reserved range of IP addresses. Devices on the network can
have the same private IP address as devices in the neighbouring house. This is not a problem, since
the devices are separately connected to different routers with a specific public IP address. Thus, the
private IP address functions only so that the router can identify the device.
Gateway
A gateway is considered as a network device that acts as an entry point from one network to another.
The main task of a network gateway is to convert protocol(rules for communicaiton over the data
network) between networks. A network gateway can accept a packet formatted for one protocol (for
example, Apple Talk) and convert it into a packet of another protocol (for example, TCP/IP) before
sending it to another network segment. Network gateways can be a hardware solution, software, or
both, but usually it is software installed on a router or computer. The network gateway must understand
all the protocols used by the router.
Switch
A switch is used to connect computers, laptops and other devices to a shared local network. For example, take a
large company with dozens and hundreds of employees. There is a marketing department, a sales department,
financiers, a director. They need to exchange information, use common tables and programs.Doing this via the
Internet is inconvenient and dangerous (if we talk about observing trade secrets). It is better to combine
working computers into a common closed network, where there is no access tooutsiders. For large video
surveillance systems, switches are also needed. Switches are also used at home.
Switch is also a network device used to connect multiple devices together like Hub. But the difference
between the hub and switch is that hub forward the received messages to all the connecting devices
and switch forward the message to the intended device only. So switch is known as the intelligent
device.
94
Modem modulator / demodulator
A modem is a device that converts a digital signal into an analog signal and vice versa.
The modem connects the user's computer or laptop to the Internet. It works in two
directions at once:
Receives a digital signal from a PC, converts it to analog (in the form of a
wave)and transmits the request to the servers storing the necessary
information;
Receives the response to the sent request in analog form, converts it to digital
andtransmits it to the PC
Nowadays the router and modem are combined together in a single device. The device is called a
router.
To transmit data in local and global networks, the sending device must know the address of the receiving
device. Therefore, each network computer has a unique address, and not one, but as many as three
addresses: physical or hardware (MAC address); network (IP address); symbolic (regular computer
name or full domain name).
95
Physical address of the computer
The physical (hardware) address of the computer depends on the technology with which the network is
built. In Ethernet networks, this is the MAC address of the network adapter. The MAC address is hard-
wired into the network card by its manufacturer and is usually written as 12 hexadecimal digits (for
example, 00-03-BC-12-5D-4E).
This is guaranteed to be a unique address: the first six characters identify the manufacturer, which
ensuresthat the remaining six characters are not repeated on the production line. The MAC address is
selected by the network equipment manufacturer from the address space allocated for it under the
license. When a machine's network adapter is replaced, its MAC address also changes.
You can find out the MAC address of your computer's network card as follows:
1. Go to "Start” – “Run” - enter the command cmd – “OK” from the keyboard.
2. Enter the ipconfig /all command and press Enter.
This command allows you to get complete information about all PC network cards. Therefore, find
the Physical address line in this window – it will indicate the MAC address of your network card.
The network address or IP address is used in TCP/IP networks when exchanging data at the network
level. IP stands for Internet Protocol . The computer's IP address is 32 bits long and consists of four
parts called octets. Each octet can take values from 0 to 255 (for example, 90.188.125.200). Octets are
separated from each other by dots.
The IP address of a computer, for example 192.168.1.10, consists of two parts – the network
number (sometimes called the network identifier) and the network computer number (host identifier). The
network number must be the same for all computers on the network and in our example the network
number will be 192.168.1. The computer number must be unique in this network, and the computer in
our example has the number 10.
The IP addresses of computers on different networks may have the same numbers. For example,
computers with IP addresses 192.168.1.10 and 192.168.15.10, although they have the same numbers
(10), but belong to different networks (1 and 15). Since the network addresses are different, computers
cannot be confused with each other.
The IP addresses of computers on the same network should not be repeated. For example, it is
unacceptable to use the same addresses 192.168.1.20 and 192.168.1.20 for two computers on your
local network. This will lead to their conflict. If you turn on one of these computers earlier, when you
turn on the second computer, you will see a message about an erroneous IP address:conflict of IP
addresses with another system on the net in this case, just change the address on one of the computers.
To separate the network number from the computer number, a subnet mask is used. Outwardly, the
subnet mask is the same set of four octets separated by dots. But, as a rule, most of the digits in it are
255 and 0.
If your computer is connected to a local network or the Internet, you can find out its IP address and
subnet mask in a way that is already familiar to us:
1. Go to "Start” – “Run" - type cmd and click OK.
96
2. In the window that opens, enter the ipconfig /all command and press Enter.
You will see the computer's IP address and subnet mask in the corresponding lines:
Internal IP addresses are reserved for local networks (they cannot be accessed via the Internet
without special software) from the ranges:
192.168.0.1 – 192.168.254.254
10.0.0.1 – 10.254.254.254
172.16.0.1 – 172.31.254.254
From these ranges, you, as a system administrator, will assign addresses to computers in your local
network. If you "rigidly" fix the IP address in the computer settings, then such an address will be called
static – it is a permanent, unchangeable IP address of the PC.
There is another type of IP addresses – dynamic, which change every time a computer enters the
network. The DHCP service is responsible for managing the dynamic address allocation process.
In addition to physical and network addresses, a computer can also have a symbolic address – the name
of the computer. The computer name is a more convenient and understandable designation for a
computer on the network.
Questions:
1. The length of a network segment in a LAN network is more than 100meteres. Select the device
to beconnected to maintain the strength of signal:
a. Switch
b. Router
c. Gateway
d. Repeater
2. Select the device that helps to transfer the digital signals to be transferred over telephone lines:
a. Switch
b. Modem
c. Gateway
d. Repeater
Solutions:
1. d. Repeater – The repeater amplifies the input signal to make up the loss in strength.
2. b. Modem – Modulator-Demodulator converts digital signal to anlog and vice-versa.
3. d. Hub -
4. c. Router
5. a. Switch
6. c. Gateway
7. c. RJ – 45 . RJ stands for Registered Jack.
8. The hub receives network data on one port and simply send information to all
devicesConnected to it. Such data transmission has disadvantages:
a. Heavy load on the network (data is sent to all computers on the
network at once);
b. A large number of errors, especially when new computers appear;
c. It is impossible to separate the flows of information, to send it in a targeted manner.
9.A gateway is a network device that allows a network to communicate with another network with other
protocols (rules for communication). Gateways act as a network point that acts as an entrance to another
network. A router connects two or more data lines, so when a packet arrives through one line, the router
98
reads the packet address information and determines the correct
destination. These days, routers are mostly available with built-in gateway systems, making it easier for
users who don't need to buyseparate systems.
10.Switch forward the message to the intended user only. It does not use the broadcast technology
Networking Topologies:
Topologies: The arrangement of computers and other peripherals in a network is called its topology.
Common network topologies are bus, star mesh, and tree
Bus Topology
In bus topology all the nodes are connected to a main cable called backbone. If any node has to send some
information to any other node, it sends the signal to the backbone. The signal travels through the entire length of
the backbone and is received by the node for which it is intended. A small device called terminator is attached at
each end of the backbone. When the signal reaches the end of backbone, it is absorbed by the terminator and the
backbone gets free to carry another signal.
Star Topology:
In star topology each node is directly connected to a hub/switch. Star topology generally requires more
cable than bus topology.
99
networks. All the stars are connected together like a bus.
Mesh Topology :
In this networking topology, each communicating device is connected with every other device in the
network. To build a fully connected mesh topology of n nodes, requires n(n-1)/2 wires.
BUS STAR
TREE MESH
100
Introduction to Internet:
The Internet 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. In addition, it
consists of networking devices such as routers, switches, gateways, etc. Today, smart electronic applianceslike
TV, AC, refrigerator, fan, light, etc., can also communicate through the Internet.
Applications of Internet
• The World Wide Web (WWW)
• Electronic mail (Email)
• Chat
• Voice Over Internet Protocol (VoIP)
The World Wide Web (WWW): The World Wide Web (WWW) or web in is information stored in
interlinked web pages and web resources. The resources on the web can be shared or accessed through the
Internet.Three fundamental technologies HTML,URL and HTTP leads to creation of web.
URL : A Uniform Resource Locator (URL) is a standard naming convention used for accessing resources over the
Internet. URL is sometimes also called a web address. In below URL, http is the protocol name, it can be
https, http, FTP, Telnet, etc. www is a sub domain. ncert.nic.in is the domain name
Electronic mail (Email) : Electronic mail is a means of sending and receiving message(s) through
the Internet. The message can be either text entered directly onto the email application or an attached file
(text, image audio, video, etc.) stored on a secondary storage. To use email service, one needs to register
with an email serviceprovider by creating a mail account.
Chat : Chatting or Instant Messaging (IM) is communicating in real time using text message(s).
Voice Over Internet Protocol (VoIP): Voice over Internet Protocol (VoIP) allows you to have
voicecalls over digital networks.
Points To Rember :
In Bus topology Nodes connected using single wire, cost effective, easy to install and fault
diagnoseis difficult.
In star topology each Nodes is directly connected to hub/switch easy to install, expensive and
easyto diagnose faults.
Tree is combination of star and bus.
101
Mesh topology each device is connected to every other device. No centralized
device, andexpensive
WWW (World Wide Web )where documents and other web resources are identified by
UniformResource Locator.
URL is a reference to a web resource that specifies its location on a computer network
and amechanism for retrieving it.
Chat is real time texting.
VoIP allows voice calls.
Questions:
1. Physical arrangement of computers in a network is called network is called .
2. In topology all the nodes are connected to a single cable.
3. Network topology in which you connect each node to the network along a single piece of
cable iscalled
4. In Topology, a dedicated link connects device to central controller
5. In Star topology if central hub fails, it effects
a. No effects b. Entire system c. Particular Node
6. Which of the following topologies is a combination of more than one topologies?
a. Bus b. Tree c. Star d. None of these
7. Identify the type of topology from the following:
a) Each node is connected with the help of a single cable.
b) Each node is connected with central switching through independent cables.
8. Illustrate the layout for connecting 5 computers in a Bus and a Star topology of Networks.
9. Identify valid URL from the following
a. http://www.cbse.nic.in/welcome.htm, b . www.cbse.nic.in/ http://welcome.htmc . http://
welcome.htm
10. Identify the protocol from the following .http://www.cbse.nic.in/welcome.htm
11. Guru wants to send a report on his trip to the North East to his mentor. The report contains images and
videos. How can he accomplish his task through the Internet?
12. URL stands for
13. VoIP stands for
14. Name the protocol allows to have the voice call over the Internet
15. Which of the following will you suggest to establish the real-time textual communication
between thepeople.
a. E-mail
b. Video Conferencing
c. Chatting
d. Real time communication is not possible
Answers:
1. Topology
2. Bus.
3. Bus
4. Star
5. Entire system
102
6. Tree
7. (a). BUS (b). Star
8.
9. http://www.cbse.nic.in/welcome.htm
10. http
11. E-mail
12. Uniform Resource locator
13. Voice over Internet Protocol
14. VoIP
15. Chatting
Website:-
Website is a group of web pages, containing text, images and all types of multi-
mediafiles
Difference between Website and Webpage
Website WebPage
A collection of web pages which A document which can be displayed
are grouped together and usually in a web browser such as Firefox,
connected together in various Google Chrome, Opera, Microsoft
ways, Often called a "web site" or Internet Explorer etc
simply a "site. Result web page of CBSE
Eg: CBSE website
Contains information about Contents information about single
various topics topic
Web Site address doesn’t depend Depends upon web page address
upon webpage address
Development time is more Less Development time required
Web Hosting :-
Web hosting is an online service that enables you to publish your website or web
application on the internet. When you sign up for a hosting service, you basically
rent some space on a server on which you can store all the files and data necessary
for your website to work properly. A server is a physical computer that runs without
anyinterruption so that your website is available all the time for anyone who wants
to see it
Web Browser :- A web browser, or simply "browser," is an application used to
access and view websites. Common web browsers include Microsoft Internet
Explorer, Google Chrome, Mozilla Firefox, and Apple Safari.
Add-ons( in terms of Hardware): An Add-on is either a hardware unit that can be
added to a computer to increase the capabilities or a program unit that enhances
primary program. Some manufacturers and software developers use the term add-
on. Examples of add-ons for a computer include card for sound, graphic acceleration,
modem capability and memory. Software add- on are common for games,
wordprocessing and accounting programs
Plug-ins:- a plug-in (or plugin, add-in, add-on) is a software component that adds a
specific feature to an existing computer program. When a program supports plug-
104
ins, it enables customization. Plug-ins are commonly used in Internet browsers but
alsocan be utilized in numerous other types of applications
Cookies :- cookies are small files which are stored on a user’s computer and contains
information like which Web pages visited in the past, logging details Password etc.
They are designed to hold a small amount of data specific to a particular client and
website and can be accessed by the web server or the client computer
2. The first page that we normally view at a website is called (a)Home page
(b)Webpage (c) Webserver (d)Email
5. Which of the following button allows you to move to the previously visited
page onthe browser?
a) Back (B)Previous (c) Last (d)Reverse
6. Which of the following is peace of information stored in a form of a text file and
thathelps in customizing the displayed information, login, showing data based
on user’sinterests from the web site?
(a) Extension (b) Cookies (c)Login (d)Session
10. The first page on the website that allows you to navigate to other pages by
menusor links is known as
(a) front page (b)primary page (c)Home page (d)
Answers
Multiple choice questions:
1.a. 2.a 3. c 4 .c 5.a 6.b 7c 8.c 9,b 10.c
Fill in the blanks:
1. Website 2.Web server 3.Web pages 4.HTML and scripting
languages 5.WebHosting
Website:-
Website is a group of web pages, containing text, images and all types of multi-mediafiles.
Some examples of websites:
Google.com
cbse.nic.in
Amazon.com
Wikipedia.org
Website WebPage
A collection of web pages which are A document which can be displayed in a
grouped together and usually connected web browser such as Firefox, Google
together in various ways, Often called a Chrome, Opera, Microsoft Internet Explorer
"web site" or simply a "site. etc
Eg: CBSE website Eg: Result web page of CBSE
A webpage is commonly written in HTML
108
Difference between Static and Dynamic webpage
Web Server :-
A web server is a computer that stores web server software and a website's component files
(e.g. HTML documents, images, CSS style sheets, and JavaScript files). When client sends
request for a web page, the web server search for the requested page. If requested page is
found then it will send it to client with an HTTP response, if the requested web page is not
found, web server will the send an HTTP response: Error 404 Not found.
Web Hosting :-
Web hosting is an online service that enables you to publish your website or web application
on the internet. When you sign up for a hosting service, you basically rent some space on a
server on which you can store all the files and data necessary for your website to work properly.
A server is a physical computer that runs without any interruption so that your website is
available all the time for anyone who wants to see it.
Web Browser: - A web browser, or simply "browser," is an application used to access and
view websites. Common web browsers include Microsoft Internet Explorer, Google Chrome,
Mozilla Firefox, Opera and Apple Safari.
Add-ons (in terms of Hardware): An Add-on is either a hardware unit that can be added to a
computer to increase the capabilities or a program unit that enhances primary program. Some
109
manufacturers and software developers use the term add-on. Examples of add-ons for a
computer include card for sound, graphic acceleration, modem capability and memory.
Software add- on are common for games, wordprocessing and accounting programs. Software
add-ons will integrate to the browser and it only run when the browser runs.
Plug-ins: - a plug-in (or plugin, add-in, add-on) is a software component that adds a specific
feature to an existing computer program. When a program supports plug-ins, it enables
customization. Plug-ins are commonly used in Internet browsers but also can be utilized in
numerous other types of applications. An example of a plugin is the free Macromedia Flash
Player, a plugin that allows the web browser to display animations using the Flash format.
Note: Plug-in is a complete program where add-on is not a complete program.
Cookies: - cookies are small text files which are stored on a user’s computer and contain
information like which Web pages visited in the past, logging details Password etc. They are
designed to hold a small amount of data specific to a particular client and website and can be
accessed by the web server or the client computer.
1. A website is a collection of
(b) HTML documents (b) Graphic files (c)Audio and video files (d)All of the above
2. The first page that we normally view at a website is called (a)Home page
(b)Webpage (c) Webserver (d)Email
5. Which of the following button allows you to move to the previously visited page onthe
browser?
(d) Back (B)Previous (c) Last (d)Reverse
6. Which of the following is peace of information stored in a form of a text file and that helps in
customizing the displayed information, login, showing data based on user’s interests from
the web site?
(e) Extension (b) Cookies (c)Login (d)Session
10. The first page on the website that allows you to navigate to other pages by menus or links
is known as
(i) front page (b)primary page (c)Home page (d) None
Fill in the blanks questions:-
1. A is a collection of web pages written using HTML___________
2. A computer on which the website is hosted and it is connected to the internet all time
is known as .
3. The of a website are linked together with different hyperlinks and share a
common interface and design.
4. An interactive web page is created through
5. The space provided by a service provider to store website data is called ______
6. The ____________ is an application program that is used to view the web pages.
Answers
Multiple choice questions:
1.a. 2.a 3. d 4 .c 5.a 6.b 7c 8.c 9.b 10.c
Fill in the blanks:
1. Website 2.Web server 3.Web pages 4.HTML and scripting languages
5. WebHosting 6. Web browser
Descriptive Questions and answers:-
5. Differentiate between web browser and web server Web Server-
A web server is a computer that stores web server software and a website's
component files (e.g. HTML documents, images, CSS style sheets, and JavaScript
files). When client sends request for a web page, the web server search for the
requested page if requested page is found then it will send it to client with an HTTP
response. If the requested web page is not found, web server will the send an HTTP
response
: Error 404 Not found.
Web Browser:-
A web browser, or simply "browser," is an application used to access and view
websites. Common web browsers include Microsoft Internet Explorer, Google Chrome,
Mozilla Firefox, and Apple Safari
6. Differentiate between web page and home page?
111
Web page:- A document created usually using HTML and resides on a
website is called webpage
Home page:-It is the first page that gets displayed when we open a website
7. Differentiate between dynamic and static webpages?
Static webpage content is The page content changes
constant in all time according to the user.
Loading time is less Loading time is more
No database is used A database is used in the server side
Content changes rarely Content changes frequently
8. Write the steps to host a website:;
Following steps needs to followed to host a website:
112
Index
UNIT 4
SOCIETAL IMPACTS
● 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.
● E-waste: hazards and management. Awareness about health concerns related to the usage of
technology.
DIGITAL FOOTPRINT
A digital footprint – refers to the trail of data you leave while using the internet. It includes websites
you visit, emails you send, and information you submit online. A digital footprint can be used to
track a person’s online activities and devices.
Internet users create their digital footprint either actively or passively. 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
Online shopping
● Making purchases from e-commerce websites
Online banking
● Using a mobile banking app
Social media
● Using social media on your computer or devices
● Sharing information, data, and photos with your connections
Reading the news
● Subscribing to an online news source
Health and fitness
● Using fitness trackers
● Using apps to receive healthcare
NETIQUETTE
It is the abbreviation of Internet etiquette or network etiquette, refers to online manners while
using internet or working online. While online you should be courteous, truthful and respectful of
others. It includes proper manners for sending e-mail, conversing online, and so on.
113
Some basic rules of netiquette are:
● Be respectful
● Think about who can see what you have shared.
● Read first, then ask
● Pay attention to grammar and punctuation
● Respect the privacy of others
● Do not give out personal information
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 Privacy v/s Data Protection
For data privacy, users can often control how much of their data is shared and with whom. For
data protection, it is up to the companies handling data to ensure that it remains private. Data
privacy is focused on defining who has access to data while data protection focuses on applying
those restrictions.
How we can protect our personal data online
● Through Encrypt our Data
● Keep Passwords Private
● Don't Overshare on Social Networking Sites
● Use Security Software
● Avoid Phishing Emails
● Be Wise About Wi-Fi
● Be Alert to Impersonators
● Safely Dispose of Personal Information
Intellectual Property (IP) – is a property 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.
Examples of Intellectual Property :- 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 Right (IPR) is the statutory right granted by the Government, to the owner(s)
of the intellectual property or applicant(s) of an intellectual property (IP) to exclude others from
114
exploiting the IP commercially for a given period of time, in lieu of the discloser of his/her IP in an
IPR application.
PLAGIARISM
Plagiarism It is stealing someone’s intellectual work and representing it as your own work without
citing the source of information.
Any of the following acts would be termed as Plagiarism:
● Using some other author’s work without giving credit to the author
● Using someone else’s work in incorrect form than intended originally by the author or
creator.
● Modifying /lifting someone’s production such as music composition etc. without attributing
it to the creator of the work.
● Giving incorrect source of information.
Licenses are the permissions given to use a product or someone’s creation by the copyright
holder.
Copyright is a legal term to describe the rights of the creator of an original creative work such as
a literary work, an artistic work, a design, song, movie or software etc.
OSS refers to Open Source Software, which refers to software whose source code is available to
customers and it can be modified and redistributed without any limitation.
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 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.
115
CYBER CRIME
Any criminal or illegal activity through an electric channel or through any computer network is
considered as cyber crime.
Eg: Cyber harassment and stalking, distribution of child pornography,types of spoofing, credit card
fraud ,. etc
CYBER LAW
It is the law governing cyberspace which includes freedom of expression, access to and usage of
internet and online privacy.
The issues addressed by cyber law include cybercrime, e-commerce, IPR and Data protection.
HACKING:
It is an act of unauthorised access to a computer, computer network or any digital system.
Hackers usually are technical expertise of hardware and software.
● Hacking when done with a positive intent is called as Ethical hacking or White hat.
● Hacking when done with a negative intent is called as Unethical hacking or Black hat.
PHISHING:
It is an unlawful activity where fake websites or emails appear as original or authentic .This sites
when clicked by the user will collect sensitive and personal details like usernames, password,
credit card details etc.
CYBER BULLYING:
It is the use of technology to harass , threaten or humiliate a target .
Example: sharing of embarrassing photos or videos, posting false information, sending mean
text., etc.
116
ABOUT HEALTH CONCERNS RELATED TO THE USE OF TECHNOLOGY:
There are positive as well as negative impact on health due to the use of these technologies.
● POSITIVE IMPACT
▪ Various health apps and gadgets are available to monitor and alert
▪ Online medical records can be maintained
● NEGATIVE IMPACT
▪ One may come across various health issues like eye strain, muscle problems, sleep
issues,etc
▪ Anti social behaviour, isolation, emotional issues, etc.
1. Online posting of rumours, giving threats online, posting the victim’s personal information,
comments aimed to publicly ridicule a victim is termed as __________
a. Cyber bullying
b. Cyber crime
c. Cyber insult
d. All of the above
2. Ankit made a ERP - Enterprise resource planning solution for a renowned university and
registered and Copyrights for the same. Which of the most important option; Ankit got the
copyrights.
a) To get society status
b) To get fame
c) To get community welfare
d) To secure finance protection
117
3. Which of the following is not an example of Social media platform?
a. Facebook
b. Pinterest
c. Google+
d. Social channel
5. A ___________ 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.
a. Cyber crime
b. Computer virus
c. Program
d. Software
7. You are planning to go for a vacation. You surfed the internet to get answers for following
queries.
a) Places to visit
b) Availability of air tickets and fares
c) Best hotel deals
d) All of these
Which of the above-mentioned actions might have created a digital footprint?
8. Legal term to describe the rights of a creator of original creative or artistic work is called……..
a) Copyright
b) Copyleft
c) GPL
d) BSD
10. _____________ includes any visual symbol, word, name, design, slogan, label, etc., that
distinguishes the brand from other brands.
a) Trademark
b) Patent
c) Copyright
d) None of the above
11. Gaining unauthorised access to a network or computer aur digital files with malicious
intentions, is
called_________
a. Cracking
b. Hacking
c. Banging
d. Phishing
12. Legal term to describe the rights of a creator of original creative or artistic work is called
_____
a. Copyright
b. Copyleft
c. GPL
d. None of these
14.Any fraudulent business practice that extracts money e from an unsuspecting, ignorant
person is called_______
a. Stealing
b. Scam
c. Violation of copyright
d. Digital footprint
16.Any work / information that exist in digital form idea on internet or on an electronic device, is
known as________________ property.
a. Licence property
b. digital property
c. source code property
d. software property
19. The original code written by programmers for a software is known as______________
a. Object code
b. Source code
c. Python code
d. Language code
23.The ________ the are the permissions given to use a product or someone's creator by the
copyright holder.
a. Source code
b. Licence
c. Software authority
d. Digital rights
30.The generally recognized term for the government protection afforded to intellectual property
written
and electronic is called _____________
a. Computer security law.
b. Aggregate information.
c. Copyright law
d. Data security standards.
33.What is the name of the IT law that India is having in the Indian legislature?
a. India's Technology IT Act 2000
b. India's Digital information technology DIT Act, 2000
c. India's Information Technology IT Act, 2000
d. The technology act, 2008.
35.Every activity you perform on the internet is safe for how long?
a. 1 month
b. 1 year
c. As per my setting
d. Forever
36.A _____________ is an injury or disorder of muscles, nerves, tendons, ligaments and joints.
a. Repetitive Strain injury
b. Muscle injury
c. Nervous breakdown
122
d. Joint pain
.
37.________________ is a technology related health condition affecting eyesight.
a. Computer vision strain
b. Computer vision syndrome
c. Eyesight syndrome
d. Vision imbalance
2. Rishika found a crumpled paper under her desk. She picked it up and opened it. It contained
some text which was struck off thrice. But she could still figure out easily that the struck off text
was the email ID and password of Garvit, her classmate. What is ethically correct for Rishika to
do?
a) Inform Garvit so that he may change his password.
b) Give the password of Garvit’s email ID to all other classmates.
c) Use Garvit’s password to access his account.
3. Suhana is down with fever. So, she decided not to go to school tomorrow. Next day, in the
evening she called up her classmate, Shaurya and enquired about the computer class. She also
requested him to explain the concept. Shaurya said, “Mam taught us how to use tuples in
python”. Further, he generously said, “Give me some time, I will email you the material which will
help you to understand tuples in python”.
Shaurya quickly downloaded a 2-minute clip from the Internet explaining the concept of tuples in
python. Using video editor, he added the text “Prepared by Shaurya” in the downloaded video
clip. Then, he emailed the modified video clip to Suhana. This act of Shaurya is an example of
—
a) Fair use
b) Hacking
c) Copyright infringement
d) Cyber crime
4. After a fight with your friend, you did the following activities. Which of these activities is not an
example of cyber bullying?
123
a) You sent an email to your friend with a message saying that “I am sorry”.
b) You sent a threatening message to your friend saying “Do not try to call or talk to me”.
c) You created an embarrassing picture of your friend and uploaded on your account on a social
networking site.
5. Sourabh has to prepare a project on “Digital India Initiatives”. He decides to get information
from the Internet. He downloads three web pages (webpage 1, webpage 2,webpage 3)
containing information on Digital India Initiatives. Which of the following steps taken by Sourabh
is an example of plagiarism or copyright
infringement?
a) He read a paragraph on “Digital India Initiatives” from webpage 1 and rephrased it in his own
words. He finally pasted the rephrased paragraph in his project.
b) He downloaded three images of “Digital India Initiatives” from webpage 2. He made a collage
for his project using these images.
c) He downloaded “Digital India Initiative” icon from web page 3 and pasted it on the front page
of his project report.
6. Neerja is a student of Class XI. She has opted for Computer Science. Neerja prepared the
project assigned to her. She mailed it to her teacher. The snapshot of that email is shown below.
Find out which of the following email etiquettes are missing in it.
a) Subject of the mail
b) Formal greeting
c) Self-explanatory terms
d) Identity of the sender
e) Regards
7. You are planning to go on a vacation to Kashmir. You surfed the internet for the following:
i) Weather conditions
ii) Availabilty of air tickets and fares
iii) Places to visit
124
iv) Best hotel deals
Which of the above mentioned acts might have left a digital footprint?
a) i and ii
b) i, ii and iii
c) i, ii and iv
d) all of these
8. Naveen received an email warning him of closure of his bank accounts if he did not update
his banking information as soon as possible. He clicked the link in the email and entered his
banking information. Next he got to know that he was duped.
ii) Someone steals Naveen’s personal information to commit theft or fraud, it is called
____________
a. Online Fraud
b. Identity Theft
c. Phishing
d. Plagarism
iv) Naveen’s Online personal account, personal website are the examples of?
a. Digital wallet
b. Digital property
c. Digital certificate
d. Digital signature
v) Sending mean texts, posting false information about a person online, or sharing embarrassing
photos or videos to harass, threaten or humiliate a target person, is called ____________
a. Eavesdropping
b. cyberbullying
c. Spamming
d. Phishing
125
9. Prathyush has to prepare a project on “Cyber Jaagrookta Diwas”.He decides to get
information from the Internet. He downloads three web pages (webpage1, webpage 2, webpage
3) containing information on the given topic.
1. He read a paragraph from webpage 1 and rephrased it in his own words. He
finally pasted the rephrased paragraph in his project. And he put a citation about the website he
visited and its web address also.
2. He downloaded three images of from webpage 2. He made a collage for his
project using these images.
3. He also downloaded an icon from web page 3 and pasted it on the front page of
his project report.
(iv) ______is a small piece of data sent from a website and stored in a user’s web browser while
a user is browsing a website.
(a) Hyperlinks
(b) Web pages
(c) Browsers
(d) Cookies
(v) The process of getting web pages, images and files from a web server to local computer is
called
(a) FTP
(b) Uploading
(c) Downloading
(d) Remote access
126
ANSWERS
The continuous use of devices like smartphones, computer desktop, laptops, head phones etc
cause a lot of health hazards if not addressed. These are:
A. Impact on bones and joints: wrong posture or long hours of sitting in an uncomfortable
position can cause muscle or bone injury.
B. Impact on hearing: using headphones or earphones for a prolonged time and on high
volume can cause hearing problems and in severe cases hearing impairments.
C. Impact on eyes: This is the most common form of health hazard as prolonged hours of
screen time can lead to extreme strain in the eyes.
D. Sleep problem: Bright light from computer devices block a hormone called melatonin which
helps us sleep. Thus we can experience sleep disorders leading to short sleep cycles.
2. 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?
127
call this type of activity as Digital Footprints
Risk involved : It includes websites we visit emails we send, and any information we submit
online, etc., along with the computer’s IP address, location, and other device specific details.
Such data could be used for targeted advertisement or could also be misused or exploited.
3. What We do you mean by Identity theft? Explain with the help of an example.
Identity theft is the crime of obtaining the personal or financial information of another person for
the sole purpose of assuming that person's name or identity to make transactions or use it to
post inappropriate remarks , comments etc.
Example:
Alex likes to do his homework late at night. He uses the Internet a lot and also sends useful data
through email to many of his friends. One Day he forgot to sign out from his email
account. In the morning, his twin brother, Flex started using the computer. He used Flex’s email
account to send inappropriate messages to his contacts
4. What do you understand by Net Ettiquetes? Explain any two such ettiquetes.
Net Ettiquets refers to the proper manners and behaviour we need to exhibit while being online.
These include :
1. No copyright violation: we should not use copyrighted materials without the permission of the
creator or owner. We should give proper credit to owners/creators of open source content when
using them.
2. Avoid cyber bullying: Avoid any insulting, degradingor intimidating online behaviour like
repeated posting of rumours, giving threats online,posting the victim’s personal information, or
comments aimed to publicly ridicule a victim.
5. 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 some methods to manage e-waste .
128
SAMPLE QUESTION
PAPERS
Index
129
Index
(SQP SET I)
KENDRIYA VIDYALAYA SANGATHAN, ERNAKULAM REGION
INFORMATICS PRACTICES (065)
SAMPLE QUESTION PAPER - Class XII
Max Marks: 70 Time: 3 hrs
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35
against part c only.
8. All programming questions are to be answered using Python Language only.
SECTION A
1 Beauty Lines Fashion Inc. is a fashion company with design unit and market unit 135 m 1
away from each other. The company recently connected their LANs using Ethernet
cable to share the stock related information. But after joining their LANs, they are not
able to share the information due to loss of signal in between. Which device out of the
following should you suggest to be installed for a smooth communication?
i. Repeater
ii. Hub
iii. Bridge
iv. Switch
2 Which of the following is a type of cybercrime? 1
i. Stealing of money from a purse
ii. Hitting or beating someone
iii. Making damage to furniture in classroom
iv. Stealing of user name and password and misusing others Email
3 What is not an example of e-waste? 1
i. Unused Mobile
ii. Unused old Keyboard
iii. Unused old computers
iv. Empty cola cans
4 Find the output of the following SQL command: 1
select mid(‘Informatics Practices’, -9);
5 If a column “Mark” in student table contains the following data 1
MARK
22
130
NULL
21
23
131
iv. All of these
13 _____________protocol allows us to have voice call (telephone service) over the 1
Internet
14 Write the output of the following SQL command: 1
SELECT ROUND(199.2936, 1);
15 Removal of parts containing the valuable items in E waste management is? 1
i. Refurbishment and reuse
ii Dismantling
iii Recycling
iv None of these
16 ------------------is the trail of data we leave behind when we visit any website (or use 1
any online application or portal) to fill-in data or perform any transaction.
i. Offline phishing
ii. Offline footprint
iii. Digital footprint
iv. Digital phishing
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
17 Assertion (A): - The Internet is a collection of interconnected computer networks 1
linked by transmission medium such as copper wires, fiber-optic cables, wireless
connections etc
22 Consider a given Series ,S1 with subject and marks where subject is index. 2
Subject Marks
ENG 76
132
HINDI 88
MATH 60
SCI 85
SST 81
Write a program in Python Pandas to create the series.
23 Write down different steps of E waste Disposal. 2
OR
Mention any four net etiquettes.
24 What will be the output of the following code: 2
>>>import pandas as pd
>>>A=pd.Series(data=[12,20,5,50])
>>>print(A>10)
25 Carefully observe the following code: 2
import pandas as pd
Sales1={'S1':5000,'S2':8000,'S3':12000,'S4': 18000}
Sales2={'A' :13000,'B':14000,'C':12000}
totSales={1:Sales1,2:Sales2} df=pd.DataFrame(totSales)
print(df)
133
c. Write SQL command to display sports name where the total number of players is
more than 25
27 Write a Python code to create a DataFrame with appropriate column headings from the 3
list given below:
[[101,'Ram',2500],[102,'Ann',5000],[103,'Sam' ,8000],[104,'Manu',4000]]
28 Consider the data frame and answer the questions 3
i)Write python code to display the profit rate of all quarters of Infosys company.
ii) Write python code to display the profit rate of Qtr3 of all companies
iii) Write the output of the python code
print(DF1.iat[1,1])
OR
Differentiate between where and having clause with the help of suitable example
SECTION D
31 Consider the following table STUDENT. Write SQL commands for the following 5
statements.
Rollno Name Dob Class Gender Hobby Fees
1001 BHAVYA 2001-01-02 11 F Painting 100
1002 AARDRA 2002-10-21 1 F Drama 200
1003 AJITH 2004-12-11 80 M Cooking 150
1004 ARJUN 2001-02-22 10 M Cooking 250
1005 KAVYA 2005-10-12 8 F Sports 100
1006 ANAND 2000-02-01 1 M Drama 120
1007 ATHUL 2006-10-11 1
6 M Sports 150
134
1008 NEERAJA 2003-11-21 9 F Sports 100
1009 REHNA 2003-08-07 8 F Painting NULL
1010 VAISAKH 2001-12-11 10 M Cooking 120
a. To display details of all the students in the descending order of their Name.
b. To print the average fee for each hobby
c. To increase the fees of Cooking by 50 Rs
d. To store the fees of hobbies as 100 where fee is not available
e. To display the name of students who were born after ’01-01-2004’
OR
Explain the following functions with examples:
a. SUBSTRING()
b. POWER()
c. DAYNAME()
d. LTRIM()
e. LENGTH()
135
iii. Suggest the placement of the following devices with justification
(a) Repeater
(b) Hub/Switch
iv. The organization is planning to link its front office situated in the city in a hilly
region where cable connection is not feasible, suggest an economic way to connect
it with reasonably high speed?
v. The organisation is planning to link its sale counter situated in various parts of the
same city, which type of network out of LAN, MAN or WAN will be formed?
Justify your answer
33 Write Python code to plot a bar chart as shown below: 5
Days=[1,2,3,4]
Wages in thousands=[40,42,38,44]
SECTION E
34 Consider the given table Result :- 1+1+2
Rollno Name Class DOB Gender City Marks
1 Nanda X 12-10-1998 F Delhi 56
2 Saurabh XI 24-12-1994 M Chennai 45
3 Sanal XII 15-08-2003 M Delhi 66
4 Rekha X 11-09-2004 F Mumbai 81
5 Neha XII 05-06-2006 F Chennai 77
136
i. Write SQL commands to :
ii. Display the minimum and maximum marks obtained by female students
iii. Display different Cities(without repetition) available in table
iv. Display the average mark obtained by students of each city
OR (Option for part iii only)
Display the class wise total of marks obtained by students
137
(SET I)
KENDRIYA VIDYALAYA SANGATHAN, ERNAKULAM REGION
INFORMATICS PRACTICES (065) – MARKING SCHEME
SQP Answer Key - Class XII
Max Marks: 70 Time: 3 hrs
SECTION A
1 i. Repeater 1
1 mark for correct answer
2 iv. Stealing of user name and password and misusing others Email 1
1 mark for correct answer
3 iv. Empty cola cans 1
1 mark for correct answer
4 Practices 1
1 mark for correct answer
5 i. 22 1
1 mark for correct answer
6 ii. Free 1
1 mark for correct answer
7 iii. SELECT * FROM PRODUCT ORDER BY PRICE DESC; 1
1 mark for correct answer
8 i. cardinality 1
1 mark for correct answer
9 iii. ALTER 1
1 mark for correct answer
10 ii. S.Tail(3) 1
1 mark for correct answer
11 iii. import matplotlib.pyplot as plt 1
1 mark for correct answer
12 iv. All of these 1
1 mark for correct answer
13 VoIP 1
14 199.3 1
15 ii. Dismantling 1
1 mark for correct answer
16 iii. Digital footprint 1
1 mark for correct answer
17 ii. Both A and R are true and R is not the correct explanation for A 1
18 i. Both A and R are true and R is the correct explanation for A 1
SECTION B
19 LAN WAN 2
Local Area Network Wide Area Network
Limited to a single organization or Span countries and continents
building
138
Low cost to set up Cost of setting up is comparatively
high
Covers a distance of upto 1KM Distance > 25 KM
1 mark each for correct difference (two differences)
OR
a. Modem is a network device to convert analog signal to digital and vice versa
b. A firewall is a network security device that monitors traffic to or from a
network. It allows or blocks traffic based on a defined set of security rules.
(1 mark for each correct answer)
20 a. SELECT LENGTH(“Happy Holidays”); 2
b. SELECT UPPER(“Happy Holidays” );
OR
SELECT UCASE(“Happy Holidays” );
22 import pandas as pd 2
S1=pd.Series([76,88,60,85,81],index=['ENG','HINDI','MATH','SCI,’SST’])
139
SECTION C
26 a. 3
Coachname
Sardar Singh
Roshan Lal
Rahul Dravid
Chetan Sharma
Deepika Kumari
Limbaram
140
b.
i. data for all -1/2 mark
ii. 6 -1/2 mark
OR
Where clause is used to put conditions on individual rows whereas having clause
is used to put conditions on groups. HAVING is used along with GROUP BY
clause (2 marks for correct answer)
1 mark for suitable example
SECTION D
31 5
a. SELECT * FROM STUDENT ORDER BY NAME DESC;
b. SELECT AVG(FEES), HOBBY FROM STUDENT GROUP BY HOBBY;
c. UPDATE STUDENT SET FEES=FEES+50 WHERE HOBBY=
’Cooking’;
d. UPDATE STUDENT SET FEES=100 WHERE FEES IS NULL;
e. SELECT NAME FROM STUDENT WHERE DOB > ‘2004-01-01’;
(1 mark for each correct query)
OR
a. SUBSTRING()- used to extract a string from a main string
Eg: SELECT SUBSTRING(“Python program”, 2,3) ;
will produce the output “yth”
b. POWER()- find the value of one number raised to another
Eg: SELECT POWER(2,3);
will produce the output 8
c. DAYNAME() – displays the name of day like “MONDAY, TUESDAY
etc”
Eg: SELECT DAYNAME(‘2022-09-29’); will give the output
THURSDAY
d. LTRIM() – displays the string with leading spaces removed
Eg: SELECT LTRIM(“ hello “);
will produce the output “hello “
e. LENGTH()- displays the number of characters in a string
Eg: SELECT LENGTH(“Python Program”);
will display 14
(1 mark for each correct answer)
32 5
i.
Block C
141
ii. Block C, since its having the highest number of computers among the
blocks. According to 80-20 rule, server should be placed in the block with
highest number of computers.
iii.
a. Block C to A, Block C to B, Block C to D – Since the distance
between the blocks is greater than 80m
b. Hub/Switch –should be placed in all the blocks, since the number of
computers in each block is greater than 1
iv. Radio waves
v. MAN , The network formed within a city is MAN
(1 mark for each correct answer)
½ mark for each correct statement Python statement to save the chart:
plt.savefig("aa.jpg")
1 mark for the correct statement
OR
import matplotlib.pyplot as plt Days=[1,2,3,4]
wages=[40,42,38,44]
plt.plot(Days,wages)
plt.show()
142
Index
KENDRIYA VIDYALAYA SANGATHAN ERNAKULAM REGION
INFORMATICSPRACTICES (065)
SAMPLE PAPER (2022 - 23) - Class XII – SET II
Max Marks: 70 Time: 3 hrs
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
6. Section C has 05 Short Answer type questions carrying 03 marks each.
7. Section D has 03 Long Answer type questions carrying 05 marks each.
8. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35
against part C only.
9. All programming questions are to be answered using Python Language only.
Part - A
1 Which of these is not a communication channel? 1
a) Satellite
b) Microwave
c) Radio wave
d) Wi-Fi
4 Given a Pandas series called Marks, the command which will display the 1
last 2 rows is _______.
a. print(Marks.tail(2))
b. print(Marks.Tail(2))
c. print(Marks.tails(3)
d. print(Marks.tail())
143
5 If column “City” contains the data set (CHENNAI, MUMBAI, KOLKATA, CHENNAI, 1
KOLKATA), what will be the output after the execution of the given query?
(a) only (ii) (b) (ii) and (iv) (c) (ii) and (iii) (d) (iii) and (iv)
8 The __________ attribute of a dataframe object returns the row labels of a 1
dataframe.
a. index
b. columns
c. rows
d. column
9 Which of the following is not a network device : 1
a. Repeater
b. hub
c. TCP
d. switch
10 Website stores the browsing activity through _____________________ 1
a. web page
b. Cookies
c. passwords
d. server
11 Which of the following is not an aggregate function ? 1
a. Avg()
b. Trim()
c. Min()
d. Sum()
144
(a) Trademark
(b) Patent
(c) Copyright holder
(d) Plagiarism
13 A Dataframe object is a collection of ______________ type of data 1
a. Homogenous
b. Heterogenous
c. Hybrid
d.None of the above
14 The practice of taking confidential information from you through an original 1
looking site and URL is known as
a. hacking
b. fishing
c. phishing
d. Eavesdropping
15 ‘F’ in FOSS stands for: 1
(a) Free
(b) Forever
(c) Fire
(d) Freezing
16 Unsolicited commercial email is known as _______________ . 1
a. Junk mail
b. Spam
c. Trash
d. Chats
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice
as
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
Part - B
Write an overview of Indian IT Act 2
19 OR
What can be done to reduce the risk of identity theft? Write any two ways.
145
With SQL, how can you return the number of rows not null value in the Project field 2
of Students table
(a) SELECT COUNT(Project) FROM STUDENTS;
20 (b) SELECT COLUMNS(Project) FROM STUDENTS;
(c) SELECT COLUMNS(*) FROM STUDENTS;
(d) SELECT COUNT(*) FROM STUDENTS:
Write a short explanation of your answer query.
What is the difference between the group by and order by clause when
21 2
used along with the select statement? Explain with an example.
Write a program in Python Pandas to create a series which stores marks of
5 subjects of a student in class 10B of your school.
22 2
Assume that student is studying class X and have 75,78,82,82,86 marks
Give any 2 solutions to manage the E-Waste in the country.
23 OR 2
List any two health hazards related to excessive use of technology
What will be the output of the following code:
>>>import pandas as pd
>>>rollno=[1,2,3,4,5,6]
24 2
>>>marks=[23,86,74,11,98,75]
>>>s=pd.Series(marks,index =rollno)
>>>print(s[s>75])
Section C
Ms Malini is working in a school and stores the details of all students in a table
SCHOOLDATA.
TABLE : SCHOOLDATA
26 3
146
Find the ouput :
i. SELECT LENGTH(NAME) FROM SCHOOLDATA WHERE HOUSE=’Red’;
ii. SELECT LEFT (Gender, 1), Name FROM SCHOOLDATA WHERE YEAR
(Dob) = 2005;
iii. SELECT MID(UPPER(NAME),5,4) FROM SCHOOLDATA WHERE
GENDER = ’Male’;
Write a Python code to create a DataFrame with appropriate column headings from
the list given below:
27 [[‘Nidhi’,’Business Studies’,95],[‘Gurjeet’,’Informatics Practices’,97], 3
[‘Pahul’,’Accountancy’,88], [‘Divya’,’English’,72]]
Sutapa received an email from her bank stating that there is a problem with
her account. The email provides instructions and a link, by clicking on
which she can logon to her account and fix the problem.
i. What is this happening to Sutapa?
29 ii. What immediate action should she take to handle it? 3
iii. Is there any law in India to handle such issues? Discuss briefly.
OR
What do you understand by hacking? Why is it a punishable offence? Mention any
two ways to avoid hacking.
Based on table SCHOOL given here, write suitable SQL queries for the following:
CODE TEACHERNAME SUBJECT Category DOJ PDS EXP
1001 RAVI SHANKAR ENGLISH PGT 12/03/2000 24 10
1009 PRIYA RAI PHYSICS TGT 03/09/1998 26 12
1203 LISA ANAND ENGLISH TGT 09/04/2000 27 5
30 1045 YASHRAJ MATHS PGT 24/08/2000 24 15 3
1123 GANAN PHYSICS TGT 16/07/1999 28 3
1167 HARISH B CHEMIST PGT 19/10/1999 27 5
RY
1215 UMESH PHYSICS TGT 11/05/1998 22 16
Resource Main
32 Compound Compound 5
Training Finance
Compound Compound
148
Center to center distances between various Compounds as per architectural
drawings (in Metre) is as follows :
Main Compound to Resource Compound 110 m
Main Compound to Training Compound 115 m
Main Compound to Finance Compound 35 m
Resource Compound to Training Compound 25 m
Resource Compound to Finance Compound 135 m
Training Compound to Finance Compound 100 m
33
149
Write a python program to plot a line chart based on the given data to depict the
changing medal tally between four Houses in school.
SECTION E
Mukund, a database administrator has designed a database for a clothing sports
club. Help him by writing answers of the following questions based on the given
table:
Consider the table SPORTS and give the output for the following queries:
StudentNo Class Name Game Grade
10 7 Sammer Cricket B
11 8 Sujit Tennis A
12 7 Kamal Swimming B 1+1+2
34
13 7 Venna Tennis C
14 9 Archana Basketball A
15 10 Arpit Cricket A
i. Write a query to display Game in lower case.
ii. Write a query to display the lowest class of the sports club.
iii. Write a query to count total number of Games with grade A.
OR (Option for part iii only)
Write a query to count class wise total number of games played
Mr. Ravi, a data analyst has designed the DataFrame df that contains data about
Car Sales with ‘T1’, ‘T2’, ‘T3’, ‘T4’, ‘T5’ as indexes shown below. Answer the
following questions:
150
KENDRIYA VIDYALAYA SANGATHAN ERNAKULAM REGION
CLASS XII - INFORMATICS PRACTICES (065)
SAMPLE PAPER – II MARKING SCHEME
Max Marks: 70 Time: 3 hrs
Q PART – A Marks
No
1. d) Wi-Fi 1
2. c. legend() 1
3. b. 15.8 1
4. a. print(Marks.tail(2)) 1
5. iii. 3 1
6. d. statistical 1
7. (c) (ii) and (iii) 1
8. c)index 1
9. c)TCP 1
10. b)Cookies 1
11. b) Trim() 1
12 a) Trademark 1
13. b)Heterogenous 1
14. c)Phishing 1
15. a) Free 1
16. b) Spam 1
17. i. Both A and R are true and R is the correct explanation for A 1
18. iii. A is True but R is False 1
Section-B
19. The Information Technology Act of 2000 came into force on October 17, 2
2000. This act is imposed upon the whole of India. Its provisions apply to
any offense committed inside or outside India's geographic boundaries
and irrespective of nationality.
The act covers offenses involving computers, computer systems, or
computer networks in India. It also makes acts like hacking, data theft,
spreading of computer viruses, identity theft, defamation (sending offensive
messages), pornography, child pornography, and cyber terrorism criminal
offenses.
151
Or
Always use strong passwords at least eight characters long that have
numbers and special characters (like: $, %, &), and that do not contain a word
found in the dictionary. Change your passwords frequently and never share
them.
Avoid using software downloaded from unknown websites or peer-to-peer file
sharing services. Avoid software that claims to be game, a screensaver,
collect information for "marketing purposes" or promises to "accelerate your
internet connections." These are actuallyprograms that can include spyware.
20. a. SELECT COUNT(Project) FROM STUDENTS; 2
count ignores null values while counting the values in its argument
column
21. 2
Group By Order By
It is used to divide the table into It sorts the result set either in
logical groups ascending or descending order
Logical grouping is done based result-set is sorted based on the
on the similarity among the column's attribute values, either
row's attribute values. ascending or descending order.
Select brand, count(*) Select *
from appliances from appliances
group by Brand order by discount asc;
22. 2
Or
The continuous use of devices like smartphones, computer desktop,
laptops, head phones etc cause a lot of health hazards if not addressed.
These are:
i. Impact on bones and joints: wrong posture or long hours of sitting in
an uncomfortable position can cause muscle or bone injury
152
ii. Impact on hearing: using headphones or earphones for a prolonged
time and on high volume can cause hearing problems and in
severe cases hearing impairments.
iii. Impact on eyes: This is the most common form of health hazard as
prolonged hours of screen time can lead to extreme strain in the
eyes.
iv. Sleep problem: Bright light from computer devices block a hormone
called melatonin which helps us sleep. Thus, we can experience
sleep disorders leading to short sleep cycles
i. 0
1
ii. a b c
Section - C
26. 3
i) LENGTH(NAME)
12
10
12
ii) LEFT (Gender, 1) Name
F Swapnil Pant
M Rahil Arora
iii) MID(UPPER(NAME),5,4)
A DA
SHA
N RA
A SI
S_Id Name
SW01 NULL
SB02 Football
SB03 Hockey
SW04 Swimming
154
2 marks for correct example
SECTION D
31 i. select CURDATE(); 5
ii. select UCASE(‘Kendriya’)
iii. select rtrim( “Good Morning “);
iv. select month(curdate());
v. select power(n1,n2);
OR
i. select stationaryname, ROUND(price) from stationary;
ii. select INSTR(stationaryname, ’en’) from stationary;
iii. select LEFT(stationaryname, 4) from stationary;
iv. select LCASE(company ) from stationary;
select LEN(stationaryname) from stationary;
32 5
e1.
e2. Bus topology
e3. Training compound.
e4. i. Repeater to be connected between Resource compound and Main
compound as thedistance is more than 70m.
ii. Hub/Switch to be connected in every compound to network computers.
e5. ii. Optical Fiber
33 import matplotlib.pyplot as plt 5
x = [1, 2, 3, 4]
h = [20, 50, 30, 40]
plt.xlabel('Subjects') plt.ylabel('Marks') plt.bar(x, h, width=0.5)
plt.show()
plt.savefig(“bar.png”)
or
155
import matplotlib.pyplot as plt
house=['Varun', 'Prithvi', 'Agni', 'Trishul']
medal=[50,70,90,110]
plt.plot(house,medal)
plt.show()
SECTION E
34 i. Select lower(Game) from sports;
ii. Select min(Class) from sports ;
1 mark for each correct query
iii. Select count(class) from sports group by game having grade=’A’ 1+1+2
OR
Select Class ,count(Game) from sports group by Game;
2 marks for correct query
35 A.
Output:
i. (4,4)
ii.
Col1 Col2 Col3 Res
T2 94.734483 100.0 59.22 True
1+1+2
T3 49.090140 100.0 46.04 False
1 mark for each correct query
B. Python statement:
print(df.loc['T2': 'T4', 'Col3'])
OR
print(df.Col2 - df.Col3)
2 marks for correct Python statement
156
Index
SET III
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35
against part C only.
8. All programming questions are to be answered using Python Language only.
PART A
1 Given a Pandas series called S, the command which will display the last 4 rows is _______. 1
a. print(S.tail(4))
b. print(s.Tail())
c. print(s.tails(4))
d. print(s.tail(4))
2 __________ are messages that a web server transmits to a web browser so that the web 1
server can keep track of the user’s activity on a specific website.
a. text
b. cookies
c. email
d. chat
3 The trim()function in MySql is an example of . 1
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
4 The command can be used to insert a new row in a table in SQL. 1
a. add()
b. append
c. insert into
d. alter table.
5 State whether True or False : 1
i. Copying and pasting data from internet or other digital resources is ethical.
ii. E-waste is very hazardous if not handled carefully.
6 Rohan wants to print the row labels of the dataframe. He should use the _____________ 1
attribute of a dataframe.
157
a. column
b. columns
c. index
d. rowname
7 Write the output of the following SQL command. 1
select pow(2,–2);
a. -4
b. 4
c. 0.25
d. -0.25
8 What is e-waste? 1
(a) electronic waste
(b) environmental waste
(c) earth waste
(d) energy waste
9 What will be the output of the following code? 1
mysql>> lcase ('INFORMATICS PRACTICES CLASS 12TH');
11 Stealing someone’s intellectual work and representing it as your own is known as _____. 1
a. Phishing
b. Spamming
c. plagiarism
d. hacking
13 A URL can specify the IP address of the Web ____________ that houses a Web page? 1
a) server
b) client
c) e-mail recipient
d) None
14 ………………. are the records and traces that are left behind while internet is used. 1
a) Digital data
b) Digital Footprint
c) Data Protection
d) Plagiarism
15 To mention conditions along with group by function …………………clause is used. 1
a)Where b)having c)distinct d)select
16 Jhilmalini has stolen a credit card. She used that credit card to purchase a laptop. What 1
type of offence has she committed?
a. online fraud
b. cyber bullying
158
c. cyber stalking
d. All of the above.
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
17 Assertion (A) : import matplotliblib.pyplot as plt is used to import pyplot .
Reason (R) :It is python library so it is imported for using its function.
SECTION B
19 Consider a given Series , T1: 2
SUB1 45
SUB2 65
SUB3 24
SUB4 89
Write a program in Python Pandas to create the series.
OR
Define Series. Write a python statement to create an empty statement.
20 Rohit writes the following commands with respect to a table student having fields, Sno, 2
name, Age, fee.
Command1 : Select count(*) from student;
Command2: Select count(name) from employee;
he gets the output as 6 for the first command but gets an output 5 for the second command.
Explain the output with justification.
21 Consider the following Series object, C_amt 2
Mouse 135
Keyboard 260
Pen drive 80
CD 155
i. Write the command which will display the name of the items having amount <100.
ii. Write the command to name the series as comp_items.
Write commands to :
159
i. Add a new column ‘Percentage’ to the Data frame.
ii. Add a new row with values ( 5 , Rohit ,XI, A ,98,Science)
28 Write a Python code to create a DataFrame with appropriate column headings from the list 3
160
given below:
[[21101,'MANJUSH',58],[21102,'AKSHAY',60],[21103,'ANN' ,76],
[21104,'NITHYA',48]]
29 What are the different ways in which authentication of a person can be performed? 3
OR
Describe measures to recycle your e-waste.
30 Predict the output of the following queries: 3
I) SELECT INSTR (‘Very good’, 'good');
II) SELECT MID('Quadratically',5,6);
III) SELECT RIGHT (‘Command', 3);
OR
Explain the following SQL functions using suitable examples.
a) INSTR()
b) MID()
c) RIGHT()
SECTION D
31 Consider the following graph. Write the code to plot it. 5
OR
Draw the following bar graph representing the uses of programming language.
161
T1 to T4 - 90m
T1 T2
T3 T4
Computers in each wing are networked but wings are not networked The company has
now decided to connect the wings also.
i. Suggest a most suitable cable layout for the above connections.
ii. Suggest the most appropriate topology of the connection between the wings.
iii. The company wants internet accessibility in all the wings. Suggest a suitable
technology.
iv. Suggest the placement of the following devices with justification if the company
wants minimized network traffic
a) Repeater b)Hub / switch
v. The company is planning to link its head office situated in Pune with the offices
in hilly areas. Suggest a way to connect it economically.
33 Write the SQL functions which will perform the following operations: 5
i) To display the current date .
ii) To display the substring “earn” from the whole string ‘LearningIsFun’.
iii) To round the number 76.384 up to 2 place after decimal point.
iv) To find the position of first occurrence of ‘R’ in string 'INFORMATION FORM'
v) To find out the result of 93 .
OR
Consider a table Order with the following data:
Write SQL queries using SQL functions to perform the following operations:
i) To count the number of orders booked by Salespersons with names starting with ‘R’.
ii) Display the position of occurrence of the string “an” in SalesPerson names.
iii) Display the four characters from SalesPerson name starting from second character.
162
iv) To find the average of order amount.
v) Display the month name for the Order date.
SECTION E
34 A relation Vehicles is given below: 1+1+2
35 A dataframe fdf stores data about passengers, Flights and Years as given below. 2+1+1
163
SET-III
KENDRIYA VIDYALAYA SANGATHAN, ERNAKULAM REGION
INFORMATICS PRACTICES (065) SAMPLE QUESTION PAPER (2022 - 23)
Class XII - Marking Scheme
15 Having 1
1 mark for the correct answer
164
18 iv. A is false but R is True 1
Section B
19 import pandas as pd 2
T1=pd.Series([45,65,24,89],index=['SUB1','SUB2','SUB3','SUB4'])
½ mark for import statement
½ mark for usage of Series ()
½ mark for stating index as a list
½ mark for creating object T1
20 This is because the column name contains a NULL value and the aggregate 2
functions do not take into account NULL values. Thus Command1 returns the
total number of records in the table whereas Command2 returns the total
number of non NULL values in the column name.
21 i. print(C_amt [C_amt <100]) 2
ii. C_amt.name=' comp_items '
1 mark each for correct answer of part (i) , (ii)
22 i. classframe[‘Percentage’]=[87,89,92,94] 2
ii. classframe.loc[‘t5’]=[5,’ROHIT’, ‘XI’, ‘A’, 98, ‘Science’]
1 mark for each correct answer
23 a. HTTP: Hyper Text Transfer Protocol 2
b. POP: Point to Point Protocol
c. FTP: File Transfer Protocol
d. VoIP: Voice over Internet Protocol
½ marks for each correct full form
Or
24 I. 2
1. a. select substr("Computer", 3);
1. b. select substr("Computer",5,2);
OR
2. a. select instr ('Computer' , 'ter');
2. b. select left ('Computer',5);
1 mark for each correct /similar answer ( of part (a) , (b))
25 The continuous use of devices like smartphones, computer desktop, laptops, 2
head phones etc cause a lot of health hazards if not addressed. These are:
i. Impact on bones and joints: wrong posture or long hours of sitting in an
165
uncomfortable position can cause muscle or bone injury.
ii. Impact on hearing: using headphones or earphones for a prolonged time
and on high volume can cause hearing problems and in severe cases
hearing impairments.
iii. Impact on eyes: This is the most common form of health hazard as
prolonged hours of screen time can lead to extreme strain in the eyes.
iv. Sleep problem: Bright light from computer devices block a hormone called
melatonin which helps us sleep. Thus we can experience sleep
disorders leading to short sleep cycles.
2 marks for any two correct points
SECTION C
26 a. will give the output as: 3
[20,40,90,110,20,40,90,110]
167
iii) Broadband.
1 mark for suggesting suitable technology
iv). a. Not required. Repeaters may be skipped as per above layout (because
distance is less than 100 m)
b. In every wing
168
2) df[' Total_ passengers’]=df['MalePassengers ']+ df[' FemalePassengers ']
print(df)
169
Index
SET - IV
CBSE SAMPLE QUESTION PAPER CLASS XII
INFORMATICS PRACTICES (065)
PART A
1. Television cable network is an example of: 1
i. LAN
ii. WAN
iii. MAN
iv. Internet
2. Which of the following is not a type of cyber crime? 1
i. Data theft
ii. Installing antivirus for protection
iii. Forgery
iv. Cyber bullying
3. What is an example of e-waste? 1
i. A ripened mango
ii. Unused old shoes
iii. Unused old computers
iv. Empty cola cans
170
4. Which type of values will not be considered by SQL while executing the 1
following statement?
i. Numeric value
ii. text value
iii. Null value
iv. Date value
5. If column “Fees” contains the data set (5000,8000,7500,5000,8000), 1
what will be the output after the execution of the given query?
SELECT SUM (DISTINCT Fees) FROM student;
i. 20500
ii. 10000
iii. 20000
iv. 33500
7. Which SQL statement do we use to find out the total number of records 1
present in the table ORDERS?
171
10. To display last five rows of a series object ‘S’, you may write: 1
i. S.Head()
ii. S.Tail(5)
iii. S.Head(5)
iv. S.tail()
11. Which of the following statement will import pandas library? 1
i. Import pandas as pd
ii. import Pandas as py
iii. import pandas as pd
iv. import panda as pd
12. Which of the following can be used to specify the data while creating a 1
DataFrame?
i. Series
ii. List of Dictionaries
iii. Structured ndarray
iv. All of these
13. Which amongst the following is not an example of a browser? 1
i. Chrome
ii. Firefox
iii. Avast
iv. Edge
14. In SQL, which function is used to display current date and time? 1
i. Date ()
ii. Time ()
iii. Current ()
iv. Now ()
15. Legal term to describe the rights of a creator of original creative or artistic 1
work is:
i. Copyright
ii. Copyleft
iii. GPL
iv. FOSS
16. is the trail of data we leave behind when we visit any website (or 1
use any online application or portal) to fill-in data or perform any
transaction.
i. Offline phishing
ii. Offline footprint
iii. Digital footprint
iv. Digital phishing
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
172
iv. A is false but R is True
17. Assertion (A): - Internet cookies are text files that contain small pieces 1
of data, like a username, password and user’s preferences while surfing
the internet.
Reasoning (R):- To make browsing the Internet faster & easier, its
required to store certain information on the server’s computer.
18. Assertion (A):- DataFrame has both a row and column index. 1
PART B
19. Explain the terms Web page and Home Page. 2
OR
Mention any four networking goals.
Help her in identifying the reason of the error and write the correct query
by suggesting the possible correction (s).
21. What is the purpose of Order By clause in SQL? Explain with the help of 2
suitable example.
22. Write a program to create a series object using a dictionary that stores 2
the number of students in each house of class 12D of your school.
Note: Assume four house names are Beas, Chenab, Ravi and Satluj
having 18, 2, 20, 18 students respectively and pandas library has been
imported as pd.
23. List any four benefits of e-waste management. 2
OR
Mention any four net etiquettes.
173
24. What will be the output of the following code: 2
>>>import pandas as pd
>>>A=pd.Series(data=[35,45,55,40])
>>>print(A>45)
SECTION C
26. Write outputs for SQL queries (i) to (iii) which are based on the given 3
table PURCHASE:
TABLE: PURCHASE
CNO CNAME CITY QUANTITY DOP
C01 GURPREET NEW DELHI 150 2022-06-11
C02 MALIKA HYDERABAD 10 2022-02-19
C03 NADAR DALHOUSIE 100 2021-12-04
C04 SAHIB CHANDIGARH 50 2021-10-10
C05 MEHAK CHANDIGARH 15 2021-10-20
i. SELECT LENGTH(CNAME) FROM PURCHASE WHERE
QUANTITY>100;
ii. SELECT CNAME FROM PURCHASE WHERE
MONTH(DOP)=3;
iii. SELECT MOD (QUANTITY, DAY(DOP)) FROM PURCHASE
WHERE CITY= ‘CHANDIGARH’;
27. Write a Python code to create a DataFrame with appropriate column 3
headings from the list given below:
[[101,'Gurman',98],[102,'Rajveer',95],[103,'Samar' ,96],
[104,'Yuvraj',88]]
174
28. Consider the given DataFrame ‘Stock’: 3
Name Price
0 Nancy Drew 150
1 Hardy boys 180
2 Diary of a wimpy kid 225
3 Harry Potter 500
Write suitable Python statements for the following:
i. Add a column called Special_Price with the following
data: [135,150,200,440].
ii. Add a new book named ‘The Secret' having price 800.
iii. Remove the column Special_Price.
29. Nadar has recently shifted to a new city and school. She does not know 3
many people in her new city and school. But all of a sudden, someone is
posting negative, demeaning comments on her social networking profile
etc.
She is also getting repeated mails from unknown people. Every time she
goes online, she finds someone chasing her online.
OR
What do you understand by plagiarism? Why is it a punishable offence?
Mention any two ways to avoid plagiarism.
30. Based on table STUDENT given here, write suitable SQL queries for 3
the following:
ACCOUNTS RESULT
176
RESULT 12
DELHI HEAD OFFICE 20
(i) Suggest the most appropriate location of the server inside the
MUMBAI campus (out of the four buildings) to get the best
connectivity for maximum number of computers. Justify your
answer.
(ii) Suggest and draw cable layout to efficiently connect various
buildings within the MUMBAI campus for a wired connectivity.
(iii) Which networking device will you suggest to be procured by
the company to interconnect all the computers of various
buildings of MUMBAI campus?
(iv) Company is planning to get its website designed which will
allow students to see their results after registering themselves
on its server. Out of the static or dynamic, which type of website
will you suggest?
(v) Which of the following will you suggest to establish the online
face to face communication between the people in the ADMIN
office of Mumbai campus and Delhi head office?
a) Cable TV
b) Email
c) Video conferencing
d) Text chat
33. Write Python code to plot a bar chart for India’s medal tally as shown 5
below:
Week=[1,2,3,4]
Avg_week_temp=[40,42,38,44]
177
SECTION E
34. Shreya, a database administrator has designed a database for a clothing 1+1+2
shop.
Help her by writing answers of the following questions based on the given
table:TABLE: CLOTH
178
-S ET I V
CBSE SAMPLE QUESTION PAPER
MARKING SCHEME
CLASS XII - INFORMATICS PRACTICES (065)
TIME: 3 HOURS M.M.70
1. iii. MAN 1
1 mark for correct answer
2. ii. Installing antivirus for protection 1
1 mark for correct answer
3. iii. Unused old computers 1
1 mark for correct answer
4. iii. Null value 1
1 mark for correct answer
5. i. 20500 1
1 mark for correct answer
6. ii. Open 1
1 mark for correct answer
7. ii. SELECT COUNT (*) FROM ORDERS; 1
1 mark for correct answer
8. i. ROUND( ) 1
1 mark for correct answer
9. i. MAX () 1
1 mark for correct answer
10. iv. S.tail() 1
1 mark for correct answer
11. iii. import pandas as pd 1
1 mark for correct answer
12. iv. All of these 1
179
19. Web Page: A Web Page is a part of a website and is commonly 2
written in HTML. It can be accessed through a web browser.
Home Page: It is the first web page you see when you visit a website.
1 mark for correct explanation of each term
Or
Four networking goals are:
i. Resource sharing
ii. Reliability
iii. Cost effective
iv. Fast data sharing
½ mark for each goal
20. The problem with the given SQL query is that WHERE clause should not 2
be used with Group By clause.
To correct the error, HAVING clause should be used instead of
WHERE. Corrected Query:
SELECT HOUSE, COUNT(*) FROM STUDENT GROUP BY HOUSE
HAVING HOUSE= ‘RED’ OR HOUSE=’YELLOW’;
1 Mark for error identification
1 Mark for writing correct query
180
25. i. The index labels of df will include Q1,Q2,Q3,Q4,A,B,C 2
ii. The column names of df will be: 1,2
1 mark for each correct answer
26. i. 8 3
ii. No Output
iii. 0
15
1 mark for each correct output
181
30. i. select max(marks) from student group by gender; 3
ii. select min(marks) from student group by city;
iii. select gender,count(gender) from student group by gender;
OR
GROUP BY clause is used in a SELECT statement in combination with aggregate
functions to group the result based on distinct values in a column.
For example:
To display total number of male and female students from the table STUDENT,
we need to first group records based on the gender then we should count records
with the help of count() function.
Considering the following table STUDENT:
RollN Name Class Gender City Marks
o
1 Abhishek XI M Agra 430
2 Prateek XII M Mumbai 440
3 Sneha XI F Agra 470
4 Nancy XII F Mumbai 492
5 Himnashu XII M Delhi 360
6 Anchal XI F Dubai 256
7 Mehar X F Moscow 324
8 Nishant X M Moscow 429
182
OR
1. UCASE(): It converts the string into upper case.
Example:
SELECT UCASE(‘welcome world’);
Output:
WELCOME WORLD
2. TRIM(): It removes the leading and trailing spaces from the given string.
Example:
SELECT TRIM(‘ Welcome world ‘ );
Output:
Welcome world
3. MID(): It extracts the specified number of characters from given string.
Example:
SELECT MID(‘ Welcome world,4,,4);
Output:
Come
4. DAYNAME(): It returns the weekday name for a given date
Example:
SELECT DAYNAME(‘2022-07-22’);
Output:
Friday
5. POWER(): It returns the value of a number raised to the power of another
number.
Example:
SELECT POW(6,2);
Output:
36
ADMIN ACCOUNTS
RESULT
III) Hub/Switch
IV) Dynamic
V) Video conferencing
183
33. import matplotlib.pyplot as plt 5
Category=['Gold','Silver','Bronze']
Medal=[20,15,18]
plt.bar(Category,Medal)
plt.ylabel('Medal')
plt.xlabel('Medal Type')
plt.title('Indian Medal tally in Olympics')
plt.show()
print(df.Tot_students-df.First_Runnerup)
2 marks for correct Python statement
184
Index
OTHER REFERENCES
185