12 IP Questions
12 IP Questions
Informatics Practices
UNIT - I
DATA HANDLING USING PANDAS
Pandas:
Python libraries contain a collection of built-in modules
NumPy, Pandas and Matplotlib are three well-established Python libraries for scientific and analytical
use.
PANDAS (PANel DAta) is a high-level data manipulation tool used for Data Analysing
Pandas is an Open Source library built for Python Programming language.
The main author of Pandas is Wes McKinney.
9
DataFrame :
Creation of Series :
There are a number of ways to create a DataFrame
Coding: Output:
import pandas as pd Series([], dtype: float64)
s1=pd.Series()
print(s1)
Creation of a Series from List:Series can be created from a List:[ default indices range from 0 through
N – 1. Here N is the number of data elements]
Coding: Output:
import pandas as pd
s2=pd.Series(['p', 'y', 't', 'h', 'o',
'n']) print(s2)
10
Coding: Output:
import pandas as pd
s2=pd.Series(['p', 'y', 't', 'h', 'o', 'n'],
index=[111,222,333,444,555,666])
print(s2)
Creation of a Series from Dictionary: Keys become Index and Values become Data
Coding: Output:
import pandas as pd
d1={'I': 'one', 'II': 'two', 'III': 'three'}
s=pd.Series(d1)
print(s)
11
Coding: Output:
import pandas as pd import numpy
as np
s=pd.Series([10,20,30,np.NaN,50])
print(s)
Note: numpy should be imported
12
s=pd.Series(['p', 'y', 't', 'h', 'o', 'n'])
1. s[0] gives p
2. s[2] gives t
3. s[[1,3]] gives
Labelled index :
Single element can be accessed using labelled index (Seriesobject [labelled index])
More than one element of a series can be accessed using a list of index labels
If s is the series given below(Data is the city name, Index is the State )
INDEX DATA
city=['Mumbai','kolkata','Chennai','Bangalore','Hydrebad']
state=['Maharashtra','west Bengal','Tamilnadu',
'karnataka','Telangana']
s=pd.Series(city,state)
print(s)
Even though labelled index is used, We can also access elements of the series
using the positional index
5) Both s[3], s['karnataka'] gives Bangalore, Bangalore
Slicing:
It is used to extract a part of a series.
Part of the series to be sliced can be defined by specifying the start and end parameters [start :end]
with the series name. eg: s[2:5]
When we use positional indices for slicing, the value at the end index position is excluded, i.e., In
s[2:5], element at 5th index is excluded, (end-start) 5-2=3 elements at index 2,3 and 4
are extracted
13
If labelled indexes are used for slicing, then value at the end index label is also
included i.e s['west Bengal':'Telangana'] includes all elements from index westbengal
till Telangana(included)
14
s[:-2] Displays Elements from
positional index 0 till -3
(-2 will not display)
s[1]=75
s['Amit']=88
s[3:5]=77
#This changes element from index 3 to 4 as 55
s[['Julie','Amar']]=90
#This changes Julie’s and Amar’s data as 90
15
s['Laxman':'Amit']=33
#This changes data from Laxman till Amit(including) as 33
Attributes of Series :
We can access certain properties called attributes of a series by using that property with the series name.
Attributes Description
16
size s1.size s2.size
3 4
It returns true in case of empty series
empty
s1.empty s2.empty
False False
It returns true if the series contains NaN
Hasnans
s1.hasnans s2.hasnans
Series s
s.head()
s.head(3)
Tail():
tail(<n>) function fetches last n rows from a pandas object
To access last 3 rows you should write Series_name.tail(3)
If you do not provide any value for n, (Series_name.tail() )will return last 5 rows
Series s
s.tail()
s.tail(3)
17
Note: if number of rows existing less than the required rows ,available rows will get displayed
Mathematical processing can be performed on series using scalar values and functions. All the
arithmetic operators such as +, -, *, /, etc. can be successfully performed on series.
Note:
Arithmetic operation is possible on objects of same index; otherwise, will result as NaN.
Series also supports vector operations. Any operation to be performed on a series gets performed on
every single element of it
import pandas as pd
s1 = pd.Series([1,3,6,4])
print(s1)
18
print(s1+2) # 2 gets added with every element print(s1*2)
# every element gets multiplied by 2 print(s1>2) # It
returns true if element >2, otherwise False
S1>2:
S1: S1+2: S1*2:
We can also give conditions to retrieve values from a series that satisfies the given condition
The following examples performing the filter operation and returns filtered result containing only those
values that return True for the given Boolean expression.
print(s1[s1>2]) #This returns only those result for which s1>2 is True (False data will not be displayed)
print(s1[s1%2==0]) #This returns only those result for which s1%2==0 is True
s.drop("Kavita")
19
s.loc['b'] iloc()- does not
s.iloc[2]
include end index
s.loc['b':'e']
Index 1 till 3 data gets displayed, 4 is excluded in iloc
import pandas as pd
s1=pd.Series([10,20,30,40])
s2=pd.Series([1,2,3,4])
s3=pd.Series([10,20,30,40,50,60])
s4=pd.Series([10,20,30,40,5,6,7,8,9])
print(s1+s2)
print(s1+s3)
print(s3*s4)
import pandas as pd
s=pd.Series([34,56,78])
print(s>40)
import pandas as pd
k=[11,22,33,44,55]
i=['a','b','c','d','e']
s=pd.Series(data=k,index=i)
print(s) print("val=",s.loc[:'c'])
print("val by iloc=",s.iloc[1:4])
import pandas as pd
k=[11,22,33,44,55,66,77,88,99,100]
s=pd.Series(k)
print(s[0],s[0:4],s[:3],s[3:],s[3:8])
print(s[:-1],s[-10:-5],s[-8:])
import pandas as p
k=[11,22,33,44,55,66,77,88,99,100]
s=pd.Series(k)
print(s[0:5],s[5:8],s[:2],s[5:],s[6:8])
print(s[-1:],s[-3:],s[-5:])
Consider the following Series object “S1” and write the output of the following statement
: import pandas as pd
L1=[2, 4, 2, 1, 3, 5, 8,
9] S1 = pd.Series(L1)
21
print("1. ",S1.index)
print("2. ",S1.values)
print("3. ",S1.shape)
print("4. ",S1.ndim)
print("5. ",S1.size)
print("6. ",S1.nbytes)
print("9. ",S1[5]**2)
print("10. ",S1.empty)
print("11.\n", S1>60
print("12.\n", S1[: : -1])
16. Write a program to create the following series and display only those values greater than 200 in the
given Series “S1”
0 300
1 100
2 1200
3 1700
17. Write a program to create the following series and modify the value 5000 to 7000 in the following
Series “S1”
A 25000 C 8000
B 12000 D 5000
18. Write a Pandas program to convert a dictionary to a Pandas series.
Sample dictionary: d1 = {'a': 100, 'b': 200, 'c':300, 'd':400, 'e':800}
19. Define the Pandas/Python pandas?
20. Mention the different types of Data Structures in Pandas?
Creation of DataFrame :
There are a number of ways to create a DataFrame
Coding: Output:
import pandas as pd Empty
df1=pd.DataFrame() DataFrame
print(df1) Columns: []
Index: []
22
Coding: Output:
Keys of dictionaries (Name,Age,Marks)
become column names
import pandas as pd
d1={'Name':'Priya','Age':16,'Marks':70}
d2={'Name':'Harshini','Age':11,'Marks':99}
d3={'Name':'Kanishka','Age':15,'Marks':90}
df1=pd.DataFrame([d1,d2,d3])
print(df1)
The dictionary keys are taken as column labels
The values corresponding to each key are taken as data
No of dictionaries= No of rows, As No of dictionaries=3, No of rows=3
No of columns= Total Number of unique keys of all the dictionaries of the list, as all dictionaries have same 3
keys, no of columns=3
Coding: Output:
Keys of dictionaries (Name, Age, Marks, Gender, Grade)
become column names
import pandas as pd
d1={'Name':'Priya','Age':16,'Marks':70,'Gender':'f'}
d2={'Name':'Harshini','Age':11,'Marks':99,'Grade':'A'}
d3={'Name':'Kanishka','Age':15,'Marks':90}
df1=pd.DataFrame([d1,d2,d3])
print(df1)
No of columns= Total Number of distinct keys of all the dictionaries of the list, as total keys is 5, no of
columns=5
NaN (Not a Number) is inserted if a corresponding value for a column is missing (As
dictionary d1 has no Grade it has Grade as NaN, dictionary d2 has no
Gender , hence it has Gender as NaN and d3 has has no Gender and Grade , hence it has both values
as NaN)
23
Coding: Output:
Keys of dictionary (Name, Age, Gender, Marks)
import pandas as pd become column names
name=['ramya','ravi','abhinav','priya','akash']
age=[16,17,18,17,16]
gender=['f','m','m','f','m']
marks=[88,34,67,73,45]
d1={'name':name,'age':age,'gender':gender,'marks'
:marks}
df1=pd.DataFrame(d1)
print(df1)
Dictionary keys become column labels by default in a Data Frame, and the lists become the rows
import pandas as pd
s1=pd.Series([100,200,300,400])
df1=pd.DataFrame(s1)
print(df1)
s1=pd.Series([100,200,300,400],index=['a','b','c','d'])
Column index is index of Series
s2=pd.Series([111,222,333,444],index=['a','b','c','d'])
df1=pd.DataFrame([s1,s2])
print(df1)
s1=pd.Series([100,200,300,400],index=['a','b','c','d'])
Column index is union of all index of all Series
s2=pd.Series([111,222,333,444],index=['a','b','c','e'])
24
df1=pd.DataFrame([s1,s2])
print(df1)
DataFrame from Multiple Series:
The labels(index) in the series object become the column names
Each series becomes a row
No of columns =No of distinct labels in all the series
If a particular series does not have a corresponding value for a label, NaN is inserted in the DataFrame
column
DataFrame created from Dictionary of Series: Output: Keys becomes Column name
Coding: Values (Series) becomes column data
import pandas as pd
name=pd.Series(['ramya','ravi','abhinav','priya','akash'])
age=pd.Series([16,17,18,17,16])
gender=pd.Series(['f','m','m','f','m'])
marks=pd.Series([88,34,67,73,45])
d1={'name':name,'age':age,'gender':gender,'marks':marks}
df1=pd.DataFrame(d1)
print(df1)
DataFrame created from Dictionary of Series(With Output :
different index: Keys becomes Column name
Values (Series) becomes column data
import pandas as pd If no value for particular row index, NaN is inserted
name=pd.Series(['ramya','ravi','abhinav','priya','akash'],[111,
222,333,444,555])
age=pd.Series([16,17,18,17,16],[111,555,666,222,333])
gender=pd.Series(['f','m','m','f','m'],[111,333,444,555,666])
marks=pd.Series([88,34,67,73,45],[222,333,444,555,666])
d1={'name':name,'age':age,'gender':gender,'marks':marks}
df1=pd.DataFrame(d1)
print(df1)
df1['city'] =
['chennai','mumbai','delhi'
,'mumbai','kolkata']
The following command will add new column newcity with same value ‘chennai’ for all rows
df1['newcity']='chennai'
The following command will change the content of existing column city with new value as chennai for
all rows
26
df1['city']='chennai'
The following command will add new row ‘Swetha’ with given list of values
df1.loc['Sita'] = [77,67,76]
The following command will add new row ‘Gita’ with value 80 for all columns
df1.loc['Gita'] =
The following command can set all values of a DataFrame to a particular value
df1[:]=0
27
The following command removes the row ‘Ramya’ [default value of axis is 0]
df1=df1.drop('Ramya')
df1=df1.drop('Priya',axis=0)
df1.drop('Kavita',inplace=True)
df1=df1.drop('Eng',axis=1)
28
The following command removes the Columns Eng ,Maths
df1=df1.drop(['Eng','Maths'],
axis=1)
The following command renames the row label Ramya by Ram[By default axis =0 so row label changes]
df1=df1.rename({'Ramya':'Ram'})
The following command renames the row label Kavita by Savita [ index used]
df1=df1.rename
(index={'Kavita':'Savita'})
The following command renames the row label Priya by Riya [ axis=0 used by default axis is 0]
df1=df1.rename
({'Priya':'Riya'},axis=0)
29
The following command renames the Column label Eng by English [
axis=1 ]
df1=df1.rename({'Eng':'English'} ,axis=1))
The following command renames the Column labels Science by EVS and Maths by Mathematics [ columns ]
df1=df1.rename(columns={'Maths
':'Mathematics','Science':'EVS'})
df1['Maths']
df1.Maths
The [ ] is used to select multiple columns passed as a list ,Df [[list of column names]]
In the given dataframe df1,
30
df1[['Eng','Maths']]
Slicing:
We can use slicing to select a subset of rows and/or columns from a DataFrame, like Select all
rows with particular columns, Select particular rows with all columns etc
Accessing the data frame through loc()[label indexing] and iloc()[positional indexing] method
• Pandas provide loc() and iloc() methods to access the subset from a data frame using row/column
Loc() method :
The loc property is used to access a group of rows and columns by label(s) [label index]
Df.loc[StartRow : EndRow, StartColumn : EndColumn]
when the row label is passed as an integer value, it is interpreted as a label of the index and not as
an integer position along the index
When labelled indices are used for slicing, value at the end index label is also included in the output.
Df1.loc[a:e,col1:col4] access ‘a’ to ‘e’ [including ‘e’] and columns col1 to col4
iLoc() method :
It is used to access a group of rows and columns based on numeric index value
Df.iloc[StartRowindex : EndRowindex, StartColumnindex : EndColumnindex]
When positional indices are used for slicing, the value at end index position is excluded
Df1.iloc[1:5,2:6] access rows 1 to 4 [excluding 5] and columns 2 to 5[excluding 6]
Note -If we pass “:” in row or column part then pandas provide the entire rows or columns respectively
The following commands helps to access Single row [Details of Ramya ] [Symbol “:” indicates all columns]
31
df1.loc['Ramya']
df1.loc['Ramya',:]
The following commands helps to access Multiple rows (Details of Ramya and Kanishka)
[Records not necessary to be continuous, it should be enclosed in list ]
df1.loc[['Ramya','Kanishka']]
df1.loc['Ramya':'Kanishka']
df1.loc['Ramya':']
32
5) Single Column Access:
The following commands helps to access Single Column [Details of Maths ] [Symbol “:” indicates all
rows]
df1.loc[:,'Maths']
df1.loc[:,['Eng','Science']]
df1.loc [: ,'Eng':'Science']
33
df1.iloc[1]
df1.iloc[1,:]
df1.iloc[1:4]
The following commands helps to access Multiple rows [Display all rows from Ramya(index 1)
till last row]
df1.iloc[1:]
Single Column Access: The following commands helps to access Single Column [Details of Maths
index-1 ] [Symbol “:” indicates all rows]
df1.iloc[:,1]
34
df1.iloc[:,[0,2]]
The following commands helps to access Multiple Columns (Details from Eng till Science index 0 till
last) [Symbol ‘:’ should be used]
df1.iloc[:,0:]
Boolean Indexing :
Boolean means a binary variable that can represent either of the two states - True (indicated by 1) or False (indicated
by 0).
In Boolean indexing, we can select the subsets of data based on the actual values in the DataFrame rather than their
row/column labels.
Thus, we can use conditions on column names to filter data values.
The following commands displays True or False depending on whether the data value satisfies the
given condition or not. (if Maths>=95 it returns True otherwise it returns False]
df1.Maths>=95
35
The following commands displays the details of those students who secured >= 95 in Maths
df1[df1.Maths>=95]
The following commands displays the English and Science marks of those students who secured >= 95
in Maths
When we create an object of a DataFrame then all information related to it like size, datatype etc can
be accessed by attributes. <DataFrame Object>.<attribute name>
ATTRIBUTE DESCRIPTION
Index It shows index of dataframe
Index(['Priya', 'Ramya', 'Kavita', 'Kanishka', 'Harshini'],
dtype='object')
36
Dtypes It returns data type of data contained by dataframe
Eng int64
Maths int64
Science int64
dtype: object
Size It returns number of elements in an object
15
Shape It returns tuple of dimension of dataframe
(5, 3)
Values It returns numpy form of dataframe
[[80 88 73]
[70 98 81]
[75 77 66]
[86 96 94]
[90 95 92]]
Empty It is an indicator to check whether dataframe is empty or not
False
df1.head(2)
If df1.head() command is executed it displays first 5 rows, if number of rows is less than 5, it will display all rows
37
DataFrame.tail(n) to display the last n rows in the DataFrame
If the parameter n is not specified by default, it gives the last 5 rows of the DataFrame.
df1.tail(2)
If df1.tail() command is executed it displays last 5 rows, if number of rows is less than 5, it will display all rows
Iterations in DataFrame:
Iterrows():
DataFrame. iterrows() method is used to iterate over rows
Each iteration produces an index and a row (a Pandas Series object)
df1:
CODING:
for i,j in df1.iterrows():
print("Details of ",i,":\n",j)
38
Iteritems():
DataFrame. iteritems() method is used to iterate over columns
Each iteration produces a column name and a column(a Pandas Series
object)
df1:
Itertuples():
DataFrame. Itertuple() method return a named tuple for each row in the DataFrame
The first element of the tuple will be the row’s corresponding index value, while the remaining values
are the row values
df1:
CODING:
for i in df1.itertuples():
print(i)
39
#Addition
df3=df1+df2 # This performs addition of two dataframe elementwise
print("df3=df1+df2","\n",df3)
print("********************")
40
df1.at['Ramya','Maths']=77 # it changes the row label ‘Ramya’’s Column ‘Maths’ as 77
Output:
Empty DataFrame
Columns: []
Index: []
2. Creating an Empty Dataframe with columnnames:
Output:
Empty DataFrame
Columns: [Name, Articles, Improved]
Index: []
3. Creating an Empty Dataframe with columnnames and indices:
Output:
Name Articles Improved
a NaN NaN NaN
b NaN NaN NaN
c NaN NaNNaN
4. Creating Dataframes using Dictionary(Keys of dictionary- becomes column names)
Output:
41
Output:
Output:
a) print(df)
b) print(df.index)
c) print(df.columns)
d) print(df.axes)
e) print(df.dtypes)
f) print(df.size)
g) print(df.shape)
h) print(df.values)
i) print(df.empty)
j) print(df.ndim)
k) print(df.T)
a) df :
42
df.index : It gives the index of the dataframe
43
Answer: ( All the codings given below will display column ‘Age’ )
print(df['Age'])
print(df.Age)
print(df.loc[:,'Age'])
print(df.iloc[:,1])
In the given Dataframe give the command to do the following:
44
Give the command to add a column named ‘C’ with all values as 11
Answer: ( All the codings given below will add column ‘C’)
df['C']=11
df['C']=[11,11,11,11]
df.insert(2, "C", 11)
df.insert(2, "C", [11,11,11,11])
[The insert function takes 3 parameters which are the index, the name of the column, and the values. The
column indices start from 0 so we set the index parameter as 2 to add the new column next to column B. ]
df.loc[:, "C"]=11
df=df.assign(C=11)[‘Note: C is not enclosed in quotes and it is assigned to df]
b) Adding single column City with a list of values ['Delhi', 'Bangalore', 'Chennai', 'Patna']
Answer: ( All the codings given below will add column ‘City’)
df['City']=['Delhi', 'Bangalore', 'Chennai', 'Patna']
df.insert(2,"City",['Delhi', 'Bangalore', 'Chennai', 'Patna'])
df = df.assign(City = ['Delhi', 'Bangalore', 'Chennai', 'Patna'])
df.loc[:,'City']=['Delhi', 'Bangalore', 'Chennai', 'Patna']
df.at[:,'City']=['Delhi', 'Bangalore', 'Chennai', 'Patna']
45
Worksheet - Basic Level Questions: (L1)
Which of the following can be used to specify the data while creating a DataFrame?
i. Series ii. List of Dictionaries iii. Structured ndarray iv. All of these
Carefully observe the following code: import pandas
as pd Year1={'Q1':5000,'Q2':8000,'Q3':12000,'Q4':
18000} Year2={'A' :13000,'B':14000,'C':12000}
totSales={1:Year1,2:Year2}
df=pd.DataFrame(totSales)
print(df)
Answer the following:
List the index of the DataFrame df
List the column names of DataFrame df.
Write a Python code to create a DataFrame with appropriate column headings from the list given
below: [[101,'Gurman',98],[102,'Rajveer',95],[103,'Samar' ,96],[104,'Yuvraj',88]]
Consider the given DataFrame ‘Stock’:
46
Write suitable Python statements for the following:
Add a column called Special_Price with the following data: [135,150,200,440].
Add a new book named ‘The Secret' having price 800. iii. Remove the column
Special_Price.
Mark the correct choice as
Both A and R are true and R is the correct explanation for A
Both A and R are true and R is not the correct explanation for A
A is True but R is False
A is false but R is True
Assertion (A):- DataFrame has both a row and column index.
Reasoning (R): - A DataFrame is a two-dimensional labelled data structure like a table of
MySQL.
Mr. Som, a data analyst has designed the DataFrame df that contains data about Computer
Olympiad with ‘CO1’, ‘CO2’, ‘CO3’, ‘CO4’, ‘CO5’ as indexes shown below. Answer the
following questions:
47
Worksheet - Difficult questions(L3):
If df is as given below, find the output of 1 to 14 and write commands for 15 to 20
print(df.loc['a':'d':2])
print(df.loc['b':'d','Name'])
print(df.loc[['b','d'],'Name'])
print(df.loc['a':'d':2,['Name','Age']])
print(df.loc['a':'d':2,'Name':'University'])
print(df.at['b','Name'])
df.at['b','Name']='Ravi'
print(df)
print(df.iat[2,1])
df.iat[2,1]=111
print(df)
print(df.iloc[2])
print(df.iloc[2:4])
print(df.iloc[2,2])
print(df.iloc[1:,1:])
df.iloc[2,2]='RU'
Display the details of Students who are from BHU university
Display the details of Students whose age is more than 21
Display the names of Students who are from JNU University
Display name and age whose university is DU
Give all the possible ways of displaying column Age
Make all the values as 0
Output:
28
30. Explain any three methods of pandas Series.
50
Importing and Exporting data between CSV files and Dataframes
CSV files
Comma separated values files
Data in tabular format
Can be imported and exported from programs
51
Exporting data from dataframe to csv file
Function used
Dataframe.to_csv()
52
Data Visualization
Representing the data in the form of pictures or graph
Represents patterns and trends in data which helps the decision makers
Matplotlib is the python library used for this.
Pyplot is a submodule
Constructs 2D plots
Basics of plotting
There are various types of chart we can use to visualize the data elements like:
Line chart: it displays information as a series of data points called markers connected by straight
line
Bar chart it were present category wise data in rectangular bars with length proportional to the
values it can be horizontal and vertical.
Histogram:
Function used :
Plot()
Example:
53
Setting up the labels in X and Y axis
Function used :
xlabel()
ylabel()
54
Bar Graph
A bar graph is used to represent data in the form of vertical or horizontal bars it is useful to
compare the quantities
Function used :
bar()
55
Changing Width, color in bar chart
Parameters in the bar function
Width
56
color
57
Adding legends in Graphs
Function used :
Legend()
58
Setting Limits to X-axis and Y axis
Functions used
xlim()
o ylim()
59
Setting ticks for bar graph
Functions used
xticks()
o yticks()
Histogram
Distribution of values.
It shows how the values are grouped into different intervals or bins.
Functions used
hist()
60
Worksheet for Data Visualization
1 …………………is the function used to set the limits for X axis.
a) xlimit() b) xLim() c)lim() d) xlim()
2 ………………………………… is the library used for data visualization in python
3 The plot which tells the trend between two graphed variable is ………………
4 Which argument of bar() lets you set the thickness of bar?
5 Which argument must be set in the plotting function for legend() to display the legend?
a) show b) label c) name d) seq
6 …….. is a summarization tool for discrete or continuous data.
a)
7 ……………….method is used to create a histogram from a dataframe in pandas.
8 Explain the use of barh() function.
9 Which argument of bar() lets you set the thickness of bar?
10 What do you mean by legends?
11 What do you mean by marker style and markersize in plot() function.
12 What will be the output of the following code :
61
import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,5,1])
plt.show()
Given two arrays namely arr1 and arr2 each having 5 values. Write a program to create a
Line chart so that each data points gets a different color, different size. Keep the
marker style as Diamond.
Write the Python program to create a histogram on the list named height containing height
of students. Use necessary functions to give the title, label, legend etc
Height=[167,158,150,140,130,145,146,128,162,153,165,133,144,122,138]
62
Type of Graphs
LINE
BAR GRAPHS
•Vertical HISTOGRAM
•Horizontal
Bar
• plot()
LINE
bar() for vertical bar graph
BAR • barh() for horizotal bar graph
• hist()
HISTOGRAM
Adding Labels Adding ticks Setting limits Display graph Setting title
63
UNIT – II
DATABASE QUERY USING SQL
SQL Functions
A function is used to perform some particular task and it returns zero or more values as a
result.
Functions can be applied on single or multiple records (rows) of a table. Depending on
their application in one or multiple rows, SQL functions are categorized as Single row
functions and Aggregate functions.
Single Row Functions
These are also known as Scalar functions.
Single row functions can be applied on a single value ,as well as a column.
When applied to a column of a table, they yield one value for each row, i.e., if they are
applied on 10 rows, we get 10 values as output.
They are categorized into: Numeric functions, String functions, and Date functions.
Numeric Functions
These functions take numeric values (numbers) as arguments.
64
If the value of D is negative then Result: 3.8
rounding off on the left-hand side of
decimal. (v) SELECT ROUND (1.298, 0);
Result: 1
(vi) SELECT ROUND (23.298, -1);
Result: 20
STRING FUNCTIONS
10 INSTR (S1, S2) Tells the position of first SELECT INSTR ('PYTHON','ON');
occurrence of S2 within S1.
RESULT: 5
DATE FUNCTIONS
Date Time functions manipulate the display format of dates and time.
66
3. DAY(D) It returns the day part from the SELECT DAY (‘2022-10-02’)
date.
RESULT: 2
5. YEAR(D) It returns the year from the date. SELECT YEAR (‘2022-10-02’)
RESULT: 2022
67
SELECT TRIM(TRAILING '.COM' FROM 'WWW.GOOGLE.COM')
RESULT: WWW.GOOGLE
SELECT TRIM(both 'mysql' from 'mysql_Python_mysql');
RESULT: _Python_
SELECT TRIM(LEADING ‘mysql’ from' mysql_Python_mysql');
RESULT: _Python_mysql
68
WORKSHEET (SOLVED)
Write Output of the following MySQL statements:
SELECT POW(4,3), POW(3,4);
POW(4,3) POW(3,4)
64 81
INSTR("UNICODE","CO") INSTR("UNICODE","CD")
4 0
69
WORKSHEET (UNSOLVED)
SELECT ROUND(3456.885, -2);
SELECT SUBSTR("Innovation",3,4) ;
SELECT RIGHT("Innovation",5) ;
SELECT INSTR("COVID-19","V") ;
SELECT MOD(5,2)
SELECT ROUND(21.341, 2);
SELECT MOD(10, 3);
SELECT MID("YOUNG INDIA",5);
SELECT INSTR("MACHINE INTELLIGENCE","IN");
SELECT LENGTH("GOOD LUCK");
SELECT POWER(3, 3);
SELECT UPPER("examination");
SELECT ROUND (7658.345,2);
SELECT MOD (ROUND (13·9, 0), 3);
SELECT SUBSTR ("FIT INDIA MOVEMENT", 5);
SELECT INSTR ("ARTIFICIAL INTELLIGENCE", "IA");
SELECT TRIM (" ALL THE BEST ");
SELECT POWER(5,2);
SELECT UPPER (MID ("start up india", 10));
The SQL string function that returns the index of the first occurrence of substring
is__________
Write the names of SQL functions to perform the following operations :
Display name of the Month from your date of birth.
Convert email-id to lowercase.
Count the number of characters in your name.
70
Consider a database LOANS with the following table:
Table: Loan_Accounts
AccNo Cust_Name Loan_Amount Installments Int_Rate Start_Date
1 R.K. Gupta 300000 36 12.00 2009-07-19
2 S.P. Sharma 500000 48 10.00 2008-03-22
3 K.P. Jain 300000 36 2007-03-03
4 M.P. Yadav 800000 60 10.00 2008-12-06
5 S.P. Sinha 200000 36 12.50 2010-01-03
6 P. Sharma 700000 60 12.50
7 K.S. Dhall 500000 48 2008-03-05
Give the output of the following SQL Queries:
1. SELECT Cust_Name, LENGTH(Cust_Name), LCASE(Cust_Name), UCASE(Cust_Name)
FROM Loan_Accounts WHERE Int_Rate < 11.00;
Cust_Name, LENGTH(Cust_Name) LCASE(Cust_Name), UCASE(Cust_Name)
Wednesday
5. SELECT ROUND(Int_Rate*110/100, 2) FROM Loan_Accounts WHERE Int_Rate > 10;
ROUND(Int_Rate*110/100, 2)
13.2
13.75
13.75
Aggregate Functions
An aggregate function performs a calculation on one or more values and returns a single
value.
We often use aggregate functions with the GROUP By and HAVING clauses of the
SELECT statement.
Except for count (*), aggregate functions totally ignore NULL values and considers all
values in the present in a column.
Some aggregate functions are as follows:
MAX(): This function returns the maximum value in selected columns. MAX() function ignores
NULL values and considers all values in the calculation.
Syntax:
SELECT MAX(Column_Name) FROM Table_ Name;
MIN(): This function returns the minimum value in selected columns. MIN() function
ignores NULL values.
Syntax:
SELECT MIN(Column_Name) FROM Table_ Name;
AVG(): This function calculates the average of specified column(s). It ignores NULL values.
Syntax:
SELECT AVG(Column_Name) FROM Table_ Name;
SUM(): This function calculates the sum of all values in the specified columns. It accepts only
the expression that evaluates to numeric values. It ignores NULL values.
Syntax:
SELECT SUM(Column_Name) FROM Table_ Name;
COUNT(<column>): This function returns the number of cells having values in the
given column.
If used with keyword distinct, it counts one value once.
If used with *, returns the cardinality of the table.
72
Syntax:
Select count([distinct]<column>/*) form <tablename>
WORKSHEET (SOLVED)
1. Discuss the purpose of count (*) function with the help of a suitable example.
Ans: The count (*) function returns the number of rows where ar least one element is present.
In other words, it returns the cardinality of the table.
2. Give any two differences between MOD() and AVG() functions in SQL.
Ams: a. MOD() returns the remainder when first parameter is divided by second, whereas
AVG() returns average of values stored in a specific column.
MOD() takes two parameters, whereas AVG() takes only one parameters.
MOD() is a single row function, whereas AVG() is an aggregate function.
Give any two differences between the POWER( ) and SUM( ) SQL functions.
Ans: a. POWER () returns the value of a number raised to the power of another number,
while SUM() returns the sum of the values stored in a specific column.
POWER () is a single row function while SUM() is a group/aggregate function.
POWER () accepts two parameters while SUM() accepts one parameter.
Consider table Hotel
Hotel_Id H_Name Location Room_type Price Star
H001 The Palace Delhi Deluxe 4500 5
H002 The Resort Mumbai Deluxe 8000 7
H003 Adobe Resort Dubai Villa 2750 7
H004 Victoria Hill London Duplex 10000 3
H005 The Bee London Villa 30000 7
Write the output of the following SQL statements
SELECT COUNT(*) FROM HOTEL;
ANS: 5
SELECT COUNT(DISTINCT STAR) FROM HOTEL;
ANS: 3
SELECT AVG (PRICE) FROM HOTEL;
ANS: 11050
SELECT SUM (PRICE) FROM HOTEL;
ANS: 55250
SELECT MIN(STAR) FROM HOTEL;
ANS: 3
73
SELECT MAX(PRICE) FROM HOTEL;
ANS: 30000
Consider a table ITEM with the following data :
S.No. Itemname Type Stockdate Price Discount
1 Eating Paradise Dining Table 2002-02-19 11500.58 25
2 Royal Tiger Sofa 2002-02022 31000.67 30
3 Decent Office Table 2002-01-01 25000.623 30
4 Pink Feather Baby Cot 2001-01-20 7000.3 20
5 White Lotus Double Bed 2002-02-23 NULL 25
Write SQL queries using SQL functions to perform the following operations:
(i) Display the first 3 characters of the Itemname.
Ans SELECT LEFT(Itemname,3) FROM ITEM ;
OR
SELECT MID(Itemname,1,3) FROM ITEM ;
OR
SELECT SUBSTR(Itemname,1,3) FROM ITEM ;
OR
SELECT SUBSTRING(Itemname,1,3) FROM ITEM
74
WORKSHEET (UNSOLVED)
An aggregate function performs a calculation on _________ and returns a single value.
(A) single value
(B) multiple values
(C) no value
(D) None of the above
Which of the following is not a built in aggregate function in SQL?
avg
max
total
count
Aggregate functions are functions that take a ___________ as input and return a single value.
A. Collection of values
B. Single value
C. Aggregate value
D. Both A & B
Mean(salary)
Avg(salary)
Sum(salary)
Count(salary)
All aggregate functions except _____ ignore null values in their input
collection. A. Count(attribute)
B. Count(*)
C. Avg
D. Sum
75
6. Find the output (i and ii) for the following SQL commands :
Table: F_INDIA
F_ID Product Price Qty
F01 Sun Cream 678 10
F02 Beauty Cream 5400 15
F03 Face Glow 1704 20
Foundation
F04 Gel Wax 520 10
F05 Hair Shampoo 800 25
F06 Beauty Cream 1200 32
SELECT COUNT (Distinct product) FROM F_INDIA;
SELECT Product, Price FROM F_INDIA WHERE Product LIKE '%m';
7. For the given table School,
Table : School
Admno Name Class House Percentage Gender
20150001 Abhishek Kumar 10 Green 86 Male
20140212 Mohit Bhardwaj 11 Red 75 Male
20090234 Ramandeep Kaur 10 Yellow 84 Female
20130216 Mukesh Sharma 9 Red 91 Male
20190227 Rahil Arora 10 Blue 70 Male
20120200 Swapnil Bhatt 11 Red 64 Female
Write SQL queries for the following :
Display the total number of students in each House where number of students are more than 2.
Display the average Percentage of girls and boys.
Display the minimum Percentage secured by the students of Class 10.
Ms. Anubha is working in a school and stores the details of all students in a Table:
SCHOOL Table : SCHOOL
Admid Sname Grade House Per Gender Dob
20150001 Aditya Das 10 Green 86 Male 2006-02-20
20140212 Harsh Sharma 11 Red 50 Male 2004-10-05
20090234 Swapnil Pant 10 Yellow 84 Female 2005-11-21
20130216 Soumen Rao 9 Red 90 Male 2006-04-10
20190227 Rahil Arora 10 Blue 70 Male 2005-05-14
20120200 Akasha Singh 11 Red Female 2004-12-16
Write the SQL statements from the given table to :
Remove TRAILING SPACES from column Sname.
76
Display the names of students who were born on Tuesday.
Display the Grades of students born in 2006.
Display the average grade of all the students born in 2005.
Predict the output of the following SQL queries from the above Table: SCHOOL
SELECT AVG(Per) FROM SCHOOL WHERE House="Red";
SELECT Sname, Per FROM SCHOOL WHERE MONTH(Dob)=11;
Predict the output produced by the following SQL queries. Are they same? Why (not)?
SELECT Count (Per) FROM SCHOOL;
SELECT Count (*) FROM SCHOOL;
9 Write the names of SQL functions to perform the following operations:
Display the name of the month from the given date value.
Display the day of month from the given date value.
Count the number of characters in a given string.
Remove spaces from beginning and end of a string.
To find if a string is present in another string.
To find today’s date.
To find length of a string.
77
The following query selects details of all the employees in ascending order of their
salaries. mysql> SELECT * FROM EMPLOYEE ORDER BY SALARY;
78
GROUP BY in SQL
At times we need to fetch a group of rows on the basis of common values in a column.
This can be done using a GROUP BY clause.
It groups the rows together that contain the same values in a specified column. We can
use the aggregate functions (COUNT, MAX, MIN, AVG and SUM) to work on the
grouped values.
HAVING Clause in SQL is used to specify conditions on the rows with GROUP
BY clause.
GROUP BY syntax:
SELECT <column_list> FROM < table name > WHERE <condition>
GROUP BY <columns>
[HAVING] <condition>;
Example:
Display total salary paid to employees working in each department.
Display the number of employees and total salary paid to employees working in each
department.
79
SELECT dept "Department Code", COUNT(*) "No of Employees", SUM(salary) "Total
Salary" FROM emp GROUP BY dept;
WORKSHEET (SOLVED)
L1
We can use the aggregate functions in select list of the______ clause of a select statement.
But they cannot be used in a ______ clause.
Write a query that counts the number of doctors registering patients for each day. (If a
doctor has more than one patient on a given day, he or she should be counted only once.)
Consider the following Table Hospital and write the output for the following
commands:
ANSWERS
Option b. GROUP BY, HAVING
When we use GROUP BY clause ( for grouping of data ) and ORDER BY clause ( for
sorting data )together, the ORDER BY clause always follows other clauses. That is, the
GROUP BY clause will come before ORDER BY clause.
For example,
SELECT EMP_ID, SUM(SALARY) AS ‘ANNUAL SALARY’
FROM EMPLOYEE
GROUP BY DEPTID ORDER BY EMP_ID DESC;
SELECT ord_date, COUNT (DISTINCT doctor_code)
FROM Patients GROUP BY ord_date;
a) SELECT DOCName, Salary FROM DOCTOR ORDER BY
Salary DESC;
SELECT Department, SUM(Salary) FROM DOCTOR
GROUP BY Department;
SELECT Department, AVG(Salary) FROM DOCTOR
81
GROUP BY Department HAVING count(*)>1;
L2
Select correct SQL query from below to find the temperature in increasing order of all
cites.
(a) SELECT city FROM weather ORDER BY temperature;
(b) SELECT city, temperature FROM weather;
(c) SELECT city, temperature FROM weather ORDER BY temperature;
SELECT city, temperature FROM weather ORDER BY city;
ANSWERS
SELECT Stream, MAX(Agg)
FROM EMPLOYEE
GROUP BY Stream;
Option c.
SELECT city, temperature FROM weather ORDER BY temperature;
Option d. A is false but R is True
L3
What is the meaning of GROUP BY clause in MySql ?
82
Group data by column values
Group data by row values.
Group data by row and column values.
None of these
2) To specify a condition with GROUP BY clause, _________ clause is used.
a) USE b) WHERE c) HAVING d) LIKE
3) By default, ORDER BY clause lists the results in ______ order.
a) Descending b) Any c) Same d) Ascending
4) Find odd one out?
a) GROUP BY b) DESC c) ASC d) ORDER BY
True / False Questions
The rows of the result relation produced by a SELECT statement can be sorted, but only by
one column.
The HAVING clause acts like a WHERE clause, but it identifies groups that meet a
criterion, rather than rows.
The SQL keyword GROUP BY instructs the DBMS to group together those rows that have
the same value in a column.
What is the difference between a WHERE clause and a HAVING clause of SQL statement
?
What is the difference between order by and group by clause when used along with the
SELECT statement?
ANSWERS
Option a. Group data by column values
Option c. Having
Option d. Ascending
Option a. Group By
83
The difference between WHERE and HAVING clause is that WHERE conditions are
applicable on individual rows whereas HAVING conditions are applicable on groups as
formed by GROUP BY clause.
The ORDER BY clause is used to show the output of the select query in a sorted manner as
per the field name given in the ORDER BY clause. The result can be arranged in the
ascending or descending order of the mentioned field.
The GROUP BY clause is used to group rows in a given field and then perform the mentioned
actions such as apply an aggregate functions. e.g., max(), min() etc on the entire group as per
the specific condition (through HAVING clause.)
UNIT – III
84
INTRODUCTION TO COMPUTER NETWORKS
A collection of computers or devices interconnected with each other for sharing information and
resources is called a computer network
Types of network: LAN, MAN, WAN
Based on the geographical area covered and data transfer rate, computer networks are
broadly categorised as:
LAN (Local Area Network)
MAN (Metropolitan Area Network)
WAN (Wide Area Network)
Network Devices
Devices that are used to connect computers and other electronic devices to a network are
called network devices
Hub:
A hub is a device that is used for connecting multiple computers to a form a network.
When it receives any message, it will broadcast the same to every device connected to it.
Switch
A Switch is device that is used for connecting multiple computers to a form a network.
When it receives any message, it will forward the same to only the correct destination node.
Therefore, it is also called as intelligent hub.
85
Modem : ‘MOdulator DEMolulator’.
Modem is a device used for conversion between analog signals and digital Signals.
Computer store data in digital format but while transmitting data is in analog form.
Modulation is the process of converting digital signals to analog signals
Demodulation is the process of converting analog signals to digital signals
Modem performs both modulation and demodulation as shown in the diagram below
Repeater
Signals lose their strength when they travel long distance. Repeater is a device used to increase
the power of a signal and retransmits it, allowing it to travel further.
86
Router
It is a networking device that interconnects different networks. The simplest function of a router is
to receive packets from one network and pass them to second connected network.
A router can be wired or wireless. A wireless router can provide Wi-Fi access to smartphones
and other devices.
Gateway
It is a device that is used for the communication among the networks which have a different set
of protocols.( for connecting dissimilar networks). It acts as a protocol converter.
Network Topologies
The arrangement of computers and other peripherals in a network is called its topology.
Common network topologies are mesh, bus, star and tree.
Star Topology
In star topology, each communicating device is connected to a central node, which is a
networking device like a hub or a switch, as shown in Figure.
Advantages:
Bus Topology
In bus topology each device connects to a central backbone known as bus.
Data sent from a node are passed on to the bus and can be received by any of the nodes connected
to the bus
87
Advantages:
Mesh Topology
Each device is connected with every other device in the network in as shown in
Figure Advantages:
Tree Topology
Tree topology combines the characteristics of bus topology and star topology.There are
multiple branches and each branch can have one or more basic topologies like star, ring and
bus
Advantages:
88
Introduction to Internet
The Internet is the global network of computing devices including desktop, laptop, servers,
tablets, mobile phones etc.
The World Wide Web (WWW) is an ocean of information, stored in the form of many
interlinked web pages and web resources.
URL
URL is Uniform Resource Locator and provides the location and mechanism (protocol) to
access the resource located on the web. Examples of URL are: https://www.mhrd.gov. in,
http://www.ncert.nic.in
URL is also called a web address.
HTML
HTML — HyperText Markup Language is a language which is used to design standardised
Web Pages It uses tags to define the way page content should be displayed by the web browser.
HTTP
HTTP is a protocol (set of rules) used when transmitting files (data) over theworld wide web
Chatting or Instant Messaging (IM) over the Internet means communicating to people at
different geographic locations in real time
It is possible to send text, image, document, audio, video through instant messengers
Applications such as WhatsApp, Skype, Yahoo Messenger, Google Talk, Facebook
Messenger, Google Hangout, etc., are examples of instant messengers
VoIP
Voice over Internet Protocol or VoIP, allows us to have voice call over the Internet. It is
also known as Internet Telephony .
Website
A website (usually referred to as a site in short) is a collection of web pages related through
hyperlinks, and saved on a web server.
89
A website’s purpose is to make the information available to people at large
Webpage
A web page (also referred to as a page) is a document on the WWW that is viewed in a web
browser.
Basic structure of a web page is created using HTML (HyperText Markup Language) and
CSS (Cascaded Style Sheet).
A web page is usually a part of a website and may contain information in different forms,
such as text , images , audio , video and other interactive contents
Static and Dynamic Web Pages
Static Web Pages Dynamic Web Pages
content always remains same, i.e., does not content of the web page can be different for
change for person to person. different users.
generally written in HTML, JavaScript can be created using various languages such
and/or CSS and have the extension .htm or as JavaScript, PHP, ASP.NET, Python,
.html. Java, Ruby, etc
Less time to load more complex and thus takes more time to
load
Web Server
A web server is used to store and deliver the contents of a website to clients that request it.
Web Hosting
Web hosting is a service that allows us to put a website or a web page onto the Internet, and
make it a part of the World Wide Web
Web Browser
A browser is a software application that helps us to view the web page(s). Some of the
commonly used web browsers are Google Chrome, Internet Explorer, Mozilla Firefox, Opera,
etc. A web browser essentially displays the HTML documents which may include text, images,
audio, video and hyperlinks that help to navigate from one web page to another
Cookies
90
Cookies are small pieces of data stored in text files that are saved on your computer when websites
are loaded in a browser.
It helps in customising the information that will be displayed, for example the choice of
language for browsing, allowing the user to auto login, remembering the shopping preference,
displaying advertisements of one’s interest, etc.
Cookies are usually harmless. Cookies can be disabled by changing the Privacy and
Security settings of our browser.
Ans. c
Which of the following is used to read HTML code and to render Webpage? a)
Web Server
b) Web Browser
c) Web Matrix
d) Weboni
Ans. b
A free open source software version of Netscape was the developed called. a)
Opera Mini
b) IE
c) Google Chrome
d) Mozilla
Ans. d
Which of the following is considered as latest browser?
Mosaic
Google Chrome
IE
Mozilla Firefox
Ans. b
The first widely used web browser was ______.
Mozilla
World Wide Web
NCSA Mosaic
heman
Ans. c
7. Name the first popular web browser is
91
IBM browser
Google chorme
Mozilla Firefox
MOSAIC
Ans. d
93
5 Internal name for the old Netscape browser was _____.
Mozilla
Google Chrome
Opera Mini
IE
Ans. a
A _____ is a document commonly written and is accessible through the internet or other
network using a browser?
a) Accounts
b) Data
c) Web page
d) Search engine
Ans. c
Which of the following is used to read HTML code and to render Webpage?
Web Server
Web Browser
96
Web Matrix
Weboni
Ans. b
4. First Web Browser was created in _______.
1991
1992
1993
1990
Ans. d
5. First web browser was created by _______.
Tim Berners lee
Mozilla Foundation
Marc Andreessen
Jacobs
Ans. a
6. A free open source software version of Netscape was the developed called.
Opera Mini
IE
Google Chrome
Mozilla
Ans. d
7 Internal name for the old Netscape browser was _____.
Mozilla
Google Chrome
Opera Mini
IE
Ans. a
8. Which of the following is considered as latest browser?
Mosaic
Google Chrome
IE
Mozilla Firefox
Ans. b
9. The first widely used web browser was ______.
Mozilla
WorldWideWeb
NCSA Mosaic
heman
Ans. C
10. Name the first popular web browser is
IBM browser
Google chorme
Mozilla Firefox
MOSAIC
Ans. d
11.Simple plain HTML is used to create following type of website
a)Completely Dynamic Website
b)None of these
c)Completely Flash Website
97
d)Completely Static Website
Ans. d
Which of the following was the first web browser to handle all HTML 3 features? a)
Cello
b) Erwise
c) UdiWWW
d) Mosaic
Ans. c
Which of these rendering engine is used by Chrome web browser?
Gecko
Blink
Quantum
Heetsoni
Ans. b
14. Which of the following is the oldest web browser still in general use?
Lynx
Safari
Internet Explorer
Navigator
Ans. a
15. When was Chrome web browser launched ?
2002
2003
2004
2008
Ans. d
16. Which of these tech company owns Firefox web browser?
Lenovo
IBM
Apple
Mozilla
Ans. d
17. Which of the following browsers were/are available for the Macintosh?
Opera
Safari
Netscape
All of these
Ans. d
What is the name of the browser developed and released by Google? a)
Chrome
b) GooglyGoogle
c) Heetson
d) Titanium
Ans. a
Which of the following are alternative names for mobile browsers? a)
microbrowser
b) wireless internet browser
c) minibrowser
98
All of these
Ans. d
20. Apple, Inc. joined the “browser wars” by developing its own browser. What is the name of this
browser?
Opera
NetSurf
Internet Explorer
Safari
Ans. d
21. Some web browsers are intended for specific audiences. What is the target group of the
ZAC Browser?
disgruntled postal workers
autistic children
hardcore gamers
librarians
Ans. b
22. Nexus is first graphical web browser.
True
False
Ans. b
23. The open source software version of netscape is ______
Chrome
Mozilla
internet Explorer
Erwise
Ans. b
24. Which of the following is an Indian Web Browser ?
Google Chrome
Safari
Epic
IE
Ans. c
25. Which of the following is a Web Browser ?
MS-OFFICE
Notepad
Firefox
Word 2007
Ans. c
27. Which of the following browser has high speed browsing capacity ?
Chrome
Opera
UC browser
Lynx
Ans. b
28. A free open source software version of Netscape was the developed called
Opera Mini
IE
Google Chrome
Mozilla
99
Ans. d
Internal name for the old Netscape browser was _____. a)
Mozilla
b) Google Chrome
c) Opera Mini
d) IE
Ans. a
Which of these tech company owns Firefox web browser? a)
Lenovo
b) IBM c)
Apple d)
Mozilla
Ans. d
Which of the following browsers were/are available for the Macintosh? a)
Opera
b) Safari
c) Netscape d)
All of these
Ans. d
What is the name of the browser developed and released by Google? a)
Chrome
b) GooglyGoogle
c) Heetson
d) Titanium
Ans. a
Which of the following are alternative names for mobile browsers? a)
microbrowser
b) wireless internet browser
c) minibrowser
d) All of these
Ans. d
Apple, Inc. joined the “browser wars” by developing its own browser. What is the name of this
browser?
a) Opera
b) NetSurf
c) Internet Explorer
d) Safari
Ans. d
Some web browsers are intended for specific audiences. What is the target group of the
ZAC Browser?
a) disgruntled postal workers
b) autistic children
c) hardcore gamers
d) librarians
Ans. b
100
UNIT-IV
SOCIETAL IMPACTS
MIND MAP
BE ETHICAL
SOCIAL MEDIA
BE RESPECTFUL
ETIQUETTES
BE RESPONSIBLE
DIGITAL BE PRECISE
SOCIETY NET ETIQUETTES
&
BE POLITE
NETIZEN
BE CREDIBLE
BE SECURE
COMMUNICATION
ETIQUETTES
101
BE RELIABLE
DIGITAL FOOTPRINT
The digital footprint is created knowingly or unknowingly while using the internet. Wherever
data is asked to fill up for the interaction you are leaving your digital footprint. Whatever data we are
providing through the internet on websites or apps, it may be used for any purposes including showing
relevant ads to your devices, or it can be misused or exploited for any other purposes.
Net Etiquettes
No Copyright Share the Respect Diversity Respect Privacy Don’t feed Avoid Cyber
Violation expertise the tr oll bullying
No copyright violation: While uploading media like audio, video, or images and creating
content we should not use any material created by others without their consent. We should
always try to make our own content.
Share the expertise: You can share your knowledge to help people on the internet. There are
many platforms like a blog, you tube, podcast and affiliate marketing etc. You should
follow the simple stuff before sharing your knowledge on the internet. The information
should be true.
102
Respect Privacy: We should not share anything on the internet related to others without their
consent. This is called respect for privacy.
Respect Diversity: There is a different kind of people having different kind of mindset and
opinion, knowledge, experience, culture and other aspects. So we have to respect their
diversity in the groups or community or forum.
Avoid cyber bullying: Cyber bullying refers to the activities done internet with an
intention to hurt someone or insult someone, degrading or intimidating online
behaviour such as spreading or sharing rumours without any knowledge or fact
check on the ground, sharing threats online, posting someone’s personal
information, sexual harassment or comments publicly ridicule. These type of
activities have very serious impacts on the victims. Always remeber, your activities
can be tracked through your digital footprints.
MIND MAP
COPYRIGHT
PATENT
IPR
TRADEMARK
LICENSING
PLAGIARISM
VIOLATION OF IPR
COPYRIGHT
INFRINGEMENT
DATA
PROTECTION TRADEMARK
PUBLIC ACCESS AND INFRINGEMENT
OPEN SOURCE
SOFTWARE
103
DATA PROTECTION
Security and control on data stored digitally to avoid any inconvenience, harm, loss or
embarrassment.
Each country has its own data protection law to ensure right protection of data from any
changes or breach.
If a person owns a house it is considered as his own property. Similarly, if a person is posting
something with his unique ideas and concepts is called a person’s intellectual property. Intellectual
Property refers to inventions, literary and artistic expressions, designs and symbols, names and logos.
The Intellectual Property Right gives ownership to the creator of the Intellectual Property
holder. By this, they can get recognition and financial benefits from their property. These
intellectual properties are legally protected by copyrights, patents, trademarks, etc.
Copyrights:
Copyrights refers to the legal rights to use a material like writing, articles, photographs,
audios, videos, software or any other literacy or artistic work. Copyrights are automatically granted
to the creators or the owners.
Patent:
The patents are given for the inventions. Here the creator needs to apply for the invention.
When the patent is granted the owner gets rights to prevent others from using, selling or
distributing the protected invention. Patent gives full control to the patentee to decide how others
can use the invention. A patent protects an invention for 20 years, after that public can use it freely.
Trademark:
Trademark is applicable for the visual symbol, word, name, design, slogan, label etc. for the
product. It provides uniqueness for the other brands and commercial enterprise. It also gives
recognition to the company. The trademark product denoted by ® or ™ symbols. There is no
expiry time for the trademark.
Licensing:
Similarly, a software license is an agreement that provides legal rights to the authorised use
of digital material. All the software, digital documents or games you are downloading from the
104
internet provides the license agreement to use the material. If anyone is not following will be
considered a criminal offence.
Violation of IPR:
Knowingly or unknowingly, people are violating IPR while doing work. So the violation of
IPR done in following ways:
Plagiarism
Copyright Infringement
Trademark Infringement
Plagiarism:
Plagiarism refers to copy or share the intellectual property of someone on the internet
without giving any credit or any mention of the creator. Sometimes if you derived an idea or
product which is already available, then also it is considered plagiarism. Sometimes it is also
considered fraud. Whenever you are using any online material for your personal use or for any
purpose, always cite the author and source to avoid plagiarism.
Copyright Infringement:
When you use the work of others without taking their written permission or don’t paid for
that using that is considered as copyright infringement. If you download an image from google and
use in your work even after giving the credit or reference you are violating copyright. So before
downloading any content check it for copyright violation.
Trademark Infringement:
For the encouragement towards the innovation and new creations, the way of accessing the
material and resources should be available. So there are some public access and open-source
licenses are made for them. Open source allows using the material without any special permission.
Some software is there which are available for free of cost and allows redistribution. User
can use them, copy them and redistribute them. They are available with modifiable source code.
Free and Open Source Software (FOSS) is a large community of users and developers who are
contributing towards open source software. These tools are Linux, Ubuntu, open office, Firefox are
examples of open source software.
Creative common:
105
Creative common is non-profit organization provides public CC license free of charge.
CC license is governed by Copyright law.
CC is used for all kind of creative works like websites, music, film, literature etc.
Six different Creative Commons licenses:
CC BY,
CC BY-SA,
CC BY-NC,
CC BY-ND,
CC BY-NC-SA,
CC BY-NC-ND
Among these, CC BY is the most open license.
Cyber crime:
The cybercrime covers phishing, credit card frauds, illegal downloading, cyber bullying,
creation and distribution of viruses, spam etc. These type of activities increasing day by day
through hacking, ransomware like attacks, denial-of-service attack, phishing, email fraud, banking
fraud and identity theft.
Hacking:
Hacking refers to entering into someone’s account without the user’s consent or stealing
login information from someone’s account and unauthorized access to data. When people share
them on the internet through different websites like emails, online shopping etc. some expert
people trying to break the system security and gain unauthorized access.
If this hacking is done for positive intent then it is known as Ethical Hacking or White
Hat Hacking. The hacker is known as Ethical Hacker or White Hat Hacker. They help to protect
the system from hacking and improves the security of the system.
A Black Hat Hacker or Unethical Hacker tries to gain untheorized access and steal the
sensitive information with the aim to damage or break down the system. Their main focus is
security cracking and stealing the sensitive information.
Phishing:
Phishing is a type of attack on a computer device where the attacker tries to find the sensitive
information of users in a fraud manner through electronic communication by intending to be from
a related trusted organization in an automated manner.
Ransomware:
Ransomware is a form of malicious software that prevents computer users from accessing
their data by encrypting it. Cybercriminals use it to extort money from individuals or organizations
whose data they have hacked, and they hold the data hostage until the ransom is paid.
If the cybercriminals do not pay the ransom within the specified time frame, the data may
leak to the public or be permanently damaged. One of the most serious issues that businesses face
is ransomware.
106
Steps to stop Ransomware:
Avoid Unverified Links:
Frequently Update Your Operating System and Software:
Make a System Backup:
Restrict Access To Your Data:
Disable vulnerable plug-ins:
Create Strong Passwords:
Computers
Televisions
VCRs
Stereos
Copiers, and
Fax machines
Impacts of E-Waste on the humans.
Electronic devices are made up of metals and elements like lead, beryllium, cadmium,
plastics, etc. Out of these materials most of them are difficult to recycle. These materials are very
toxic and unsafe for human beings because they may cause disease like cancer.
E-Waste management:
Recycle Reduce
Reuse
According to the Environmental Protection Act, 1986 - “Polluter pays Principle” means that
anyone causing the pollution will pay for the damage caused. Any kind of violation will be
punished according to this act. The Central Pollution Control Board(CPCB) has issued guidelines
for the proper handling and disposal of e-waste. The guideline says that the manufacture of the
product will be responsible for the disposal of the product when it becomes e-waste.
The Department of Information Technology (DIT) issued a comprehensive technical guide
on “Environmental Management for Information Technology Industry in India.
WORKSHEET
L1
Jack is a good programmer and wants to contribute to the features of one of the
softwares, that he uses. What kind of software he can contribute to?
a) Proprietary software b) Free software
c) Open source software d) Shareware
2) Digital footprints are stored ______________
a) Temporarily (for few days) c) for 7 days only
b) Permanently d) for 3 days
3) What is hazardous pollutant released from mobile phone ?
a) Lithium b) Barium c) Lead d) Copper
L3
1) Any information created by us that exists in digital form is called
a) Digital footprint b) Cyber print c) Internet print d) Web finger print
2) A fraudulent process that extracts money from an ignorant person is called
a) Spamming b) Phishing c) Scam d) None of these
3) The term Intellectual property rights cover
a) Trademark b) Copyright c) Patents d) All of these
Using someone’s Twitter handle to post something will be termed as
110
a) Fraud b) Identity theft c) Online stealing d) Phishing 5) Which of
the following are not ways of data protection? a) Using password b)
Using User IDs c) Using encryption techniques. d) None of these
*******************
111
BLUEPRINT
CLASS: XII SUB: INFORMATICS PRACTICES (065)
Total
S. Section A Section B Section C Section D Section E
Unit Name Marks
No (1 mark) (2 marks) (3marks) (5 marks) (4 marks)
Data Handling
1 4* 3 2 - 1*** 20
Using Pandas
Data
2 - - - 1** - 5
Visualization
Database
3 6 2 2** 1** 1*** 25
Query using SQL
Introduction to
Computer
4 3* 1** - 1 - 10
Networks
Societal
5 5 1** 1** - - 10
Impacts
112
SAMPLE QUESTION PAPER - I
CLASS XII
INFORMATICS PRACTICES (065)
General Instructions:
This question paper contains five sections, Section A to E.
All questions are compulsory.
Section A have 18 questions carrying 01 mark each.
Section B has 07 Very Short Answer type questions carrying 02 marks each.
Section C has 05 Short Answer type questions carrying 03 marks each.
Section D has 03 Long Answer type questions carrying 05 marks each.
Section E has 02 questions carrying 04 marks each. One internal choice
is given in Q35 against part c only.
All programming questions are to be answered using Python Language only.
PART A
1. 25 computers in a school are connected to form a network. It 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. Phishing
ii. Downloading attachment from email
iii. Forgery
iv. Cyber bullying
3. __________ is the process of conversion of electronic devices into something 1
that can be used again and again in some or the other manner
i. Re-Using
ii. Replaying
iii. Recycling
iv. None of the above
4. Which of the following is not an aggregate function? 1
i. Count()
ii. Min()
iii. Round()
iv. Avg()
113
5. If column “Fees” contains the data set (5000,8000,7500,5000,8000), what will 1
be the output after the execution of the given query?
i. 5
ii. 3
iii. 2
iv. 4
6. ‘F’ in FOSS stands for: 1
i. Free
ii. Friendly
iii. Follow
iv. None of the above
7. Which SQL statement do we use to find out the number of distinct names 1
present in the table Student?
114
12. Which of the following cannot 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. Opera
ii. Internet Explorer
iii. Avast
iv. Edge
14. In SQL, which function is used to display current date and time? 1
i. Now()
ii. Curdate () and Curtime()
iii. Curdatetime ()
iv. Curdate ()
15. ___________ offers users the right to freely distribute and modify the original 1
work, but only under the condition that the derivative works be licensed with
the same rights.
i. Copyright
ii. Copyleft
iii. GPL
iv. FOSS
16. __________ gets created through your data trail that you unintentionally leave 1
online.
i. Passive digital footprint
ii. Inactive digital footprint
iii. Digital footprint
iv. Active digital footprint
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): - Internet cookies create some security and privacy 1
concerns.
Reasoning (R): - To make browsing the Internet faster & easier, its required
to store certain information on the server’s computer.
115
PART B
19. Explain the terms Web page and Home Page. 2
OR
Mention any four networking goals.
21. What is the purpose of Group By clause in SQL? Explain with the help of 2
suitable example.
116
23. List any four benefits of e-waste management. 2
OR
Explain any two cyber crimes.
24. Write a program in Python to create a series of first five even number. 2
117
SECTION C
26. Write outputs for SQL queries (i) to (iii) which are based on the given table 3
PURCHASE:
TABLE: PURCHASE
CNO CNAME CITY QUANTITY DOP
C01 GURPREET NEW DELHI 150 2022-06-11
C02 MALIKA HYDERABAD 10 2022-02-10
C03 NADAR DALHOUSIE 100 2021-12-10
C04 SAHIB CHANDIGARH 50 2021-10-10
C05 MEHAK CHANDIGARH 15 2021-10-20
L1=[[101,'Guru',10],[102,'Raj',9],[103,'Sam' ,12],[104,'Yuvraj',12]]
Name Price
0 Nancy Drew 1390
1 Hardy boys 1260
2 Diary of a wimpy kid 2250
3 Harry Potter 1500
119
You as a network expert have to suggest the best network related solutions for
their problems raised in (i) to (v), keeping in mind the distances between the
buildings and other given parameters.
ADMIN 110
ACCOUNTS 75
EXAMINATION 40
RESULT 12
DELHI HEAD OFFICE 20
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.
Suggest and draw cable layout to efficiently connect various
buildings within the MUMBAI campus for a wired connectivity.
Which networking device will you suggest to be procured by the
company to interconnect all the computers of various buildings of
MUMBAI campus?
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?
Which of the following will you suggest to set up the online face to
face communication between the people in the ADMIN office of
Mumbai campus and Delhi head office?
Cable TV
Email
Video conferencing
Text chat
120
33.Write Python code to plot a bar chart for India’s medal tally as shown below: 5
SECTION E
34. Shreya, a database administrator has designed a database for a clothing shop. 1+1+2
Help her by writing answers of the following questions based on the given
table: TABLE: CLOTH
121
OR (Option for part iii only)
Mr. Som, a data analyst has designed the DataFrame df that contains data about
Computer Olympiad with ‘CO1’, ‘CO2’, ‘CO3’, ‘CO4’, ‘CO5’ as indexes
shown below. Answer the following questions:
1+1+2
Predict the output of the following python statement:
df.axes
df.iat[2,3]
Write Python statement to display the data of School and Topper
column of indexes CO1 to CO4.
OR (Option for part iii only)
Write Python statement to compute and display the difference of data of
Tot_students column and Topper column of the above given DataFrame.
122
SAMPLE QUESTION PAPER-I
MARKING SCHEME
CLASS XII
INFORMATICS PRACTICES (065)
TIME: 3 HOURS M.M.70
1. iii. LAN 1
3. iii. Recycling 1
4. iii. Round() 1
1 mark for correct answer
5. ii. 3 1
1 mark for correct answer
6. i.Free 1
1 mark for correct answer
8. i. SUM( ) 1
9. ii. MIN () 1
123
1 mark for correct answer
15. i. Copyright 1
1 mark for correct answer
19. Web Page: A Web Page is a part of a website and is commonly written in 2
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. 2
Corrected Query:
SELECT WINNERS AS HOUSE, SUM(POINTS) AS TOTAL POINTS
FROM STUDENT GROUP BY WINNERS;
124
21. GROUP BY clause: 2
The GROUP BY statement groups rows that have the same values into
summary rows, like "find the number of customers in each country".
The following SQL statement lists the number of customers in each country:
SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country;
1 mark for correct purpose 1
mark for correct example
22. 2
125
ii.
Cname
SAHIB
MEHAK
iii.
Mod(Quantity,3)
2
28. i. Stock['Discount’]=[5,30,17,10] 3
ii. Stock.loc['5']=['The Secret',800,20]
iii. Stock=Stock.drop([2,3],axis=0)
126
30. i. select city,avg(marks) from student group by city having avg(marks)>400; 3
ii. select class,max(marks) from student group by class;
iii. select city,count(gender) from student group by city;
OR
Having Clause is used to filter groups after applying Group By clause
OR
ii.
Hub/Switch
Dynamic
Video conferencing
127
import matplotlib.pyplot as plt 5
33. Category=[“Australia”,”England”,”India”,”Canada”]
Medal=[200,125,65,75]
plt.bar(Category,Medal)
plt.ylabel('Total Number of Medals)
plt.xlabel('Countries')
plt.title('Medal tally of commonwealth Games 2018’)
plt.show()
plt.savefig("aa.jpg")
ii. 2
1 mark for each correct output
B. Python statement:
print(df[["School","Topper"]].loc["C01":"C03",:] OR
print(df.Tot_students-df.Topper)
2 marks for correct Python statement
128
SAMPLE QUESTION PAPER - II
CLASS XII
INFORMATICS PRACTICES (065)
General Instructions:
This question paper contains five sections, Section A to E.
All questions are compulsory.
Section A have 18 questions carrying 01 mark each.
Section B has 07 Very Short Answer type questions carrying 02 marks each.
Section C has 05 Short Answer type questions carrying 03 marks each.
Section D has 03 Long Answer type questions carrying 05 marks each.
Section E has 02 questions carrying 04 marks each. One internal choice is given
in Q35 against part c only.
All programming questions are to be answered using Python Language only.
PART A
1 Bluetooth is an example of: 1
i. LAN
ii. WAN
iii. MAN
iv. PAN
2 A person complains that somebody has created a fake profile of Facebook 1
and defaming his/her character with abusive comments and pictures.
i. Cyber bullying
ii. Cyber stalking
iii. Cyber theft
iv. Cyber Crime
3 The process of re-selling old electronic goods at lower prices is called ____ 1
i. Refurbishing
ii. Recycle
iii. Reuse
iv. Reduce
4 Which function accepts a character string as an input and provides character string or 1
numeric values as an output?
i. Text
ii. Date
iii. Time
iv. Math
5 If column “Marks” contains the data set (50,48,50,40, NULL), what will be the output 1
129
after the execution of the given query?
130
iv. WWW
14 In SQL, which function is used to display current date ? 1
i. Date ()
ii. Time ()
iii. Curdate ()
iv. Now ()
15 GPL is primarily designed for providing public license to a ______ 1
i. software
ii. websites
iii. literature
iv. music
16 The digital data trail we leave online intentionally is called _____ 1
i. Active digital footprints
ii. Passive digital footprints
iii. Current digital footprints
iv. None 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) : Static webpage contains contents that do not chane. 1
Reason (R) : They may only change if the actual HTML file is manually edited.
Ans. Option i is correct.
18 Assertion (A) : A Series is a one-dimensional array containing a sequence of values of any 1
data type (int, float, list, string, etc).
Reason (R) : Pandas Series can be imagined as a column in a spreadsheet.
Ans. Option i is correct.
PART B
19 Differentiate between Web browser and Web server. Write any two popular web browsers. 2
OR
Write two advantages and two disadvantage of Star topology.
20 Gopi Krishna is using a table Employee. It has thefollowing columns : 2
He wants to display maximum salary department wise. He wrote the following command :
SELECT Dept_code, Max(Salary) FROM Employee;
But he did not get the desired result.
Rewrite the above query with necessary changes to help him get the desired output.
21 What is the difference between order by and group by clause when used along with 2
SELECT statement? Explain with an example.
131
22 Consider a given Series, Subject : 2
Index Marks
English 75
Hindi 78
Maths 82
Science 88
SECTION C
26 3
Write outputs for the SQL Queries (i) to (iii) which are based on the given table MOVIE.
29 Mr. Manoj who is a business man by profession faced following situations. Identify the type 3
of crime for each situation/incident happened to him?
i. He was constantly receiving abusive emails
ii. Derogatory messages were posted on him online
iii. His laptop was controlled by somebody in an unauthorised way
OR
What do you understand by Net Etiquettes? Explain any two such etiquettes.
30 Based on table Employee given here, write suitable SQL queries for the following: 3
Computers in each department are networked but departments are not networked The
company has now decided to connect the departments also.
i. Suggest a most suitable cable layout for the above connections.
Suggest the most appropriate topology of the connection between the departments.
The company wants internet accessibility in all the departments. Suggest a suitable
technology.
Suggest the placement of the following devices with justification if the company
wants minimized network traffic
a)Repeater
b)Hub /switch
134
v. The company is planning to link its head office situated in New Delhi with the offices in
hilly areas. Suggest a way to connect it economically.
33 Write code to draw the following bar graph representing the number of students in each 5
class.
OR
Consider a Dataframe ‘emp_df’.
Write a Python code to display a line graph with names on x-axis and age on y-axis.
Give appropriate names for axis and title for the graph.
SECTION E
34 In a database there is a table ‘LOAN’ as shown below: 4
LOAN
135
L-300 DownTown 120000 CarLoan
136
SAMPLE QUESTION PAPER - II
MARKING SCHEME
PART A
1 iv. PAN 1
2 ii. Cyber Stalking 1
3 i Refurbishing 1
4 i Text 1
5 ii 47 1
6 ii FOSS 1
7 i. Count of rows of a table
8 iv Pow() 1
9 i MIN() 1
10 ii. drop 1
11 iv. Tkinter 1
12 ii. import pandas as 1pd 1
13 ii. webpage 1
14 iii. Curdate() 1
15 i. software 1
16 i. Active digital footprints 1
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
A is True but R is False
iv.A is false but R is True
17 Option i is correct. 1
18 Option i is correct. 1
PART B
19 A web browser is a special software that enables the users to read/view web page and jump 2
from one web page to another. It displays a webpage and interprets its HTML code.
Eg. Microsoft Edge, Mozilla Firefox
A web server is a computer that runs websites. It is a computer program that distributes
web pages as they are requested. The basic objective of the web server is to store, process
and deliver web pages to the users.
OR
Advantages:
137
i. We can easily increase computers in a network without any disturbance.
ii. We can easily diagonose errors due to central device.
Disadvantages:
i. When central device(hub/switch) failed, entire network is collapsed.
ii. More cable is required than bus topology
20 SELECT Deptcode, Max(Salary) 2
FROM Employee
GROUP BY Deptcode;
21 The ORDER By clause is used to show the contents of a table / relation in a sorted manner 2
with respect to the column mentioned after the order by clause. The contents of the column
can be arranged in ascending or descending order.
The GROUP By clause is used to group groups the rows together that contain the same
values in a specified column.
Write one example also.
22 import pandas as pd 2
Subject=pd.Series([75,78,82,88], index=[‘English’,’Hindi’,’Maths’,’Science’])
print(Subject)
23 Cyber law as it is the part of the legal systems that deals with the cyberspace,Internet and
with the legal issues. It covers a broadarea, like freedom of expressions, access to and
utilization of the Internet, and online security or online privacy.
It is important as it is concerned to almost all aspects of activities and transactions that take
place either on the internet or other communication devices. Whether we are aware of it or
not, but each action and each reaction in Cyberspace has some legal and Cyber legal views
OR
Hacking is the process of gaining unauthorized access into a computing device, or group of
computer systems. This is done through cracking of passwordsand codes which gives access
to the systems.
Black hat hackers or crackers are individuals with extraordinary computing skills, resorting
to malicious /destructive activities. Black hat hackers use their knowledge and skill for their
own personal gains probably by hurting others.
White hat hackers are those individuals who use their hacking skills for defensive purposes.
This means that the white hat hackers use their knowledge and skill for the good of others
and for the common good.
24 Marks1 90 2
Marks2 95
Marks3 97
dtype: int16
25 i. df[['Month','Passengers']][df['Month']=='Jan'] 2
ii. df.index=[‘Spice Jet’,’Jet’,’Emirates’,’Air India’,’Indigo’]
SECTION C
26 3
138
Ans:i
ii.
iii.
27 import pandas as pd 3
d={'Rollno':[1,2,3,4],'Name':['Swapnil Sharma','Raj Batra','Bhoomi Singh','Jay
Gupta'],'Marks1':[30,75,82,90],'Marks2':[50,45,95,95]}
df=pd.DataFrame(d)
df.to_csv('Sample.csv')
28 i. Vaccine[‘Discount’]=[25,55,70] 3
ii. Vaccine.loc[3]=[‘T1000’,’Covaxin’,780]
iii. Vaccine[‘Price’]=Vaccine[‘Price’]-Vaccine[‘Discount’]
29 i. Cyber Bullying 3
ii. Cyber Trolls
iii. Hacking
OR
Do
• Keep Messages and Posts Brief
139
Protect Personal Information
Obey Copyright Laws
30 3
SELECT GENDER,AVG(SALARY) FROM EMPLOYEE GROUP
BY GENDER;
SELECT DESIGNATION,MAX(SALARY) FROM EMPLOYEE
GROUP BY DESIGNATION;
SELECT DEPT,COUNT(*) FROM EMPLOYEE GROUP BY DEPT;
OR
Physical Problems:
Repetitive Strain Injury: The pain exists even when resting and as a result it
becomes very
difficult to accomplish even easy and ordinary tasks.
Computer Vision Syndrome: Experts believe that people blink their eyes more
frequently while using computers than they do otherwise and that this can cause
various eye and vision-related problems.
Radiation: Computer screens produce radiations of various types. These
radiations can cause headaches and inattentiveness.
Sleeping disorders and decrease in productivity
Loss of attention and stress
Psychological Disorders:
Fear of technology
Computer anxiety
Internet addiction
SECTION D
31 i) SELECT ROUND (123.2356,2); 5
ii) SELECT LTRIM (“Python“)
iii) SELECT MONTHNAME(DOB)
iv) SELECT INSTR (“Information Technology”, ”Information”)
140
v)SELECT POW (3,4);
OR
SUBSTR()
Returns the substring (part) of a string.
Eg. SELECT SUBSTR(‘Python Programming’,3,4);
Output:
thon
141
Students = [40,45,35,44]
plt.barh(Classes,Students)
plt.title('Class wise Strength')
plt.xlabel('Classes')
plt.ylabel('Strength')
plt.show()
OR
import matplotlib.pyplot as plt
x = emp_df['Name']
y = emp_df['Age']
plt.plot(x,y)
plt.xlabel("Name")
plt.ylabel("Age")
ptl.title("Name vs Age")
plt.show()
SECTION E
34 i. SELECT UPPER(Branch_name) FROM LOAN; 4
ii. SELECT * FROM LOAN ORDER BY AMOUNT DESC;
iii. SELECT BRANCH_NAME,COUNT(*) FROM LOAN GROUP BY
BRANCH_NAME HAVING BRANCH_NAME
IN(‘DOWNTOWN’,’PERRYRIDGE’);
OR
SELECT LOANTYPE,SUM(AMOUNT) FROM LOAN GROUP BY LOANTYPE
HAVING LOANTYPE IN(‘HOMELOAN’,’CARLOAN’);
35 A. i. 4
B. sales_df.loc[1:3,'July']
OR
>>> diff=sales_df['June']-sales_df['July']
>>> print(diff)
142
SAMPLE QUESTION PAPER - III
CLASS XII
INFORMATICS PRACTICES (065)
PART A
1 Akhilesh is transferring songs from his mobile to his friend’s mobile via 1
Bluetooth connection. Name the network used by Akhilesh
i. LAN
ii. WAN
iii. MAN
iv.PAN
.
2 The school offers Wi-Fi to the students of Class XII. For communication, the 1
network security-staff of the school is having a registered URL "schoolwifi.edu".
One day, emails were received by all the students regarding expiry of their
passwords. Instructions were also given renew their password within 24 hours by
clicking on particular URL provided. Specify which type of cybercrime is it.
a) Spamming
b) Phishing
c) Identity Theft
d) Hacking
3 Which amongst the following is not an example of browser? 1
a. Chrome
b. Firefox
c. Avast
d. Edge
143
7 Out of the given query is ……………………….. 1
SELECT SUBSTRING(‘practically',5);
8 Identify an aggreagate fn 1
a)orderby()
b) count(*)
c) groupby()
d) upper()
15 Legal term to describe the rights of a creator of original creative or artistic work 1
is:
i. Copyright ii. Copyleft iii. GPL iv. FOSS
16 A digital document hosted on a website is ______________ 1
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
PART B
19 Differentiate static and dynamic web page. 2
OR
Explain any two networking devices
20 Anjali writes the following commands with respect to a table employee 2
having fields, empno, name, department, commission.
She gets the output as 4 for the first command but gets an output 3 for
the second command. Explain the output with justificatio
INDEX MARKS
ENGLISH 75
HINDI 78
MATHS 82
SCIENCE 86
Write a program in Python Pandas to create this series.
145
23 Expand the following terms related to Computer Networks: 2
a. PPP
b. HTTPS
OR
a)VoIP
b)www
24 Consider the series h1 2
0 12
1 23
2 34
3 27
(a) Write code to change the index as a1,a2,a3,a4.
(b)Write the name of module imported to create series.
25 Write python code to create the given dataframe using dictionary and 2
display.
code pname price
0 x01 Talcum powder 200
1 x02 Face wash 50
2 x03 Bath soap 40
3 x04 Shampoo 200
4 x05 Tooth paste 300
SECTION C
26 Write outputs for SQL queries (i) to (iii) which are based on the given table 3
Write commands to :
i. Add a new column ‘Activity’ to the Dataframe
ii. Add a new row with values ( 5 , Mridula ,X, F , 9.8, Science)
146
iii. Remove a column Section
29 Nadar has recently shifted to a new city and school. She does not know many 3
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. i. What is this happening to Nadar? ii. What
immediate action should she take to handle it? iii. Is there any law in India to
handle such issues? Discuss briefly.
OR
What do you understand by Cyber bullying? Why is it a punishable offence?
30 A relation Vehicles is given below : 3
SECTION D
31 Write suitable SQL query for the following: 5
i. Display first 5 characters extracted from the string ‘Informatics
Practices’.
ii. Display the position of occurrence of string ‘COME’ in the string
‘WELCOME WORLD’.
iii. Round off the value 23.78 to one decimal place.
iv. Display the current time and date.
v. Remove all the expected leading and trailing spaces from a column
userid of the table ‘USERS’.
OR
Explain the following SQL functions using suitable examples.
i. MONTH()
ii. RTRIM()
iii. INSTR()
iv. DAYNAME()
v. MOD()
147
32 Cognisant technologies has set up their new center at Cochin for its office and
web based activities. They have 4 blocks of buildings named Block A, Block B,
Block C and Block D.
Name of Block No. of Computers
Block A 25
Block B 50
Block C 125
Block D 10
Distance between the Blocks
Block A to Block B 50m
Block B to Block C 150m
Block C to Block D 25m
Block A to Block D 170m
Block B to Block D 125m
Block A to Block C 90m
Suggest the most suitable place (i.e. block) to house the server of this
organization with a suitable reason.
Suggest a cable layout of connections between the blocks.
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.
Describe where the following devices are required?
(a) Hub/Switch (b) Repeater
The organization is planning to link its Block E situated in the same city.
Which type of network out of LAN, WAN, MAN can be considered? Justify.
33 Mr. Sharma is working in a game development industry and he was comparing 5
the given chart on the basis of the rating of the various games available on the
play store. Write Python code to plot a bar chart.
OR
Write a python program to plot a line chart based on the given data to depict the
marks of 5 students in English.
Roll=[1,2,3,4]
148
Marks=[40,42,38,44]
SECTION E
34 A Departmental store ‘Iconic’ is planning to automate its system so that they can 1+1+2
store all the records on computer. They contacted a Software Company to make
the software for the same. The company suggested that there is need of a front
end and back-end software. The major challenge was to keep the record of all the
items available in the store. To overcome the problem, the software company has
shown the glimpses of the database and table required to resolve their problem:
Table Name: Garment
Attributes of the table: Gcode – Numeric, Gname – Character 25, Size - Character
5, Colour – Character 10, Price – Numeric
Consider the following records in ‘Garment’ table and answer the given questions
149
SAMPLE QUESTION PAPER - III
MARKING SCHEME
PART A
1 Ans: PAN 1
2 1
Ans: b) Phishing
3 Ans: c. Avast 1
4 Ans: d. 50 1
7 Ans: tically 1
8 Ans: count(*) 1
9 Ans: HAVING 1
10 Ans: print(Sequences.head(4)) 1
11 Ans: c 1
12 Ans: c 1
13 Ans: URL 1
14 Ans: Use DISTINCT keyword 1
15 Ans: Copyright 1
16 1
Ans: webpage
150
17 Ans: i 1
18 1
Ans:iii
PART B
19 Ans: The static web pages display the same content each time when someone visits it.It takes 2
less time to load over internet.
In the dynamic Web pages, the page content changes according to the user.Dynamic web pages
take more time while loading.
OR
Ans:
Repeater
▪ Data are carried in the form of signals over the cable
▪ Signals lose their strength beyond 100 m limit and become weak.
▪ The weakened signal appearing on the cable is regenerated and put back on the cable by a
repeater
Hub
▪ An Ethernet hub is a network device used to connect different devices through wires.
▪ Data arriving on any of the lines are sent out on all the other
20 Ans: Count(*) counts null values while count() counts not null values only 2
21 Ans: 2
The SQL GROUP BY clause is used to arrange identical data into groups.
22 Ans: 2
import pandas as pd
a = pd.Series(marks:[75,78,82,86],index=[‘ENGLISH’,’HINDI’,MATHS”,’SCIENCE’])
print(a)
23 Ans: 2
PPP-Point to Point Protocol
b. HTTPS-Hypertext Transfer Protocol
OR
a)VoIP- Voice over Internet protocol
b)www- World wide web
24 Ans: 2
a) h1.rename(index=[‘a1’,’a2’,’a3’,’a4’]
b) pandas
25 Ans: 2
import pandas as pd
details = {
'Code' : ['x01', 'x02', 'x03', 'x04',’x05’],
'pname' : [‘Talcum powder’,’ Face wash’, ‘Bath Soap’, ’Shampoo’, ’Tooth paste’,
151
'price' : [200, 50,40,200,300]}
df = pd.DataFrame(details)
print(df)
SECTION C
26 Ans: 3
i)
Sname
Sushant
Priya
ii)
Sname round(sales,1)
Amit 5000.9
Sushant 7000.7
Priya 3450.5
Mohit 6000.5
Priyanshi 8000.6
iii)
Right(Sname,3), Round(Sales)
iya 3450
shi 8001
27 Ans: 3
import pandas as pd
details = {
'Id' : [200,300,300,400],
'City’ : [‘Delhi’,'Mumbai','Kolkota’,'Chennai’],
'Populationinlakhs' : [98,95,96,88]}
df = pd.DataFrame(details)
print(df)
29 Ans: 3
i. Namita has become a victim of cyber bullying and cyber stalking.
152
She must immediately bring it to the notice of her parents and school authorities.
And she must report this cybercrime to local police with the help of her parents.
Yes, IT Act, 2000
iv.
OR
30 3
Ans:
SELECT AVG(Price) FROM Vehicles WHERE Quantity >20 GROUP BY Type;
SELECT COUNT(Type) FROM Vehicles GROUP BY Type;
SELECT SUM(Price) FROM Vehicles;
OR
Ans:
HAVING Clause in SQL is used to specify conditions on the rows with GROUP BY clause.
Eg:
SELECT CustID, COUNT(*) FROM SALE GROUP BY CustID HAVING Count(*)>1
Display customer id and number of cars purchased if the customer purchased more
than one car from the sale table.
SECTION D
31 Write suitable SQL query for the following: 5
Display first 5 characters extracted from the string ‘Informatics
Practices’. Ans: Select LEFT(‘Informatics Practices’,5);
Display the position of occurrence of string ‘COME’ in the string
‘WELCOME WORLD’.
153
RTRIM()
Ans:
Removes trailing spaces. Example: SELECT RTRIM(‘ INFOR MATICS
'); Result: ‘ INFOR MATICS
INSTR()
Ans:
Returns the index of the first occurrence of substring. Example: (i)
SELECT INSTR(‘Informatics’,’ mat’); Result: 6 (since ‘m’ of ‘mat’ is at
6th place
DAYNAME() :
Ans:
Returns the name of the weekday. Example: SELECT DAYNAME('2010-
07-21'); Result: WEDNESDAY
MOD()
Ans:
Divides x by y and gives the remainder. (i)SELECT MOD(12,5); Result: 2
Cognisant technologies has set up their new center at Cochin for its office and web based
activities. They have 4 blocks of buildings named Block A, Block B, Block C and Block D.
Name of Block No. of Computers
Block A 25
Block B 50
Block C 125
BlockD 10
Distance between the Blocks
Block A to Block B 50m
Block B to Block C 150m
Block C to Block D 25m
Block A to Block D 170m
Block B to Block D 125m
Block A to Block C 90m
Suggest the most suitable place (i.e. block) to house the server of this organization with a
suitable reason.
154
50
A
B
90
25
D
C
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.
Ans: Microwave
Describe where the following devices are required?
Hub/Switch – In all blocks (b) Repeater- No need since the distances between blocks are
below 100 m
The organization is planning to link its Block E situated in the same city. Which type of
network out of LAN, WAN, MAN can be considered? Justify.
Ans: Metropolitan Area Network (MAN): covers a larger geographical area like a city or a
town.
▪ Can be extended up to 30-40 kms
33 Mr. Sharma is working in a game development industry and he was comparing the given chart 5
on the basis of the rating of the various games available on the play store. Write Python code to
plot a bar chart.
plt.bar([‘Subway’,Surfer’,’TempleRun’,’CandyCrush’,’BottleShot’,’RunnerBest’,[1,2,3,4,5])
155
plt.xlabel(‘Games’ )
plt.ylabel(‘Rating’)
plt.show()
plt.savefig()
OR
Write a python program to plot a line chart based on the given data to depict the marks of 5
students in English.
Roll=[1,2,3,4]
Marks=[40,42,38,44]
Ans:
import matplotlib as plt
Roll=[1,2,3,4]
Marks=[40,42,38,44]
plt.plot(Roll,Marks)
plt.title(‘English Marks’)
plt.xlabel(‘Rollnumbers’ )
plt.ylabel(‘Marks’)
plt.show()
plt.savefig()
SECTION E
34 A Departmental store ‘Iconic’ is planning to automate its system so that they can store all the 1+1+2
records on computer. They contacted a Software Company to make the software for the same.
The company suggested that there is need of a front end and back-end software. The major
challenge was to keep the record of all the items available in the store. To overcome the
problem, the software company has shown the glimpses of the database and table required to
resolve their problem:
Table Name: Garment
Attributes of the table: Gcode – Numeric, Gname – Character 25, Size - Character 5, Colour
– Character 10, Price – Numeric
Consider the following records in ‘Garment’ table and answer the given questions
156
Ans:
UPDATE GARMENT SET COLOUR=’ORANGE’ WHERE CODE=116;
Write a query to display the table in the order of the price.
Ans: SELECT * FROM GRAMENT ORDER BY
PRICE; OR (Option for part iii only)
Write a query to find the count of the garments in each size.
Ans: SELECT GNAME, COUNT(GNAME) FROM GARMENTS GROUP BY
SIZE;
OR
Write python statement to display the Series.
Ans: print(school)
157
SAMPLE QUESTION PAPER - IV
CLASS XII
INFORMATICS PRACTICES (065)
TIME: 3 HOURS M.M.70
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) Uploading photo from mobile phone to Desktop computer is an example of 1
a) LAN
b) PAN
c) MAN
d) WAN
2) Using Someone else’s twitter handle to post something is termed as 1
a) Fraud
b) Identity theft
c) Online stealing
d) Violation
3) Following are the impact of e-waste on the environment. Choose the odd one out. 1
a) Soil Pollution
b) Water Pollution
c) Air Pollution
d) Sound Pollution
4) The practice of taking confidential information from you through an original looking site and 1
URL is known as _______________
a) Plagiarism
b) Phishing
c) Hacking
d) Cookies
5) If column “Salary” contains the data set (20000,30000,NULL,10000), what will be the output 1
after the execution of the given query?
select avg(salary) from empl;
a) 15000
b) 20000
c) 10000
158
d) 60000
6) OSS stands for______ 1
a) Open system Service
b) Open Source Software
c) Open system Software
d) Open Synchronized Software
7) SQL command that removes trailing spaces from a given string is ___________ 1
a) rtrim()
b) ltrim()
c) right()
d) left()
8) The avg( ) function in MySQL is an example of …………………. 1
a) Math Function
b) Text Function
c) Date Function
d) Aggregate Function
9) Write the SQL command that will display the time and date at which the command got 1
executed.
a) Select sysdate();
b) Select now();
c) Select curdate();
d) Both (i) and (ii)
10) Pandas series is: 1
a) 2 dimensional
b) 1 dimensional
c) 3 dimensional
d) Multi dimensional
11) The command to install Pandas is: 1
a) install pip pandas
b) install pandas
c) pip pandas
d) pip install pandas
12) In Pandas the function used to delete a column in a DataFrame is 1
a) remove
b) delete
c) drop
d) cancel
13) For web pages where the information is changed frequently, for example, stock prices, weather 1
information which out of the following options would you advise?
a) Static web page
b) Dynamic web page
c) Animated web page
d)Home page
14) Write the output of the following SQL command. 1
select round (49.88);
a) 49.88
b) 49.8
159
c) 49.0
d) 50
15) Which of the following is not a violation of IPR? 1
a) Plagiarism
b) Copyright Infringement
c) Patent
d) Trademark Infringement
16) A patent protects an invention for ___________ years, after which it can be freely used. 1
a) 10
b) 20
c) 30
d) 40
160
print(s[s%2==0])
25) Carefully observe the following code 2
import pandas as pd
import numpy as np
data = {'Ramya': {'Age': 35,'Desg':'PGT', 'Address': 'Portblair','dob':'12-12-1987'},
'Priya': {'Age': 28,'Desg':'TGT', 'Address': 'Chennai','Salary':65000},
'Suresh': {'Age': 25, 'Desg':'PRT','Address': 'Madurai'}}
df= pd.DataFrame(data)
print(df)
Answer the following:
Give the command to list all row labels of df, and give the output of the same
Give the commands to find the dimension and shape of dataframe df
SECTION C
26) Write outputs for SQL queries (i) to (iii) which are based on the given table AGENT: 3
TABLE AGENT
161
30) A relation Product is given below : 3
(or)
Explain the following SQL functions using suitable examples.
a) LTRIM ()
b) NOW ()
c) ROUND ()
d) MOD ()
e) INSTR ()
32) “Anutulya Creations”-A start-up fashion house has set up its main centre at Kanpur, Uttar Pradesh for 5
its dress designing, production and dress supplying activities. It has 4 blocks of buildings. Distance
between the various blocks is as follows:
162
Based on the above specifications, answer the following questions:
Out of LAN, WAN and MAN, what type of network will be formed if we interconnect
different computers of the campus? Justify.
Suggest the topology which should be used to efficiently connect various blocks of buildings
within Kanpur centre for fast communication. Also draw the cable layout for the same.
Suggest the placement of the following device with justification i. Repeater ii. Hub/Switch
Now a day, video-conferencing software is being used frequently by the company to discuss
the product details with the clients. Name any one video conferencing software. Also mention the
protocol which is used internally in video conferencing software
Suggest a device/software and its placement that would provide data security for the entire
network
33) Write Python code to plot a line chart for Students Class Strength as shown below: 5
(or)
Mr. Sharma is working in a game development industry and he has to compare the games on the
basis of the rating of the various games available on the play store using Bar Chart. Help him to
write the python program for the bar chart to get the desired output
Games=["Subway Surfer","Temple Run","Candy Crush","Bottle
Shot","RunnerBest"] Rating=[4.2,4.8,5.0,3.8,4.1]
SECTION E
Consider the table SHOP as given below: 1+1+2
163
Write SQL Commands for the following :
Display all the company names in capital letters and itemname in lower case
Display the highest price of each company
Count number of items where number of characters in the item name is less than
5 (or)
Count number of items city wise
35) Zeenat has created the following data frame dataframe1 to keep track of data Rollno, Name, Marks1 1+1+2
and Marks2 for various students of her class where row indexes are taken as the default values
164
SAMPLE QUESTION PAPER – IV
MARKING SCHEME
CLASS XII
INFORMATICS PRACTICES (065)
TIME: 3 HOURS M.M.70
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) Uploading photo from mobile phone to Desktop computer is an example of 1
a) LAN
b) PAN
c) MAN
d) WAN
Answer:b)PAN
2) Using Someone else’s twitter handle to post something is termed as 1
a) Fraud
b) Identity theft
c) Online stealing
d) Violation
Answer: b)Identity theft
3) Following are the impact of e-waste on the environment. Choose the odd one out. 1
a) Soil Pollution
b) Water Pollution
c) Air Pollution
d) Sound Pollution
Answer: d. Sound Pollution
4) The practice of taking confidential information from you through an original looking site and 1
URL is known as _______________
a) Plagiarism
b) Phishing
c) Hacking
d) Cookies
Answer: b) Phishing
165
5) If column “Salary” contains the data set (20000,30000,NULL,10000), what will be the output 1
after the execution of the given query?
select avg(salary) from empl;
a) 15000
b) 20000
c) 10000
d) 60000
Ans: b)20000
6) OSS stands for______ 1
a) Open system Service
b) Open Source Software
c) Open system Software
d) Open Synchronized Software
Answer: b) Open Source Software
7) SQL command that removes trailing spaces from a given string is ___________ 1
a) rtrim()
b) ltrim()
c) right()
d) left()
Answer: a) rtrim()
8) The avg( ) function in MySQL is an example of …………………. 1
a) Math Function
b) Text Function
c) Date Function
d) Aggregate Function
Answer: d) Aggregate Function
9) Write the SQL command that will display the time and date at which the command got 1
executed.
a) Select sysdate();
b) Select now();
c) Select curdate();
d) Both (i) and (ii)
Answer: a)Select sysdate();
10) Pandas series is: 1
a) 2 dimensional
b) 1 dimensional
c) 3 dimensional
d) Multi dimensional
Answer: b)1 dimensional
11) The command to install Pandas is: 1
a) install pip pandas
b) install pandas
c) pip pandas
d) pip install pandas
Answer: d) pip install pandas
12) In Pandas the function used to delete a column in a DataFrame is 1
a) remove
b) delete
166
c) drop
d) cancel
Answer: c)drop
13) For web pages where the information is changed frequently, for example, stock prices, weather 1
information which out of the following options would you advise?
a) Static web page
b) Dynamic web page
c) Animated web page
d)Home page
Answer: b) Dynamic web page
14) Write the output of the following SQL command. 1
select round (49.88);
a) 49.88
b) 49.8
c) 49.0
d) 50
Answer: 50
15) Which of the following is not a violation of IPR? 1
a) Plagiarism
b) Copyright Infringement
c) Patent
d) Trademark Infringement
Answer. C.Patent
16) A patent protects an invention for ___________ years, after which it can be freely used. 1
a) 10
b) 20
c) 30
d) 40
Answer. b. 20
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):Digital Footprints are also termed as Digital Tattoos 1
Reason(R): A digital tattoo can also refer to the record of someone’s actions and
communications online and its permanence like a physical tattoo
Answer: (i)
18) Assertion(A): List of dictionaries can be passed to form a DataFrame 1
Reason(R): Keys of dictionaries are taken as row names by default
Answer: (iii)
SECTION B
19) Explain the differences between Static web page and Dynamic web page 2
Static web page:
167
A web page which displays same kind of information whenever a user visits
it, is known as a static web page.
A static web page generally has.htm or .html as extension
(or)
Differentiate between LAN and WAN
LAN WAN
It spread over a small area It spreads over a large area
Diameter of not more than few km Span entire countries
Less cost to setup Higher cost to setup
Operate at data transfer rate of several Data rate less than 1 MBPS
MBPS (1 to 10 MBPS)
Complete ownership by a single Owned by multiple organizations
organization
Very low error rates Comparatively higher error rates
20) To display the sum of salary paid to KARATE coaches of each gender, Ravi has written the 2
following command but unable to get the desired result, help him to identify the error and write
the correct query by suggesting the possible reason
Select sex, sum(pay) from club group by sex where sports= “KARATE”;
Answer:
The problem with the given SQL query is that WHERE clause should not be used with Group
By clause. To correct the error, where clause should be used before group by. Corrected
Query: Select sex, sum(pay) from club where sports= “KARATE” group by sex;
168
What is the difference between a WHERE clause and a HAVING clause in SQL SELECT 2
statement?
Answer:
SR.
NO. WHERE Clause HAVING Clause
WHERE Clause is used to filter the records HAVING Clause is used to filter record
from the table based on the specified from the groups based on the specified
1. condition. condition.
WHERE Clause can be used without HAVING Clause cannot be used withou
2. GROUP BY Clause GROUP BY Clause
WHERE Clause is used with single row HAVING Clause is used with multiple
4. function like UPPER, LOWER etc. row function like SUM, COUNT etc.
WHERE Clause can be used with HAVING Clause can only be used with
5. SELECT, UPDATE, DELETE statement. SELECT statement.
WHERE Clause is used before GROUP HAVING Clause is used after GROUP
6. BY Clause BY Clause
22) Write a program to create a series object using a dictionary that stores the number of employees 2
in each department of XYZ company.
Note: Assume there are five departments namely SALES, ACCOUNTS, COMPUTER,
PURCHASE,PRODUCTION with 120,10,5,50,200 respectively
Answer:
import pandas as pd
s=pd.Series({'SALES':120, 'ACCOUNTS':10, 'COMPUTER':5, 'PURCHASE':50,
'PRODUCTION':200})
print(s)
23) What is e-waste? What is the procedure to dispose e-waste? 2
(or)
Sita has recently shifted to a new house. She does not know many people in her new street.
But all of a sudden, someone starts posting negative, demeaning comments on her social
networking profile, college site’s forum, etc. She is also getting repeated mails from unknown
people. Every time she goes online, she finds someone chasing her online.
(i) What is happening to Sita?
(ii) What action should she take to stop them?
Answer:
169
Electronic waste or e-waste describes discarded electrical or electronic devices. Used
electronics which are destined for refurbishment, reuse, resale, salvage, recycling through
material recovery, or disposal are also considered e-waste.
E-waste Disposal Process
1. Dismantling: Removal of parts containing dangerous substances(CFCs, switches, PCB);
removal of easily accessible parts containing valuable substances(cable containing copper, steel,
iron, precious metals
containing parts).
2. Segregation of ferrous metal, non-ferrous metal and plastic: This separation is normally done
in a shredder process.
3. Refurbishment and reuse: Refurbishment and reuse of e-waste has potential for those used in
electrical and electronic equipments which can be easily refurbished to put to its original use.
4. Recycling/recovery of valuable materials: Ferrous metals in electrical arc furnaces, non-
ferrous metals in smelting plants, precious metals in separating works.
5. Treatment/disposal of dangerous materials and waste: Chlorofluora-carbons(CFCs) are
treated thermally, Printed Circuit Board(PCB) disposed of in underground storages,
Mercury(Hg) is recycled or disposed off underground.
(or)
(i) Sita has become a victim of cyber bullying and cyber stalking.
(ii) She must immediately bring it to the notice of her parents and college authorities and report
this cyber crime to local police with the help of her parents.
24) Find the output of the following: 2
import pandas as pd
s=pd.Series(index=[111,222,333,444,555],data=[11,22,33,44,55])
print(s[s%2==0])
Answer:
b) print(df.ndim, df.shape)
[ or
>>>df.ndim
>>>df.shape ]
170
SECTION C
26) Write outputs for SQL queries (i) to (iii) which are based on the given table AGENT: 3 TABLE
AGENT
b)
c)
27) Write a Python code to create a DataFrame ‘df’ with column headings as ['Sports_Id', 'Name', 3
'Student', 'Team' ] and row labels as ['s1','s2','s3','s4'] using the list given below:
[[1,'Hockey',15,'B'] , [2,'Cricket',20,'D'], [3,'Chess',4,'C'], [4,'Carrom',4,'A']]
Answer:
d=[[1,'Hockey',15,'B'],[2,'Cricket',20,'D'], [3,'Chess',4,'C'],[4,'Carrom',4,'A']]
df1=pd.DataFrame(d,columns=['Sports_Id','Name','Student','Team'] ,index=['s1','s2','s3','s4'])
171
print(df1)
172
SH06 Shampoo XYZ 70 26
FW12 FaceWash XYZ 60 18
FC10 TalcumPowde ABC 120 15
r
Write SQL Commands to:
Display the average Price of each type of Product
Display the total quantity manufactured by each manufacturer if total quantity
more than 100
Display the product name, totalprice (totalprice=price x qty ) of all products arranged
in descending order of totalprice
Answer:
Select avg(Price) from Product group by Pname;
Select sum(qty) from product group by manufacturer having sum(qty)>100;
Select Pname, price*qty totalprice from Product order by totalprice;
OR
Discuss the significance of Aggregate functions in Mysql in detail and explain with example
Answer:
Aggregate Functions: Aggregate functions are functions that take a collection of values
as input and return a single value.
SQL offers five types of aggregate functions:-
Avg( ) :- To findout the average
Min( ) :- Minimum value
Max( ) :-Maximum value
Sum( ) :-To calculate the total
Count( ) :- For counting
NOTE: - The input to sum ( ) and avg( ) must be a collection of numbers, but the other
functions can operate on non numeric data types e.g.string
SECTION D
31) Write suitable SQL query for the following: 5
a) Display the position of “CHENNAI” in the string “KVSROCHENNAI”
b) Extract 5 characters from position 9 from the string “ CENTRAL BOARD OF
SECONDAY EDUCATION ”after removing leading and trailing spaces from
the string
Display the sqrt of the length of the number “1234.999” rounded off to zero
decimal places
Display the remainder of your day of birth divided by month of your birth
Display the name of the day of hiredate column of table emp
(or)
Explain the following SQL functions using suitable examples.
LTRIM ()
NOW ()
ROUND ()
173
MOD ()
INSTR ()
Answer:
SELECT INSTR('KVSROCHENNAI','CHENNAI');
SELECT MID(TRIM(" CENTRAL BOARD OF SECONDAY EDUCATION
"),9,5);
SELECT SQRT(LENGTH(ROUND(1234.999)));
SELECT MOD(DAY(DOB),MONTH(DOB)); [DOB-DATE OF BIRTH]
SELECT DAYNAME(HIREDATE) FROM EMP;
(or)
LTRIM():
The LTRIM() function removes leading spaces from a string.
Syntax: LTRIM(string) [String: Required. The string to remove leading spaces from]
NOW():
The NOW() function returns the current date and time.
Note: The date and time is returned as "YYYY-MM-DD HH-MM-SS" (string) or
as YYYYMMDDHHMMSS.uuuuuu (numeric). Syntax: NOW()
ROUND():
The ROUND() function rounds a number to a specified number of decimal places.
Syntax: ROUND(number, decimals)
MOD():
The MOD() function returns the remainder of a number divided by another
number. Syntax: MOD(x, y)
INSTR():
The INSTR() function returns the position of the first occurrence of a string in another string.
This function performs a case-insensitive search.
Syntax: INSTR(string1, string2)
32) “Anutulya Creations”-A start-up fashion house has set up its main centre at Kanpur, Uttar 5
Pradesh for its dress designing, production and dress supplying activities. It has 4 blocks of
buildings. Distance between the various blocks is as
follows:
174
Out of LAN, WAN and MAN, what type of network will be formed if we
interconnect different computers of the campus? Justify.
Suggest the topology which should be used to efficiently connect various blocks of
buildings within Kanpur centre for fast communication. Also draw the cable layout for
the same.
Suggest the placement of the following device with justification i. Repeater ii. Hub/Switch
Now a day, video-conferencing software is being used frequently by the company to
discuss the product details with the clients. Name any one video conferencing software.
Also mention the protocol which is used internally in video conferencing software
Suggest a device/software and its placement that would provide data security for the entire
network
Answer:
LAN As computers are placed with-in the same campus within a small
range. ½ Mark for correct answer ½ Mark for correct justification
Star topology ½ Mark for correct answer
Mr. Sharma is working in a game development industry and he has to compare the games
on the basis of the rating of the various games available on the play store using Bar Chart.
Help him to write the python program for the bar chart to get the desired output
Games=["Subway Surfer","Temple Run","Candy Crush","Bottle Shot","RunnerBest"]
Rating=[4.2,4.8,5.0,3.8,4.1]
Answer:
import matplotlib.pyplot as plt
classes=["12 A","12 B","12 C", "12 D"]
boys=[24,22,20,26]
girls=[18,20,22,14]
plt.plot(classes,boys,marker="o",label="boys",linestyle=":")
plt.plot(classes,girls,marker="*",label="girls",linestyle="--")
plt.xlabel("No of Students")
plt.ylabel("Classes")
plt.title("Class Strength")
plt.legend()
plt.grid()
plt.show()
(or)
176
Answer:
a) select ucase(company),lcase(item) from shop;
b) select company,max(price) from shop group by company;
c) select count(*) from shop where length(item)<5;
(or)
select count(*) from shop group by city;
35) Zeenat has created the following data frame dataframe1 to keep track of data Rollno, Name, 1+1+2
Marks1 and Marks2 for various students of her class where row indexes are taken as the
default values
16
c) print(dataframe1.loc[[1,3],'Marks1':'Marks2'])
[ or print(dataframe1.loc[[1,3],['Marks1','Marks2']]) ]
(or)
dataframe1['totalmarks']=dataframe1['Marks1']+dataframe1['Marks2']
177
SAMPLE QUESTION PAPER - V
CLASS XII
INFORMATICS PRACTICES (065)
TIME: 3 HOURS M.M.70
General Instructions:
This question paper contains five sections, Section A to E.
All questions are compulsory.
Section A have 18 questions carrying 01 mark each.
Section B has 07 Very Short Answer type questions carrying 02 marks each.
Section C has 05 Short Answer type questions carrying 03 marks each.
Section D has 03 Long Answer type questions carrying 05 marks each.
Section E has 02 questions carrying 04 marks each.
All programming questions are to be answered using Python Language only.
SECTION A
1 Which of the following is not a type of cyber-crime? 1
a. Data theft b. Damage to data and systems
c. Forgery d. Stealing Mouse
2 If column “Fees” contains the data set (5000,8000,7500,5000,8000), what will 1
be the output after the execution of the given query?
SELECT COUNT (DISTINCT Fees) FROM student;
a. 3
b. 5
c. 4
d. 2
3 Electronic products that are unwanted, not working, and nearing or at the end of 1
their “useful life.”, known as
a. Computer Waste b. E- Waste
c. Biological Waste d. Chemical waste.
4 Which amongst the following is not an example of browser ? 1
a. Chrome b. Firefox c. Avast d. Edge
5 What is the correct syntax to return both the first row and the second row in a 1
Pandas DataFrame df?
a. df.loc[[0,1]] b. df.[[0,1]]
c. df.loc[[0-1]] d. df.[[0-1]]
6 Abdul deleted all his chats from all his social media accounts, and he thinks that 1
all his traces are deleted completely. Is he right in thinking so?
a. Yes b. No c. May be d. Not sure
7 Which SQL statement do we use to find out the cardinality of the table Student? 1
a. SELECT * FROM Student;
b. SELECT COUNT (*) FROM Student;
c. SELECT COUNT (Marks) FROM Student;
d. SELECT SUM (Marks) FROM Student;
178
8 Which one of the following is not a Single row function? 1
a. ROUND ()
b. MOD ()
c. COUNT ()
d. MID ()
9 Which one of the following functions is used to find the smallest value from the 1
given data in MySQL?
a. MIN ()
b. MINIMUM ()
c. SMALLEST ()
d. Any of the above.
10 To display first five rows of a series object ‘S’, you may write: 1
a. S.head()
b. S.Tail()
c. S.Head()
d. S.tail()
11 _____________ is the function to save the graph. 1
a. Savefig() b. Savefigure() c. Savegraph() d. Savechart()
12 The command to install the pandas is: 1
a. install pip pandas b. install pandas
c. pip pandas d. pip install pandas
13 Which of the following is not a violation of IPR? 1
a. Plagiarism b. Copyright Infringement
c. Patent d. Trademark Infringement
14 In SQL, which function is used to display name of month from date? 1
a. Date () b. Month_Name () c. NameofMonth () d.Monthname()
15 A symbol, word, phrase, sound, color and design that is used to identify a product 1
or an organization is ________
a. Trademark b. Patent c. Copyright d. Plagiarism
16 FLOSS stands for ________________ 1
a) Free Legal Open-Source Systems
b) Free Libre Open-Source Software
c) Free License for Open-Source Software
d) Final License for Open Systems Software
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
a. Both A and R are true and R is the correct explanation for A
b. Both A and R are true and R is not the correct explanation for A
c. A is True but R is False
d. A is false but R is True
17 Assertion (A): Digital footprint is the trail of data we leave behind when we visit 1
any website (or use any online application or portal) to fill-in data or perform any
transaction.
Reason (R): While online, all of us need to be aware of how to conduct ourselves,
how best to relate with others and what ethics, morals and values to maintain.
18 Assertion (A): DataFrame.count() function will display the sum of the values 1
from the data frame
Reason (R): axis=0, argument is to be used to find sum column-wise
179
SECTION B
19 What do you mean by Free and Open-Source Software? What is difference between Free 2
Software and Open-Source Software?
Or
What is identity theft? How can we prevent identity thefts?
20 Rahul writes the following commands with respect to a table employee having 2
fields, empno, name, department, commission.
Command1 : Select count(*) from employee;
Command2: Select count(commission) from employee;
He gets the output as 4 for the first command but gets an output 3 for the second command.
Explain the output with justification
21 What is the purpose of Group By clause in SQL? Explain with the help of suitable 2
example.
22 Consider a given Series , M1: 2
Marks
Term1 45
Term2 65
Term3 24
Term4 89
Write a program in Python Pandas to create the series
23 According to a survey, one of the major Asian countries generates approximately about 2 2
million tonnes of electronic waste per year. Only 1.5 % of the total e-waste gets recycled.
Suggest two methods to manage e-waste.
Or
Write any 4 safety measures to reduce the risk of cyber crime.
24 Consider two objects X and Y. X is a list whereas Y is a Series. Both have 2
values 20, 40,90, 110. What will be the output of the following two statements considering
that the above objects have been created already
a. print (x*2)
b. print(y*2)
Justify your answer.
25 Consider the following DataFrame, classframe 2
Rollno Name Class Section CGPA Stream
St1 1 Aman IX E 8.7 Science
St2 2 Preeti X F 8.9 Arts
St3 3 Kartikey IX D 9.2 Science
St4 4 Lakshay X A 9.4 Commerce
Write commands to :
i. Add a new column ‘Activity’ to the Dataframe
ii. Add a new row with values ( 5 , Mridula ,X, F , 9.8, Science)
SECTION C
26 Write a program in Python Pandas to create the following DataFrame batsman 3
from a Dictionary:
B_NO Name Score1 Score2
1 Sunil Pillai 90 80
2 Gaurav Sharma 65 45
3 Piyush Goel 70 90
180
4 Kartik Thakur 80 76
Also display total score by each batsman.
27 Ms. Anubha is working in a school and stores the details of all students in a Table: SCHOOL 3
Table: SCHOOL
Admid Sname Grade House Per Gender Dob
20150001 Aditya Das 10 Green 86 Male 2006-02-20
20140212 Harsh Sharma 11 Red 50 Male 2004-10-05
20090234 Swapnil Pant 10 Yellow 84 Female 2005-11-21
20130216 Soumen Rao 9 Red 90 Male 2006-04-10
20190227 Rahil Arora 10 Blue 70 Male 2005-05-14
20120200 Akasha Singh 11 Red Female 2004-12-16
Write the SQL statements from the given table to :
(i) Remove TRAILING SPACES from column Sname.
(ii) Display the names of students who were born on Tuesday.
(iii) Display the Grades of students born in 2006.
28 Consider the following DataFrame “population” 3
Country population percent
IT Italy 61 0·83
ES Spain 46 0·63
GR Greece 11 0·15
FR France 65 0·88
PO Portugal 10 0·14
Perform the following operations on the DataFrame:
(i) Display the columns country and population.
(ii) Display all the rows where population is more than 40.
(iii)Delete the last 2 rows.
29 What do you mean by Identity theft? Explain with the help of an example. 3
OR
What do you understand by Net Etiquettes? Explain any two such etiquettes.
30 For the given table School, 3
Table : School
Admno Name Class House Percentage Gender
20150001 Abhishek Kumar 10 Green 86 Male
20140212 Mohit Bhardwaj 11 Red 75 Male
20090234 Ramandeep Kaur 10 Yellow 84 Female
20130216 Mukesh Sharma 9 Red 91 Male
20190227 Rahil Arora 10 Blue 70 Male
20120200 Swapnil Bhatt 11 Red 64 Female
Write SQL queries for the following :
(a) Display the total number of students in each House where number of students are more
than 2.
(b) Display the average Percentage of girls and boys.
(c) Display the minimum Percentage secured by the students of Class 10.
SECTION D
31 Explain the following SQL functions using suitable examples. 5
a. TRIM()
b. MID()
181
c. LEFT()
d. ROUND()
e. POW()
OR
Consider a table “MYPET” with the following data :
Table : MYPET
Pet_id Pet_Name Breed LifeSpan Price Discount
101 Rocky Labrador Retriever 12 16000 5
202 Duke German Shepherd 13 22000 10
303 Oliver Bulldog 10 18000 7
404 Cooper Yorkshire Terrier 16 20000 12
505 Oscar Shih Tzu NULL 25000 8
The school also has a branch in Mumbai. The school management wants to
connect all the wings as well as all the computers of each wing (W1, W2,
W3, W4).
Distance between the wings are as follows :
W3 to W1 85 m
W1 to W2 40 m
W2 to W4 25 m
W4 to W3 120 m
W3 to W2 150 m
W1 to W4 170 m
Number of computers in each of the wing:
W1 125
W2 40
W3 42
W4 60
182
Based on the above specifications, answer the following questions :
i. Suggest the topology and draw the most suitable cable layout for
connecting all the wings of Delhi branch.
Suggest the kind of network required (out of LAN, MAN, WAN) for connecting
(a) Administrative Wing (W1) with Middle Wing (W3)
(b) Administrative Wing (W1) with the Mumbai branch
Suggest the placement of the following devices with justification:
Repeater
Switch/Hub
Due to pandemic school had to adopt Online classes. Suggest the protocol that is used for
sending the voice signals over internet. Also, give an example of an application of WWW
that helped the teachers to send messages instantly to the students.
School 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?
33 Write code to draw the following bar graph representing the total number of medals won by 5
Australia.
Avg_week_temp=[40,42,38,44]
183
SECTION E
34 Consider the table STUDENT given below 1+1+2
Give the command to display average marks of all classes in descending order.
35 Consider the following DataFrame df1 1+1+2
POPULATION HOSPITALS SCHOOLS
DELHI 10927986 189 7916
MUMBAI 12691836 208 8508
KOLKATA 4631392 149 7226
CHENNAI 4328063 157 7617
a. Write command that will give the following output:
DELHI 10927986
MUMBAI 12691836
KOLKATA 4631392
CHENNAI 4328063
b. Display all details of DELHI
c. Predict the output of the following python statement:
i. df1.shape
ii. df1[1:3]
OR (for part c only)
Write Python statement to display the data of school column of indexes MUMBAI to
CHENNAI.
184
SAMPLE QUESTION PAPER - V
CLASS XII
INFORMATICS PRACTICES (065)
MARKING SCHEME
SECTION A
1 d. Stealing Mouse 1
2 a. 3 1
3 b. E- Waste 1
4 c. Avast 1
5 a. df.loc[[0,1]] 1
6 b. No 1
7 b. SELECT COUNT (*) FROM Student; 1
8 c. COUNT () 1
9 a MIN () 1
10 a. S.head() 1
11 a. Savefig() 1
12 d. pip install pandas 1
13 c. Patent 1
14 d. Monthname() 1
15 a. Trademark 1
16 FLOSS stands for ________________ 1
b) Free Libre Open-Source Software
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice
as
a. Both A and R are true and R is the correct explanation for A
b. Both A and R are true and R is not the correct explanation for A
c. A is True but R is False
d. A is false but R is True
17 b. Both A and R are true and R is not the correct explanation for A 1
18 d. A is false but R is True 1
SECTION B
19 Free and open-source software (FOSS) is a term used to refer to groups of software consisting 2
of both free software and open-source software where 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.
“Free Software” is a matter of liberty not price. It provides four freedom to Run, Study how the
program works, Redistributes copies, Releases improvement to the Public.
Open-Source Software:- In this type of software, the source code is freely available.
Or
Identity theft is when someone gains access to your personal information and uses it without
your permission.
1. Don't Give out Personal Information to anyone .
2. Secure Your Personal Records
185
3. Protect Your Personal Information Online ·(Or any other points)
20 There may be any NULL value in the commission column. The count() function discards NULL 2
values in a column but count(*) includes all the rows where at least one column has value, or in
other word cardinality of the table
21 Purpose of Group By clause in SQL: The GROUP BY Clause is utilized in SQL with the 2
SELECT statement to organize similar data into groups. It combines the multiple records in
single or more columns using some functions. (1)
Suitable example. (1)
22 import pandas as pd 2
M1=pd.Series(data=[45,65,24,89],index=["Term1","Term2","Term3","Term4"],name="Marks")
23 Any two methods to mange e-waste (1 mark each) 2
Or
any 4 safety measures to reduce the risk of cyber crime. ( ½ mark each)
24 Consider two objects X and Y. X is a list whereas Y is a Series. Both have 2
values 20, 40,90, 110. What will be the output of the following two statements considering that
the above objects have been created already
a. [20, 40, 90, 110, 20, 40, 90, 110])
b. 0 40
1 80
2 180
3 220
In lists, ‘*’ means replication whereas in series, it is scalar multiplication
25 i. classframe[‘Activity’] = [‘Swimming’, ’Dancing’, ’Cricket’, ‘Singing’] 2
ii. classframe.loc[‘St5’] = [1,’Mridula’, ‘X’, ‘F’, 9.8, ‘Science’]
SECTION C
26 import pandas as pd 3
d1={'B_NO':[1,2,3,4], 'Name':['Sunil Pillai','Gaurav Sharma','Piyush Goel','Kartik
Thakur'],'Score1':[90,65,70,80],'Score2':[80,45,95,76]}
batsman=pd.DataFrame(d1)
batsman["Total"]=batsman.Score1+batsman.Score2
print(batsman[["Name", "Total"]])
27 (i) SELECT RTRIM(Sname) FROM SCHOOL 3
(ii) SELECT Sname FROM SCHOOL WHERE DAYNAME(DOB)= “TUESDAY”
(iii) SELECT GRADES FROM SCHOOL WHERE YEAR(DOB) = 2006.
28 (i) df[["Country","population"]] 3
(ii) print(df[df["population "]>40])
(iii)df.drop(df.tail(n).index, inplace = True)
29 Identity theft is the crime of obtaining the personal or financial information of another person 3
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.
OR
Net Etiquettes refers to the proper manners and behaviour we need to exhibit while being
online.
186
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, degrading or 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.
(Or any other )
30 (a) SELECT HOUSE, COUNT(*) FROM SCHOOL GROUP BY HOUSE HAVING 3
COUNT(*)>2.
(b) SELECT GENDER, AVG(PERCENTAGE) FROM SCHOOL GROUP BY GENDER;
(c) SELECT MIN(PERCENTAGE) FROM SCHOOL WHERE CLASS =10.
SECTION D
31 Explanation of the SQL functions using suitable examples. (½ mark for explanation and ½ mark 5
for example)
a. TRIM()
b. MID()
c. LEFT()
d. ROUND()
e. POW()
OR
Write SQL queries for the following:
(i) SELECT UPPER(Breed) FROM MYPET
(ii)SELECT SUM(PRICE) FROM MYPET.
(iii)SELECT AVG(LifeSpan) FROM MYPET.
(iv) SELECT INSTR(“Innovation”,”at”);
(v)SELECT ROUND (456,-2);
32 i. BUS OR STAR Anyone can be used. 5
ii. Suggest the kind of network required (out of LAN, MAN, WAN) for connecting
(a) Administrative Wing (W1) with Middle Wing (W3): LAN
(b) Administrative Wing (W1) with the Mumbai branch: WAN
iii. Suggest the placement of the following devices with justification:
(a) Repeater: Repeater to be placed based on layout drawn in part(i), between two
physically connected buildings wherever the distance between the two
buildings is more.
(b) Switch/Hub: in all buildings
iv. Protocol name : VoIP OR Voice Over Internet Protocol
WhatsApp, Slack, Skype, Yahoo Messenger, Google Talk, Facebook Messenger,
Google Hangout, Instant Messenger
Any of the above or any other correct example of an application of WWW for
instant messaging.
v. dynamic
33 import matplotlib.pyplot as plt 5
X=['Gold','Silver','Bronze','Total']
Y=[75,50,50,200]
plt.bar(X,Y)
plt.xlabel('Medals won by Australia')
plt.ylabel('Medals won')
plt.title('AUSTRALIA MEDAL PLOT')
187
plt.show()
To save the chart
plt.savefig()
OR
import matplotlib.pyplot as plt
Week=[1,2,3,4]
Avg_week_temp=[40,42,38,44]
plt.plot(Week,Avg_week_temp)
plt.xlabel('WEEK')
plt.ylabel('AVERAGE WEEKLY TEMPERATURE')
plt.show()
SECTION E
34 Consider the table STUDENT given below 1+1+2
188