Class 12th QuestionBank InformaticsPractices
Class 12th QuestionBank InformaticsPractices
MUMBAI REGION
INFORMATICS PRACTICES-XII
Question Bank
2023-2024
Key Features:
CBSE Question
SAMPLE MIND MAPS
Bank
PAPER
Latest Question Paper Includes question based on To memorize and review the
latest question papers. topics quickly
हमारे संर क
OUR PATRONS
Q.9 Given a Pandas series called Sample, the command which will display the last 3 rows
is .
Ans. print(Sample.tail(3))
Q.10 Given a Pandas series called Sequences, the command which will display
the first 4 rows is .
Ans. print(Sequence.head(4))
Q5. Consider the following Series object, “company” and its profit in Crores
TCS 350
Reliance 200
L&T 800
Wipro 150
(i) Write the command which will display the name of the company
having profit>250.
(ii) Write the command to name the series as Profit.
SA – Short Answer Question (for 3 Marks)
What will be the output of the following two statements considering that the above
objects have been created already
a. print(a*2) b. print(b*2)
Justify your answer.
Ans.
a. will give the output as:
[10,20,25,50,10,20,25,50]
b. will give the output as
0 20
1 40
2 50
3 100
Justification: In the first statement a represents a list so when a list is multiplied by a
number, it is replicated that many number of times.
The second b represents a series. When a series is multiplied by a value, then each
element of the series is multiplied by that number.
Q.2 Explain the data structure in Pandas
Ans. Data structure is defined as the storage and management of the data for its
efficient and easy access in the future where the data is collected, modified and the
various types of operations are performed on the data respectively.
Pandas provides two data structures for processing the data, which are described below :
(i) Series : It is an one dimensional object similar to an array, list or column in
a table. It will assign a labelled index to each item in the series. By default,
each item will receive an index label from 0 to N, where N is the length of
the series minus one.
(ii) DataFrame : It is a tabular data structure comprised of rows and columns.
Data Frame is defined as a standard way to store data and has two different
indexes i.e., row index and column index.
Q.3 What is slicing ?
Ans. Slicing is a powerful approach to retrieve subsets of data from a Pandas object. A
slice object is built using a syntax of start : end : step, the segments representing the first
item, last item and the increment between each item that you would like as the step.
Q.3 is a general term for taking each item of something, one after another.
Ans. Iteration.
Q.4 function return last n rows from the object based on position.
Ans. tail( )
Q.6 Boolean indexing helps us to select the data from the DataFrame using .
Ans. boolean vector.
Q.9 Hitesh wants to display the last four rows of the dataframe df and has written the
following code :
df.tail( )
but last 5 rows are being displayed. Identify the errors and rewrite the correct code so that
last 4 rows get displayed.
Ans. df.tail(4)
Q.10 Consider the following Python code and write the output for
statement. import pandas as pd
values=[“India”, “Canada”]
code=[“IND”, “CAN”]
df=pd.DataFrame(values,Index=Code,columns=[‘Country’]
Ans.
Code Country
IND India
CAN Canada
Q.11 The teacher needs to know the marks scored by the student with roll number 4. Help her
to identify the correct set of statement/s from the given options :
a. df1=df[df[‘rollno’]==4]
print(df1)
b. df1=df[rollno==4]
print(df1)
c. df1=df[df.rollno=4]
print(df1)
d. df1=df[df.rollno==4]
print(df1)
Ans.
a. df1=df[df[‘rollno’]==4]
print(df1)
d. df1=df[df.rollno==4]
print(df1)
Q.12
In Pandas the function used to delete a column in a DataFrame is
a. remove
b. del
c. drop
d. cance
l Ans. (b) del
Q.13 function applies the passed function on each individual data element of
the dataframe.
a. apply() b. applymap() c. pivot() d. pivot_table()
Ans. a. apply()
Q.14 Which of the following statement/s will give the exact number of values
in each column of the dataframe?
i. print(df.count())
ii. print(df.count(0))
iii. print(df.count)
iv. print(df.count(axis=’index’))
Choose the correct option:
a. both (i) and (ii)
b. only (ii)
c. (i), (ii) and (iii)
d. (i), (ii) and (iv)
Ans. a. both (i) and (ii)
Q.15 Which of the following command will display the column labels of the DataFrame?
a. print(df.columns()) b. print(df.column()) c. print(df.column) d.
print(df.columns) Ans. a. print(df.columns()) or d. print(df.columns)
Df1 Df2
Mark1 Mark2 Mark1 Mark2
0 10 20 0 10 15
1 40 45 1 20 25
2 15 30 2 25 30
3 40 70 3 50 30
Write the commands to do the following operations on the DataFrames given below :
(i) To add DataFrames Df1 and Df2
(ii) To subtract Df2 from Df1
(iii) To Rename column Mark1 as Marks1 in both the DataFrame Df1 and Df2
(iv) To Change index label of Df1 from 0 to zero and from 1 to one.
Ans.
import numpy as np
import pandas as pd
Df1=pd.DataFrame({‘Mark1’ :[10,40,15,40],’Mark2’ : [20,45,30,70]})
Df2=pd.DataFrame({‘Mark1’ :[10,20,25,50],’Mark2’ : [15,25,30,30]})
print(Df1)
print(Df2)
(i) print(Df1.add(Df2))
(ii) print(Df1.sub(Df2))
(iii) Df1.rename(columns={‘Mark1’ : ‘Marks1’}, inplace =True)
print(Df1)
(iv) Df1.rename(columns={0: ‘zero’,1: ‘one’}, inplace =True)
print(Df1)
Q.2 Consider the following DataFrame emp and answer any four questions from (i) to (v)
Empno Name Dept Salary Experience
(in years)
1 Ram Singh IT 15000 2.5
2 Shyam Singh HR 18000 3
3 Nidhi Gupta IT 9000 2
4 Pooja Sharma EXE 24000 8
5 Rohan Malik HR 20000 6
(i) Write down the command that will give the following
output.
Empno 5
Name Rohan Malik
Dept HR
Salary 20000
Experience 6
dtype: object
a. print(emp.max)
b. print(emp.max())
c. print(emp.max(axis=1))
d. print(emp.max,axis=1)
(ii) CEO needs to know the salary of the employee with empno 4. Help him
to identify the correct set of statement/s from the given options:
a. emp1=emp[emp[‘empno’]==4]
print(emp1)
b. emp1=emp[emp]
print(emp1)
c. emp1=emp[emp.empno=4]
print(emp1)
d. emp1=emp[emp.empno==4]
print(emp1)
(iii) Which of the following statement/s will give the exact number of values in
each column of the dataframe?
i. print(emp.count())
ii. print(emp.count(0))
iii print(emp.count)
iv. print(emp.count(axis=’index’))
(ii) a. emp1=emp[emp[‘empno’]==4]
print(emp1)
d.emp1=emp[emp.empno==4]
print(emp1)
(iii) a. both (i) and (ii)
(iv) d. print(emp.columns)
(v) b. emp[‘Performance’]=[ ’A’,’A’,’B’,’A’,’B’]
Q.3 A dataframe fdf stores data about passengers, Flights and Years. First fews of the
dataframe are shown below.
Year Months
Passengers 0 2009
January 112
1 2009 February 118
2 2009 March 132
3 2009 April 129
4 2009 May 121
Using the above DataFrame, Write commands for the following:
(a) Compute total passengers per Year
(b) Compute average passengers per Month.
Ans.
(i) fdf.pivot_table(index='year', value='passengers', aggfunc='sum')
(ii) fdf.pivot_table(index='month', values='passengers', aggfunc='mean')
Write the code in Pandas to create the above dataframes and write the command to
perform following operations on the dataframes Cls1 and Cls2:
(i) To subtract Cls2 from Cls1.
(ii) To add Cls1 and Cls2.
(iii) To rename column Hindi as Science in Cls1.
(iv) To change the index label of Cls1 from 2 to two and from 3 to
three. Ans.
Dataframe contents are
Name Age Score
0 Anu 26 87
1 Abhishek 25 67
2 Rajeev 24 89
3 Ritu 31 55
Name 4
Age 4
Score 4
dtype: int64
OR
import numpy as np
import pandas as pd
Cls1=pd.DataFrame({'Eng':[43,23,65,12],'Maths':[42,41,57,14],
'Hindi':[40,53,62,17]})
Cls2=pd.DataFrame({'Eng':[32,54,31,21],'Maths':[53,21,73,51],
'Hindi':[31,65,36,43]})
(i) print(Cls1.subtract(Cls2))
(ii) print(Cls1.add(Cls2))
(iii) Cls1.rename(columns={'Hindi':'Science'},inplace=True)
(iv) Cls1.rename(index={2:"Two",3:"Three"},inplace=True)
Q.10 Mr.Sanjay wants to plot a bar graph for the given set of values of subjects on x-axis
and number of students who opted for that subject on y-axis.
Complete the code to perform the following operation
Q.15 Using Python Matplotlib can be used to count how many values
fall into each interval
a. line plot
b. bar graph
c. histogram
Ans. c. histogram
Q.16 Mr. Harry wants to draw a line chart using a list of elements named LIST. Complete
the code to perform the following operations :
(i) To plot a line chart using the given LIST
(ii) To give a y-axis label to the line chart named sample
number. import matplotlib.pyplot as PLINE
LIST=[10,20,30,40,50,60]
#statement 1
#statement 2
Ans. (i) PLINE.plot(LIST)
(ii) PLINE.ylabel(“Sample number”)
Q.17 In matplotlib, what is ticks?
Ans. A standard graph shows the marks on the axis, in matplotlib library, it is called ticks.
Q.20 Assuming that a line chart is plotted on x and y axis, write the command to give title
as ‘New Graph’ using Plt object
Q.1 Consider the following graph. Write the code to plot it.
Ans.
import matplotlib.pyplot as
plt a = [0,1,2,3,4,5]
b = [10,31,26,24,20]
plt.plot(a,b
) plt.show()
Q.2 Write code to draw the following bar graph representing the number of students in
each class.
Ans.
import matplotlib.pyplot as
plt Classes = ['VII','VIII','IX','X']
Students = [40,45,35,44]
plt.barh(classes,
students) plt.show()
Q.5 Write code to plot a line graph showing the relation between channel name and its
TRP rating ( 4 channels). Include the titles and formatting of your choice. The font size of
the x and y labels should be 15 and font color should be green
Ans.
import matplotlib.pyplot as p
x=["Sony","Star","SAB","Zee"]
y=[60,40,55,35]
p.plot(x,y, linestyle=":")
p.title('TRP of various channels')
p.xlabel('Name of Channel',fontsize="15",color="green")
p.ylabel('TRP',fontsize="15",color="green")
p.show()
Q.6 Consider the following graph. Write a program in python to draw it along with proper
labeling of X-axis, Y-axis and Title for the line Chart of your choice.
Ans.
import numpy as np
import matplotlib.pyplot as
plt x=np.linspace(-2, 2,50)
y=x*x
plt.plot(x,y)
plt.title('Y = x * x')
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
plt.show()
Q.7 Consider the following graph. Write a program in python to draw it. (Height of Bars are
10,1,0,33,6,8)
Ans.
import numpy as np
import matplotlib.pyplot as plt
plt.hist([0,10,20,30,40,50],bins=[0,10,20,30,40,50,60],weights=[10,1,0,3
3,6,8],edgecolor='yellow')
plt.title('Histogram of Student Data')
plt.xlabel('value')
plt.ylabel('Frequency')
plt.show()
Kendriya Vidyalaya Sangthan Mumbai Region
2023-24
1 Mark questions-
S NO Questions Answer
a. thick
6 b. thickness Width
c. width
d. barwidth
S1
A 10
20
8 B 20
30
C 30
D 40
9 (a) plt.show() D
a.<DF>.read_csv(<file>)
10 b. <File>.read_csv(<DF>) A
c.<DF>=pandas.read(<file>)
d. <DF>=pandas.read_csv(<files>)
1. plt.show()
12 2. plt.plot() C
3. plt.hist()
4. plt.histt()
a. It is a part of Pandas
I 2
False
J 4
False
14 K 8
True
L 10 True
a. S1>4
a) rename()
17
b) reindex()
c) reframe()
A 30 A 80
19 S1.sub(S2)
B 70 B 60
C 44 C 94
D 80 D 40
import numpy as np
arr=np.array([21,22,23,24,25,26,27,28,29,30])
20 print(arr[4:9]) a
22 c
1. bar() (b) hist() (c) histh() (d)barh()
S1
A 10
20
B 20
25 30
C 30 40
D 40
1. plt.show()
26 2. plt.title() plt.show()
3. plt.xlabel()
4. plt.plot()
Mohan create a Pandas series with name Marks, he typed command
print(Marks.head())
S1
A 10
28 B 20 print(S1/2)
C 30
D 40
Write the command to print the half the value of given series.
29 Axes of a graph can be labeled using _____ and ______ functions. xlabel and ylabel
What will be the output of the following code?
import pandas as pd
30 [6,6,6,6,6]
s = pd.Series(6,index=range(0,5))
print(s)
Fill in the blanks with correct library to execute the given code.
import____________________ as plt
import numpy as np
31 matplotlib.pyplot
plt.plot(ypoints)
plt.show()
Rohan wants to print the row labels of the dataframe. He should use
32 index
the _____________ attribute of a dataframe.
import pandas as pd
33 1
import numpy as np
s = pd.Series(np.random.randn(4))
print (s.ndim)
The command used to save the figure (graph) is savefig function. It
34 Name of the file
takes one compulsory argument. What does that specify?
Names
Name1 Amit
Name2 Suraj
Name3 Srinidhi
Table 350
Chair 200
Sofa 800
Stool 150
(i) Write the command which will display the name of the furniture having rent greater than
250
(ii) Write the command to name the series as Furniture
Write commands to
(a) Add a new column ‘percentage’ to the dataframe with a scalar value.
(b) Add a new row with values of your choice.
(b)
Q.5 Write program to create a Series have 10 random numbers in the range of 10 and 20.
Ans:
100 500
101 500
102 500
103 500
104 500
index
Ans:
Pen 50
Pencil 100
Eraser 70
Sharpener 80
i. Write the command which will display the name of the item having price >70.
ii. Write the command to name the series as ITEM.
LONG QUESTION (3-4-5 Marks)
Q.1 Consider the following DataFrame, df
Write commands to :
i. Add a new column ‘Course’ to the Dataframe with values which are any computer science
related field.
ii. Add a new row with values (Sam,456,Chennai,Data Science)
iii. Display the average of TMarks column
Ans:
Q.2 Consider the two objects s1 and s2. s1 is a list whereas s2 is a Series. Both have values 10,
20, 30, 40, 50.
What will be the output of the following two statements considering that the above objects
have been created already
a. print(s1 * 2) b. print(s2 * 2)
Justify your answer
Ans:
Q.3 Consider the following graph . Write the code to plot it.
Ans:
Q.4 Draw the following bar graph representing the Production by Factory.
Q.5
5 Marks
Q.1 Write a program in python Pandas to create the following DataFrame Student from a
Dictionary.
Ans:
Q.2 Consider the following DataFramen df as shown below :
Col1 Col2 Col3 Res
T1 62.893165 100.0 60.00 True
T2 94.734483 100.0 59.22 True
T3 49.090140 100.0 46.04 False
T4 38.487265 85.4 58.60 False
Ans:
Q.3 Write a program in Python Pandas to create the following DataFrame PLAYER from a
Dictionary:
Ans:
Q.5 Write a program in Python Pandas to create the following DataFrame stuDF from a
Dictionary of List:
Ans:
Q.8 Write a program in Python Pandas to create the DataFrame Stationary from
following data:
Company is storing the above information in a CSV file “Qtrly_Sales.csv”. Mr. Rohit is a
programmer. Company has given him the responsibility to create the program to visualise
the above data. He wrote Python code but he is facing some difficulties. Help him by giving
the solutions of following situation:
Python code:
import pandas as pd
import ________________ as plt
df=__________("Qtrly_Sales.csv")
df.plot(__________='bar',
color=['red','blue','brown',’green’])
plt.___________('Quarterly Report')
plt.xlabel('Salesman')
plt.ylabel('Sales')
plt._________()
Ans:
Q.10 Sanyukta is the event incharge in a school. One of her students gave her a suggestion to use
Python Pandas and Matplotlib for analysing and visualising the data, respectively. She has
created a Data frame “df” to keep track of the number of First, Second and Third prizes won
by different houses in various events.
Write Python commands to do the following:
a. Display the house names where the number of Second Prizes are in the range of 12 to 20.
b. Considering above DataFrame df which python command use to display all the records
in the reverse order.
c. Considering above DataFrame df which python command use Display the bottom 3
records.
d. What will be the output of the following command.
x=df.columns[:1]
print(x)
Ans:
Q.11 Mr. Pramod was planning to teach about the Olympics in one of his upcoming classes. He
took help from a student of class XII to prepare the data for analysis and visualization. In the
process there are a couple of problems that still need to be resolved. Kindly help them out.
import pandas as pd
import numpy as np
src='DataViz/master/India_at_Olympics_Medal_by_year.csv'
df=pd._________(src) # Statement 1
print(df.head())
print(df.______) # Statement 2
a. Which method should be placed in the blank space in statement 1 to read the data from the
csv file?
b. Which method should be placed in the blank space in statement 2 to display the last five
rows from the data frame?
c. Which statement will be used to save the data of 10 most recent olympics in a new object
df_last10?
d. Mr. Pramod only wants to display the summer olympic data (Row index 0, 2, 4.... represents
summer olympics), What would be an appropriate statement to do that?
e. Mr. Pramod wants to change the index of the Data Frame which should start with 1 instead
of 0. Identify the correct statement to change the index.
Ans:
Q.12 Mr. Sethi wants to write Python code to create the following data frame containing marks of
3 students. However, he is facing some problems. Help him by answering a few questions
below.
c. He wants to rename the column M1 to MT1, Write the command should he execute?
d. He wants to obtain the sum of marks for each student as given below. 1 Choose the
correct statement to obtain the same.
e. He wants to modify the value 16 of S2, M3 to 20. Write command to do the same.
Q.13 Write a program in Python Pandas to create the following DataFrame df1 from a dictionary :
Perform the following operations on the DataFrame :-
a) Write command to compute sum of every column of the DataFrame.
b) Write command to compute mean of column Rainfall.
c) Write command to display maximum temperature of cities having rainfall less than 40cm.
Q.14 Write a program in Python Pandas to create the following DataFrame ‘Order’ for an online
shopping app:
Ans:
Q.15 Consider the following graph. Write a program in python to draw it. (Height of Bars are
10,1,0,33,6,8) Take care of axis label and title.
Ans:
Dataframe attributes Create Dataframe
axes Return a list representing the axes of the
DataFrame. pandas.DataFrame( data, index, columns, dtype)
columns The column labels of the DataFrame. data : takes various forms like ndarray, series, map, lists, dict, constants and
dtypesReturn the dtypes in the DataFrame. also another DataFrame.
index The index (row labels) of the DataFrame. index : For the row labels,
Iteration over row ndim Return an int representing the number of axes / columns : For column labels
Features of Dataframe array dimensions. dtype : Data type of each column.
# row iteration - 2D structure shape Return a tuple representing the dimensionality of
i mpor t pandas as pd
import pandas as pd - Potentially columns are of different the DataFrame. l =[ [ 1, 10, ' a' ] , [ 2, 20, ' b' ] , [ 3, 30, ' c ' ] ]
dic={"SName":["Radha","Sam","Ameer","Aman"], types size Return an int representing the number of df = pd. Dat aFr ame( l )
"Gender":['F','M','M','M'],"Age":[17,18,20,18]} - Size ? Mutable elements in this object. pr i nt ( df )
df = pd.DataFrame(dic) - Labeled axes (rows and columns) values Return a Numpy representation of the
- Can Perform Arithmetic operations on 0 1 2
print(df) DataFrame.
rows and columns 0 1 10 a
print("Iterate using iterrows:") 1 2 20 b
for i,j in df.iterrows(): 2 3 30 c
print(j)
print("------") import pandas as pd
l=[[1,3,-9],[4,5,6],[7,5,8]]
print("Iterate using iteritems:") Observe the
df = pd.DataFrame(l,index=["r1","r2","r3"],columns=["c1","c2","c3"]) arrengement of
for key,value in df.iteritems(): print(df) row and
print(value) c1 c2 c3 columns
print("Iterate using itertuples:") r1 1 3 -9
for i in df.itertuples(): r2 4 5 6
print(i) r3 7 5 8
Observe the
#Dataframe using dictionary
Iteration over column import pandas as pd
arrengement of
row and
#column iteration dic = {'one':[1,2,3,4],'two':[5,6,7,8],'three':[9,10,11,12]} columns
import pandas as pd df = pd.DataFrame(dic)
dic={"Name":["Radha","Sam","Ameer","Aman"], Pandas print(df)
one two three
"Gender":['F','M','M','M'],"Age":[17,18,20,18]} Dataframe 0 1 5 9
df = pd.DataFrame(dic) 1 2 6 10 As no columns match the
print("Iterate over columns") 2 3 7 11 keys Dataframe is empty.
for i in df.columns: 3 4 8 12 Even if one column matches
print(df[i]) then the Dataframe would
import pandas as pd be created with that column
dic = {'one':[1,2,3,4],'two':[5,6,7,8],'three':[9,10,11,12]} vakues and remaining
df = pd.DataFrame(dic,columns=['c1','c2','c3']) columns NaN
print(df)
Empty DataFrame
Arithmetic Operations Columns: [c1, c2, c3]
Index: []
import pandas as pd
# Dataframe from dictionary using from_dict ( )
import numpy as np import pandas as pd Observe the
arr1 = np.random.randint(1,10,(3,3)) dic = {'one':[1,2,3,4],'two':[5,6,7,8],'three':[9,10,11,12]} effect of
arr2 = np.random.randint(1,10,(3,3)) df = pd.DataFrame.from_dict(dic,orient="index") orientation on
df1 = pd.DataFrame(arr1) print(df) the index and
df2 = pd.DataFrame(arr2) df = pd.DataFrame.from_dict(dic,orient='columns') column.
All the corresponding print(df)
df3 = df1 + df2 elements of both 0 1 2 3
print("The addition is:") dataframes would be one 1 2 3 4
print(df3) taken as two operans for two 5 6 7 8
df3 = df1 - df2 the operations. three 9 10 11 12
print("The subtraction is:") one two three
0 1 5 9
print(df3) 1 2 6 10 Any numpy
df3 = df1 * df2 2 3 7 11 method to create
print("The multiplication is:") 3 4 8 12 array can be
used.
print(df3)
df3 = df1 / df2 # Data frame using numpy array
import pandas as pd
print("The division is:")
import numpy as np
print(df3) a = np.random.randint(0,20,size=(3,3))
df3 = df1 % df2 df = pd.DataFrame(a) If there is NaN value in
print("The modulus is:") print(df) the data the complete
print(df3) 0 1 2 data is considered to
0 18 18 10 be a float.
1 17 4 1
2 13 0 16
Mathematical Operations with NaN values
# Dataframe using Series
import pandas as pd
import pandas as pd s1 = pd.Series([1,2,3,4])
import numpy as np s2 = pd.Series([5,6,7,8])
arr1 = np.random.randint(1,10,(3,4)) s3 = pd.Series([9,10,11,12])
s1 = pd.Series([2,3,5,6]) df = pd.DataFrame([s1,s2,s3]) Write complete
s2 = pd.Series([1,5,8,4]) print(df) path for the text
0 1 2 3 file. Header
df1 = pd.DataFrame(arr1) 0 1 2 3 4 specified the row
df2 = pd.DataFrame([s1,s2]) 1 5 6 7 8 that is to be taken
print("The Dataframe 1 is:") 2 9 10 11 12 as column labels.
print(df1)
print("The Dataframe 2 is:") # Dataframe using Text file
import pandas as pd
print(df2)
df=pd.read_table("data.txt",header=0)
df3 = df1.add(df2 , axis = 0) print(df)
print("The addition along axis = 0 is:")
print(df3) import pandas as pd
df3 = df1.add(df2, axis = 0,fill_value=1) df=pd.read_table("data.txt",header=0)
print(df)
print("The addition along axis = 0 is:") index_col gives
regno roll name
print(df3) 0 1 34 Rajesh the column to be
The Dataframe 1 is: 1 2 42 Suman used as index
0 1 2 3 label.
0 8 7 8 9 import pandas as pd
1 5 1 5 9 df=pd.read_csv("student1.csv",index_col=0)
print(df)
2 6 5 6 8 Name Eng Phy Chem Maths IP
The Dataframe 2 is: Roll No
0 1 2 3 12 Kishore 23 54 36 56 54
0 2 3 5 6 44 Tarun 34 65 45 46 52
1 1 5 8 4
df = pd.DataFrame({'name': ['Raphael', 'Donatello'],
The addition along axis = 0 is: 'mask': ['red', 'purple'],
0 1 2 3 'weapon': ['sai', 'bo staff']})
0 10.0 10.0 13.0 15.0 df.to_csv(index=False)
1 6.0 6.0 13.0 13.0
2 NaN NaN NaN NaN
The addition along axis = 0 is:
0 1 2 3
0 10.0 10.0 13.0 15.0 Head and Tail function
1 6.0 6.0 13.0 13.0
2 7.0 6.0 7.0 9.0 import pandas as pd
df = pd.read_csv("StudentsPerformance.csv")
Selection using dot operator print(df.shape)
#first n rows
# selection using dot operator print(df.head(2))
import pandas as pd #last n rows
df = pd.read_csv("StudentsPerformance.csv",index_col=['Reg No']) print(df.tail(14))
print(df)
print("Selected column values for gender are : ") The columns Note : Default value of n is 5
print(df.gender) having labels i.e. df.tail() will display last 5 rows
with spaces can
not be accessed
Selection using [ ] with dot
operator. Rename Row / Column
# selection using [ ]
import pandas as pd import pandas as pd
df = pd.read_csv("StudentsPerformance.csv",index_col=['Reg No']) import numpy as np
print("Selected column values for reading score are : ") a = np.random.randint(1,10,(4,5))
print(df[['reading score','writing score']]) df = pd.DataFrame(a,columns = ['a','b','c','d','e'],index=['Row1','Row2','Row3','Row4'])
df2 = df.rename(index={'Row1':1,'Row2':2,'Row3':3,'Row4':4} )
print("The new Dataframe is:")
print(df2)
df2 = df.rename(columns={'a':1,'b':2,'c':3,'d':4,'e':5} )
print("The new Dataframe is:")
Selection using loc print(df2)
import pandas as pd
df = pd.read_csv("StudentsPerformance.csv",index_col="Reg No")
print(df)
#print("A selection of row based on label is:\n") Delete Row / Column
#print(df.loc[235 : 575,])
import pandas as pd
#print("A selection of multiple discrete rows based on label is:\n") import numpy as np
#print(df.loc[[231 , 475],]) a = np.random.randint(1,10,(3,5))
Remember : both df=pd.DataFrame(a)
#print("A selection of alternate rows based on label is:\n") the starting and print("The original Dataframe")
#print(df.loc[::2,]) print(df)
ending label is df.drop(0,axis=0,inplace=True)
#print("A selection cross section of a row and column is:\n") included in the print("The Dataframe after deleting 0th row")
#print(df.loc[[231,475],'race/ethnicity']) print(df)
range while using #discrete rows to be deleted.
#print("A selection cross section of a row and column is:\n") loc to make df.drop([0,3],axis=0,inplace = True)
#print(df.loc[[342,377],['race/ethnicity','math score']]) print("The Dataframe after deleting rows")
selection. print(df)
print("Selection using slicing of rows \n")
newdf=df.loc[332:543,'gender':'reading score':2]
print(newdf)
Chapter Practice:
ORDER BY emp_id;
16. A School in Delhi uses database management system to store student details. The
school maintains a database 'school_record' under which there are two tables.
Student Table Maintains general details about every student enrolled in school.
Student
Field Type
StuID numeric
StuName varchar(20)
StuAddress varchar(50)
StuFatherNam varchar(20)
e
StuContact numeric
StuAadhar numeric
varchar(5)
StuSection varchar(1)
StuLibrary
Field Type
BookID numbric
StuID numbric
Issued_d Date
ate
Return_d Date
ate
(i) Identify the SQL query which displays the data of StuLibrary table in ascending
order of student ID.
I. SELECT * FROM StuLibrary ORDER BY BookID;
II. SELECT * FROM StuLibrary ORDER BY StuID;
III. SELECT * FROM StuLibrary ORDER BY StuID ASC;
IV. SELECT * FROM StuLibrary ORDER BY StuID DESC;
Choosethecorrectoption,whichdisplaysthe desired data.
Column Name
Store_ID
Sales_Date
Sales_Amount
(i) Which SQL statement allows you to find the highest pricefrom
thetable Book_Information?
(a) SELECT Book_ID,Book_Title,MAX(Price) FROM Book_Information;
(b) SELECT MAX(Price) FROMBook_Information;
(c) SELECT MAXIMUM(Price) FROM Book_Information;
(d) SELECT Price FROM Book_Information ORDERBY Price DESC ;
Ans. (b) SELECT MAX(Price) FROM Book_Information;
(ii) WhichSQL statement allows youto find sales amount for each store?
(a) SELECT Store_ID, SUM(Sales_Amount) FROMSales;
(b) SELECT Store_ID, SUM(Sales_Amount) FROM Sales ORDER BY Store_ID;
(c) SELECT Store_ID, SUM(Sales_Amount) FROMSales GROUP BY Store_ID;
(d) SELECT Store_ID, SUM(Sales_Amount) FROMSales HAVING UNIQUE Store_ID;
Ans. (c) SELECT Store_ID, SUM(Sales_Amount) FROMSales GROUP BY Store_ID;
(iii) Which SQL statement lets you to list all storename whose total sales amount is over 5000 ?
(a) SELECT Store_ID, SUM(Sales_Amount) FROMSales GROUP BY Store_ID
HAVING SUM(Sales_Amount) > 5000;
(b) SELECT Store_ID, SUM(Sales_Amount) FROMSales GROUP BY Store_ID HAVING
Sales_Amount >5000;
(c) SELECT Store_ID, SUM(Sales_Amount) FROMSales WHERE SUM(Sales_Amount) > 5000
GROUP BY Store_ID;
(d) SELECT Store_ID, SUM(Sales_Amount) FROMSales WHERE Sales_Amount > 5000
GROUP BYStore_ID;
Ans. (a) SELECT Store_ID, SUM(Sales_Amount) FROMSales GROUP BY Store_ID HAVING
SUM(Sales_Amount) > 5000;
(iv) Which SQL statement lets you find thetotal number of stores in the SALES table?
(a) SELECT COUNT(Store_ID) FROM Sales;
(b) SELECT COUNT(DISTINCT Store_ID) FROM Sales;
(c) SELECT DISTINCT Store_ID FROM Sales;
(d) SELECT COUNT(Store_ID) FROM Sales GROUPBY Store_ID;
Ans. (d) SELECT COUNT(Store_ID) FROM Sales GROUP BY Store_ID;
(v) Which SQL statement allows you to find the total sales amountfor Store_ID 25 and
the totalsales amount for Store_ID 45?
(e) SELECT Store_ID, SUM(Sales_Amount) FROM Sales WHERE Store_ID IN ( 25, 45)
GROUP BY Store_ID;
(f) SELECT Store_ID, SUM(Sales_Amount) FROM Sales GROUP BY Store_ID
HAVING Store_ID IN ( 25, 45);
(g) SELECT Store_ID, SUM(Sales_Amount) FROMSales WHERE Store_ID IN (25,45);
(h) SELECT Store_ID, SUM(Sales_Amount) FROM Sales WHERE Store_ID = 25 AND
Store_ID =45 GROUPBY Store_ID;
Ans. (b) SELECT Store_ID, SUM(Sales_Amount) FROM Sales GROUP BY Store_ID
HAVING Store_ID IN ( 25, 45);
ShewantstodisplayhighestAggobtainedineach Stream.
But she did not get the desired result. Rewrite the abovequerywithnecessarychangestohelp
herget the desired output.
FROM EMPLOYEE
GROUP BY Stream;
Ans: A HAVING clause is like a WHERE clause, but applies only to groups as a whole (that is, to the
rows in the result set representing groups), whereas the WHERE clause applies to individual
rows. A query can contain both a WHERE clause and a HAVING clause.
GROUP BY Deptcode;
7. Writeaquerythatcountsthenumberofdoctors registeringpatientsforeachday.(Ifa
doctorhas morethanonepatient onagivenday, he orshe should be counted only once.)
P_ID ProductName Manufact Price
ure
TP01 TALCOM POWDER LAK 40
FW05 FACE WASH ABC 45
BS01 BATH SOAP ABC 55
SH06 SHAMPOO XYZ 120
FW12 FACE WASH XYZ 95
Ans. SELECT ord_date, COUNT (DISTINCT doctor_code) FROM Patients
GROUP BY ord_date;
8. Consider the table DOCTOR given below. Write commands in SQL for (i) to (ii) and
output for (iii) to (v).
Table : DOCTOR
ID DOCName Department DOJ Gender Salary
1 Amit Kumar Orthopaedics 1993-02-12 M 35000
2 Anita Hans Paediatrics 1998-10-16 F 30000
3 Sunita Maini Gynaecology 1991-08-23 F 40000
4 Joe Thomas Surgery 1994-10-20 M 55000
5 Gurpreet Paediatrics 1999-11-24 F 52000
6 Anandini Oncology 1994-03-16 F 31000
(i) Displaythenamesandsalariesofdoctorsin descending order ofsalaries.
(ii) Displaynamesofeachdepartmentalongwithtotal salary being given to doctorsof
thatdepartment.
(iii) SELECT SUM(Salary) FROM DOCTOR WHERE
Department==‘Surgery’;
(iv) SELECT Department, COUNT(*) FROM DOCTOR GROUP BY
Department;
(v) SELECT DOCName FROM DOCTOR WHERE Department LIKE
‘%gery%’;
Ans. (i) SELECT DOCName, Salary FROM DOCTOR ORDER BY Salary DESC;
[1 marks question]
1) The avg( ) function in MySQL is an example of ………………….
(i) Math Function
(ii) Text Function
(iii) Date Function
(iv) Aggregate Function
Ans:- (v) Aggregate Function
2) The Command can be used to make changes in the rows of table in SQL.
Ans:- UPDATE
3) The SQL Command that will display the current time and date.
Ans :- Select now();
4) The mid()function in MySql is an example of .
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
a. Informatics Practices
b. Informatic Practices
c. Inform practices
d. Inform atics practices
Ans :- a. InformaticsPractices
13) Write the output of the following SQL command.
select round (19.88,1);
a. 19.88 b. 19.8 c. 19.9 d. 20.0
Ans:- c. 19.9
14) The now() function in MySql is an example of .
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans:- c. Date Function
15) The command can be used to makes changes in the structure of a table in SQL.
Ans:- ALTER
16) Write the SQL command that will display the time and date at which the command got
executed.
Ans :- Select sysdate();
17) Write the output of the following SQL
command. select round(15.872,1);
a. 15.87
b.15.9
c.15.8
d.16
Ans:- b. 15.9
18)
Manish wants to select all the records from a table named “Students” where the value of
the column “FirstName” ends with an “a”. Which of the following SQL statement willdo
this?
19) The command can be used to add a new column to the table.
Ans:- ALTER
20) Which SQL command is used to describe the structure of the table ?
Ans:- DESC
21) Foreign Key in a table is used to enforce
i) Data dependency
ii) Referential Integrity
iii) Views
iv) Index Locations
Ans:- ii) Referential Integrity
22) A table ‘Student’ contains 5 rows and 4 columns initially. 2 more rows are added and 1
more column is added . What will be the degree and cardinality of the table student
after adding these rows and columns?
i) 7, 5
ii) 5,7
iii) 5,5
iv) None of the above
Ans:- ii) 5,7
23) Insert into student values(1,’ABC’,’10 Hari Nagar’) is a type of which command :
i) DML
ii) DDL
iii) TCL
iv) DCL
Ans:- i) DML
24) What will be the output of - select mid('Pyhton Programming’,3,9);
i) ton Progr
ii) ton Progr
iii) hton Prog
iv) htonProg
Ans:- iii) hton Prog
25) Write the output of the following SQL statement:
SELECT TRUNCATE(15.79,-1) , TRUNCATE(15.79,0), TRUNCATE(15.79,1);
a. 15 15 15.7
b. 10 15.7 15.9
c. 10 15 15.7
d. 10 10 15.9
Ans:- c. 10 15 15.7
26) The COUNT( ) in MySQL is an example of :
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans:- d. Aggregate Funcion
27) …….. which of the following sublanguages of SQL is used to query information from the
database and to insert tuples into, delete tuples from and modify tuples in the database?
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page
No-
a. DML
b. DDL
c. Query
d. Relational Schema
Ans:- a. DML
28) The ……… clause of SELECT query allows us to select only those rows in the result that
satisfied a specified condition.
a. WHERE
b. FROM
c. HAVING
d. LIKE
Ans:- a. WHERE
29)
Write the output of the following SQL command.
select substr(“COMPUTER”,3,4);
a. MPUT
b. PUTE
c. PU
d. MP
Ans: - a. MPUT
30)
The now() function in MySql is an example of .
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans :- c. Date Function
31) The command is used to make the changes in a table permanent.
Ans:- COMMIT
32) Give SQL command that will display the current month from the date and time.
Ans :- MONTH( )
33) Which of the following keywords will you use in the following query to display all the
records of students whose name start with S?
SELECT * from student where name “S%”
Ans :- LIKE
4) Which of the following is an aggregate function:
a. Upper()
b. Trim()
c. Date()
d. Sum()
Ans:- d. SUM()
SELECT MOD(14,3);
Ans: 2
37) What will be the result of the following query based on the table given here.
COUNT(Salary)
Ans:- 5
38) Write the command to delete all the data of the table ‘activity’ retaining only structure.
Ans:- DELETE FROM ACTIVITY;
39) Write the output for the following SQL commands
Select round(15.193 , -1);
Ans:- 10
40) Write a SQL query to display date after 20 days of current date on your system.
Ans:- SELECT CURDATE( ) + 10;
41) Write the output for the following sql command
Select SUBSTR(‘ABCDEFG’, -5 ,3)
Ans:- CDE
42) Which keyword is used to arrange the result of order by clause in descending order?
a. DSEC
b. DES
c. DESC
d. DESNO
Ans: C. DESC
43) Write the output of the following SQL command.
c)14.8
d) 15
Ans:- b) 14.9
44) The command can be used to change the size of column to the
table.
Ans:- ALTER
45) The command can be used to makes changes in the
rows of a table in SQL.
Ans:- Update
46) Write the output of the following SQL command.
select round (49.88);
a. 49.88
b. 49.8
c. 49.0
d. 50
Ans:- d. 50
47) Write the output of the following SQL command.
select round (19.88,1);
a. 19.88 b. 19.8 c. 19.9 d. 20.0
Ans:- c. 19.9
48) Select count(*) from Employee;
The above query will not consider the following:
Ans:- c) Total( )
50) The command can be used to make changes in the definition of a table in SQL.
Ans:- ALTER
51) Write the SQL clause used to sort the records of a table.
Ans:- ORDER BY
52) Write the output of the following SQL command.
select round(15.857,-1);
a. 15.8
b. 15.9
c. 15.0
d. 20
Ans:- 20
53) The now()function in MySql is an example of .
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page
No-
Ans:- c. Date Function
54) The command can be used to makes changes in the structure
of a table in SQL.
Ans:- ALTER
55) Write the SQL command that will display the time and date at which the
command got executed.
Ans: SELECT NOW();
56) In SQL NULL value means :
(i) 0 value (ii) 1 value (iii) None value (iv) None of the above
Ans:- iii) None value
57) Find the output of SQL Query:-
SELECT MOD(11, 3);
Ans:- 2
58) The MAX() function in MySql is an example of
.
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans:- d. Aggregate Function
59) Write the output of the following SQL command.
select round(314.82,-1);
a. 314.0 b. 310.0 c. 314.8 d. 300.0
Ans:- d. 300
60) What will be the output of the following SQL command:
SELECT LTRIM(“ RAJKUMAR “);
Ans:- “RAJKUMAR “
(Removes spaces from left side)
61) Write the output of the following SQL command.
select pow(2.37,3.45);
a. 17.62
b. 19.62
c. 18.35
d. 15.82
Ans:- b. 19.62
62) Having clause is used with function.
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans:- Aggregate Function
63) Write the output of the query:
[2 marks question]
1) State any two differences between single row functions and multiple row functions.
OR
What is the difference between the order by and group by clause when used along with the
select statement. Explain with an example.
Ans:- Differences between single row functions and multiple row functions. (i) Single row functions work
on one row only whereas multiple row functions group rows (ii) Single row functions return one
output per row whereas multiple row functions return only one output for a specified group of
rows.
OR The order by clause is used to show the contents of a table/relation in a sorted manner 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 rows in a given column and then apply an aggregate function
eg max(), min() etc on the entire group. (any other relevant answer)
Single row v/s Multiple row functions 1 mark for each valid point
Group by v/s Order by 1 mark for correct explanation 1 mark for appropriate example
2) Consider the decimal number x with value 8459.2654. Write commands in SQL to: i. round it off
to a whole number ii. round it to 2 places before the decimal.
She gets the output as 4 for the first command but gets an output 3 for the second command.
Explain the output with justification.
Ans:- This is because the column commission contains a NULL value and the aggregate functions do not
take into account NULL values. Thus Command1 returns the total number of records in the table
whereas Command2 returns the total number of non NULL values in the column commission.
4) Consider the following SQL string: “Preoccupied”
a. “occupied” b. “cup”
OR
a. the position of the substring ‘cup’ in the string “Preoccupied” b. the first 4 letters of the string
OR
OR
UPDATE command is a part of DML command and used to update the data of rows of a table.
While ALTER command is a part of DDL command and used to change the structure of a table like
adding column, removing it or modifying the datatype of columns.
Eg: UPDATE EMP SET SALARY = 20000;
Ans:- This is because the column DESTINATION contains a NULL value and the aggregate functions do not
take into account NULL values. Thus Command1 returns the total number of records in the table
whereas Command2 returns the total number of non NULL values in the column DESTINATION.
8) Write the output for following queries:
i. select MOD(11,4) "Modulus", power(3,2) "Raised";
ii. select CURDATE( )+10;
OR
i. select length('CORONA COVID-19');
ii. select lcase('COMputer Science');
3 9
or
i. 15
ii. ‘computer science’
9) Consider the decimal number x with value 7459.3654. Write commands in SQL
to:
i) round it off to a whole number
ii) round it to 2 places before the decimal.
10) Shailly writes the following commands with respect to a table Employee having
fields, empno, name, department, commission.
Command1 : SELECT COUNT(*) FROM EMPLOYEE; Command2 :
SELECT COUNT(COMMISSION) FROM EMPLOYEE;
She gets the output as 7 for the first command but gets an output 5 for the second
command. Explain the output with justification.
Ans:- This is because the column commission contains a NULL value and the aggregate
functions do not take into account NULL values. Thus Command1 returns the total
number of records in the table whereas Command2 returns the total number of non
NULL values in the column commission.
OR
OR
(student may use other functions like – substring/ mid/ right .. etc
Ans:- Data types are mean to identify the type of data and its associated functions.
The main objectives of datatypes is to clarify the type of data a variable can store and which
operations can be performed on it.
13) Consider the decimal number n with value 278.6975. Write commands in SQL :
i. That gives output 279
ii. That gives output 280
But the Query is not executing successfully. What do you suggest to him in order to execute this
query i.e. write the correct query.
(ii) Write a SQL query to display the details of those employees whose Salary column has
some values.
OR
20) Consider the following SQL string: “Mental Toughness Helps You
Succeed” Write commands to display following using functions:
a. “Toughness”
b. “Succeed”
OR
Considering the same string: “Mental Toughness Helps You Succeed”
Write SQL commands to display:
a. the position of the substring ‘’Helps’ in the string “Mental Toughness Helps You Succeed”
the first 6 letters of the string
Ans:- i) Select mid(‘Mental Toughness Helps You Succeed’, 8, 9)
ii) Select right(‘Mental Toughness Helps You Succeed’, 7);
OR
i) select instr("Mental Toughness Helps You Succeed",’Helps’);
ii) select left("Mental Toughness Helps You Succeed",6);
1 Mark each for correct function usage
21) Find out the error in the following SQL command and correct the same.
Select * from employee group by dept where sum(salary) > 2000000
Shewani has recently started working in MySQL. Help her in understanding the
difference between where and having clause.
Ans:- Having clause is used in conjunction with group by clause in MySQL. It is used to provide
condition based on grouped data. On the other hand, order by clause is an independent
clause used to arrange records of a table in either ascending or descending order on the
basis of one or more columns
OR
COUNT(*) returns the number of items in a group, including NULL values and duplicates.
COUNT(expression) evaluates expression for each row in a group and returns the number
of non null values
2 marks of correct explanation & for any other relevant answer.
23) Write commands in SQL to:
i. round off value 56789.8790 to nearest thousand’s place.
ii. Display day from date 13-Apr-2020.
Ans:- i. Select ROUND(56789.8790,-3);
ii. Select DAY(‘2020-04-13’) 1 mark each for correct answer.
24) Given Table Course:
to search / locate row in a relation. There can be only one primary key in a table. 1 mark
for correct definition with proper significance.
1 mark for stating only one primary key in a table.
OR
TRIM () function is used to remove leading and trailing spaces from a string a table. It can
be used as
TRIM(String)
For example;
SELECT TRIM(' bar ');
-> 'bar'
1 mark for stating purpose of the functions 1 mark for correct example.
27)
Consider the following ‘Student’ table.
(i) What will be the most suitable datatype for the grade column and why?
(ii) Write a command to insert Suman’s record with the data as shown in the
table.
Ans:- (i) Gender column datatype char(1) as all the possible values can be accommodated and it
will be space efficient.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records
in descending order, use the DESC keyword.
1 mark for correct explanation. 1 mark for appropriate example
29)
Consider a string “AS YOU know MORE” 2
Write the queries for the following tasks.
(i) Write a command to display “know”.
(ii) Write a command to display number of characters in the string.
OR
Consider a string “You Grow more” stored in a
column str. What will be the output of the following
queries?
(i) SELECT UPPER(str);
(ii) SELECT substr(str,-9,4);
Ans:- (i) select mid(“AS YOU know MORE”,8,4);
(ii) select length(“AS YOU know MORE”);
OR
[3 marks question]
Ans:- a. select Type, avg(Price) from Vehicle group by Type having Qty>20;
b. select Company, count(distinct Type) from Vehicle group by Company;
c. Select Type, sum(Price* Qty) from Vehicle group by Type;
a. ½ mark for the Select with avg(), ½ mark for the having clause
b. ½ mark for the Select with count() , ½ mark for group by clause
c. ½ mark for the Select with sum() , ½ mark for the group by clause
2) Consider the table Garment and write the query:
a. To display details of those faculty members whose First_name ends with ‘t’.
b. Display all records in descending order of Hire_date.
c. Find the maximum and minimum salary.
Ans:- a. Select * from Faculty where First_name like ‘%t’;
b. Select * from Faculty order by Hire_date desc;
c. Select max(Salary), min(Salary) from Faculty;
1 mark for each correct answer
5) Given the table CARDEN having following data:
a. Display the average charges of each type of car company having capacity more than 3.
b. Count the totalcars manufactured by each company.
c. Display the total charges of all the types of vehicles.
Ans a. select company, avg(charges) from carden group by company having capacity>3;
b. select Company, count(*) from carden group by Company;
c. Select company, sum(charges) from carden group by company;
1 mark each for correct answer
6) TABLE NAME : PHARMADB
KENDRIYA VIDYALAYA SANGATHAN RANCHI REGION Page
No-
a. To display sum of price for each PharmacyName having more than 1 drug.
b. Display pharmacy name in descending order of drug id
c. SELECT PharmacyName, COUNT(*) FROM PharmaDB GROUP BY PHARMACY NAME
Ans:-
a. Select sum(price) from pharmadb group by pharmacyname having count(*)>1;
b. Select PharmacyName from Pharmadb order by DrugID;
a. ½ mark for the Select with sum(), ½ mark for the having clause
b. ½ mark for the Select ,½ mark for the order by
clause 1 marks for correct output.
7) Consider a MySQL table ‘product’
(i) Display the value of each product where the value of each product is
calculated as PROD_PRICE * PROD_QTY
(ii) Display average PROD_PRICE.
Ans:-
(i) SELECT MAX(PROD_QTY) FROM product;
(ii) SELECT PROD_PRICE*PROD_QTY AS ‘Value’ FROMproduct;
(iii) SELECT AVG(PROD_PRICE) FROM
1) Write the SQL functions which will perform the following operations:
i) To display the name of the month of the current date .
ii) To remove spaces from the beginning and end of a string, “ Panorama “.
iii) To display the name of the day eg, Friday or Sunday from your date of birth, dob.
iv) To display the starting position of your first name(fname) from your whole name (name).
v) To compute the remainder of division between two numbers, n1 and n2
OR
Write SQL queries using SQL functions to perform the following operations:
a) Display salesman name and bonus after rounding off to zero decimal places.
b) Display the position of occurrence of the string “ta” in salesman names.
c) Display the four characters from salesman name starting from second character.
d) Display the month name for the date of join of salesman
e) Display the name of the weekday for the date of join of salesman
Ans:- i) monthname(date(now()))
ii) trim(“ Panaroma “)
iii) dayname(date(dob))
iv) instr(name, fname)
v) mod(n1,n2)
1 mark for each correct answer
OR
Write SQL queries using SQL functions to perform the following operations:
a) Convert all the names into lower case.
b) Display the position of occurrence of the string “sh” in Name.
c) Display the four characters from Department starting from second character.
d) Display the month name for the date of admission.
e) Display the name of the weekday for the date of admission.
OR
Write the SQL functions which will perform the following operations:
i) To display the day of month of current date.
ii) To remove spaces from the beginning and end of a string, “ Informatics Practices “.
iii) To display the name of the day eg. Friday or Sunday from your date of birth, dob.
iv) To convert your name into Upper case.
v) To compute the mode of two numbers num1 and num2.
OR
i. SELECT DAYOFMONT(CURDATE());
ii. SELECT TRIM(“ Informatics Practices “;
iii. SELECT DAYNAME(“2015-07-27”);
iv. SELECT UPPER(Name);
v. SELECT MOD(num1,num2);
3) Write the SQL functions which will perform the following operations:
(i) Print the details of KVs whose StationCode between 300 and 500
(ii) Print the details of KVs whose name ends with AFS
(iii) Print the details of KVs of Jaipur region
(iv) Print the number of KVs Zone-wise
(v) Select Region, count(KVName) from KV where Zone=’West’ group by Region
(vi) Select * from KV where substr(KVName, 2, 3)=’and’ or StationCode=390;
(i) select month(current_date());
(ii) select trim(“ KV Sangathan “);
Ans:- (iii) select dayname(dob) from student;
(iv) select round(sqrt(2) , 2);
(v) s
;
O
c
o
u
n
t
(
K
V
N
a
m
e
)
A
h
m
e
d
a
b
a
d
2
Jaipur 3
(vi)
KVCode KVName StationCode Region Zone
1019 Gandhidham IFFCO 11 Ahmedabad West
1020 Gandhidham Railway 11 Ahmedabad West
1702 Uri 390 Jammu North
Table : Garments
GCode GName Price MCode Launch_Date
10001 Formal Shirt 1250 M001 2008-12-12
10020 Frock 750 M004 2007-09-07
10007 Formal Pant 1450 M001 2008-03-09
10024 Denim Pant 1400 M003 2007-04-07
10090 T-Shirt 800 M002 2009-05-12
5) Write the SQL functions which will perform the following operations:
i) To display the name of the month of your birthdate .
ii) To remove spaces from the beginning of a string, “ Python“.
iii) To display the day of the week eg, Sunday from current date.
iv) To display the starting 3 characters from your name .
v) To compute the power of 2 to the power 3
OR
a) Display shop name and bonus after rounding off to zero decimal places.
b) Display the position of occurrence of the string “tech” in shop names.
c) Display three characters from shop name starting from second character.
d) Display the month name for the date of opening of shop
e) Display the name of the shop in all capitals.
Ans:- i)select monthname(‘1998-11-20’);
ii)select ltrim(‘ Python’);
iii)select dayname(now());
iv)select left(‘Nitin’,3);
v)Select power(2,3);
1 mark each for correct function
OR
a) Select Sname,round(Bonus,0) from Shop;
b) Select instr(SName,’tech’) from Shop;
c) Select mid(SName,2,3) from Shop;
d) Select monthname(DateOfOpen) from shop;
e) Select Upper(SName) from shop;
1 mark each for the correct query
6) Consider the following data frame of automobile
Write SQL queries using SQL functions to perform the following operations:
a) Display company name and body wheel base after rounding off to nearest ten’s decimalplaces.
b) Display the position of occurrence of the string “dan” in body style.
c) Display the 3 characters from company name starting from second character.
d) Display the year of manufacturing for sedan;
Page
No-
e) Display the name of the weekday for the manufacturing date.
Ans:- a) Select company, round(wheel-base,-1) from automobile;
b) Select instr(body-style,’dan’) from automobile;
c) Select substr(company,2,3) from automobile; /mid(company,2,3)
d) Select year(dateofmanufacture) from automobile where body-style=’sedan’;
e) Select dayname(dateofmanufacture) from automobile;
(i) Display first three letters of description e.g. ‘FRO’ for ‘FROCK’
(ii) Display the description after removing leading spaces if any.
(iii) Display number of characters taken by each description.
(iv) Display the number of MCODE in the table.
(v) Display the day of the LAUNCHDATE. Eg. ‘Monday’, ’Tuesday’ etc
OR
Databases query
using SQL
AVG()
ROUND()
MID()/SUBSTRING()/ MONTH()
SUBSTR()
SUM()
MOD() MONTHNAME()
LENGTH() COUNT()
YEAR()
COUNT(*)
LEFT() DAYNAME()
RTRIM()
RIGHT() DAY()
LTRIM()
GROUP BY
ORDER BY
TRIM() ,HAVING
INSTR()
MCQ
20) Which is the physical address to identify the Machine uniquely in network
a. IP Address
b. MAC Address
c. Computer Name
d. Your Used ID
21) Online textual talk is called
a. Video Conference
b. Text Chat
c. Video Call
d. Audio Call
22) The First Page we generally view when we open the browser is called.
a. Default page
b. First page
c. Home page
d. Landing Page
23) URL stands for
a. Uniform Run Line
b. Uniform Resource Line
c. Uniform Resource Location
d. Uniform Resource Locator
27) Google is a
a. Web service
b. Website
c. Program
d. All of it
28) When the signal from one wire bleeds into another wire , it is called as
a. Radio waves
b. Infrared
c. Laser
d. None of them
29) Communication Media can be of ___________ and _____________ type
a. Twisted pair , Shielded Twisted pair
b. Fiber optics , coaxial
c. Guided , Unguided
d. Wire , Laser
30) To prevent unauthorized access to and / or from the network, a system known as
____________, can be implemented by hardware and / or software
a. Antivirus
b. Firewall
c. Software
d. Hardware
1 MARKS QUESTION
2 Marks Questions
1) What is the difference between STAR and BUS topologies?
2) www mean internet or not ? Explain with example ?
3) What is the deference between the http and Https: websites
4) What are Plug-in or Add on or Extension
5) Email is our phone uses which protocal
6) Which address is used to uniquely identify the machines in a network
7) What s VoIP? Where is it used ?
8) Which protocol is used to upload files to webserver for creating websites.
9) Please help Amit to understand the parts of Email Address
10) What is difference between a website and an webpage 11) What is a gateway and
why is it used?
12) Router is needed for internet to work? Explain if true or false?
13) When can an HUB be used in place of Switch?
14) How website is not same as web portal?
15) What are the common services provided by any web portal?
16) Google.co.in is a static webpage . The statement is correct or wrong ? Help Raj to
define the correct webpage type ?
17) What browser setting is needed to do when we access any site in public computer
like cyber café?
18) What in a VPN software
19) Why we use a domain name address in place of IP address of the Server to access
any web site?
20) Redirection or Popups in the website are to be checked carefully before forwarding?
Why is this so important?
Block B 150
Block C 45
Head office 10
a. Suggest the most suitable place to house the server with justification.
b. Suggest a connection medium to connect Gurgaon campus with head office.
c. Suggest the placement of the following devices with justification:
i)Switch ii)Repeater
d. The organization is planning to provide a high speed link with its head office
situated in Mumbai using a wired connection. Which of the following cables
will be most suitable for this job?
i) Optical Fibre ii)Co-axial Cable iii)Ethernet Cable
2) Sarguja University is setting up its new academic block in KP Gaon. The University has
3 new academic block and 1 human resource centre.
The distance between the blocks are given below
fazz building 15
jazz building 25
a. Suggest the most suitable place to house the server of this organization with a suitable
reason.
b. Suggest the placement of the following devices with justification.
i)Internet connecting device ii)switch
c. The organization is planning to link its sale counter situated in various parts of the same
city, which type of network out of LAN, MAN or WAN will be formed? Justify your
answer.
d. If there will be connection between all building using mesh topology, suggest where
need to place repeater.
4) “KVS” is planning to setup its new campus at Raipur for its educational activities. The
campus has four(04) UNITS as shown below:
a. Suggest an ideal cable layout for connecting the above UNITs
b. Suggest the most suitable place i.e. UNIT to install the server for KVS
c. Which network device is used to connect the computers in all UNITs
d. Suggest the placement of Repeater in the UNITs of above network.
5) Knowledge All Organization has set up its new center at Kolkata for its office and web
based activities. It has 4 blocks of building as shown in the diagram below
a. Suggest a layout of connections between the blocks
b. Suggest the most suitable place (i.e. block) to house the server of this
organization with a suitable reason
c. Suggest the placement of the following devices with justification
i. Repeater ii. Hub / Switch
d. The organization is planning to link its front office situated in the city in the
hilly region where cable connection is not feasible , suggest an economic way
to connect it with reasonably high speed
6) Ramji Training Educational Institute is setting up its centre in RAIPUR with four
specialized departments for Orthopaedics, Neurology and Paediatrics along with an
administrative office in separate buildings. The physical distances between these
department buildings and the number of computers to be installed in these departments
and administrative office are given as follows. Answer the queries as raised by them in (a) to
(d)
a) Suggest the most suitable location to install the main server of this institution
to get efficient connectivity.
b) Suggest the best cable layout for effective network connectivity of the
building having server with all the other buildings.
c) Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following : Gateway, switch,
Modem
d) Suggest the topology of the network and network cable for efficiently
connecting each computer installed in each of the buildings out of the following :
Topologies: Bus Topology, Star Topology
Network Cable: Single Pair Telephone Cable, Coaxial Cable, Ethernet Cable.
7) RAJKUMARMedicos Centre has set up its new centre in Bilaspur. It hasfour buildings
as shown in the diagram given below
Distances between various buildings are as follows:
Number of Computers
As a network expert, provide the best possible answer for the following queries:
ANSWER
1. C 2. B 3. C 4. B 5. B 6. D 7. A 8. A 9. A 10. A
11.A 12.B 13. B 14. C 15. A 16. A 17. A 18. A 19. B 20. B
21.B 22.C 23. D 24. D 25. C 26. B 27. A 28. C 29. C 30. B
1 MARKS QUESTIONS
1. Network is the interconnection between systems for resource sharing like printing
and internet sharing.
2. FULL ABBRIBIATION
NIC:-Network Interface Card
ICT:-Information and Communication Technology
PCB:-Printer Circuit Board
DND:-Do Not Disturb Directory
STP:-Shielded Twisted Pair
UTP:-Un-Shielded Twisted Pair
CAT-6:-Category 6 Cables
CRT:-Cathod Ray Tube
TFT:-Thin Film Transistor
LED:-Light Emmited Diode
3. WAN – WIDE AREA NETWORK / MAN – METROPLITON AREA NETWORK
4. LAN- LOCAL AREA NETWORK / PAN – PERSONAL AREA NETWORK
5. Node is the client computer that is connected to a computer
6. NIC is the card that create an interface between the computer and the internet or
network medium
7. Server is the Computer that serve as the main computer to serve information.
8. Bluetooth Headsets are used to get voice from the source but there is a delay in the
voice and the video played
9. Networking Topology is physical layout of the networking connection to the
computer
10. Internet is the network of networks and LAN is only a single network
11. Firewall is used to save the network from un-authorised access
12. It is the Internet Service Provider for the Clients
13. IP or Internet Protocol Address is the 32 Bit Address Logical Number to be given to
any network for uniquely identifying the Computers
14. Because each node is connected directly to the main server and any fault is highly
localised
15. He will us his cookies in the browser to save the password and details
16. Setting -> default page->home page address
17. Modem is used to connect Digital computer to Analog Line for Digital data Transfer
18. They use IM (Instance Messaging) for Text Chatting other then SMS
19. Router is used to connect all the different networks together. It also forwards and
receives different data packets from different places
20. Password Security Ethics
21. URL (Uniform Resource Locator) is the human understandable format for website
address.
22. An absolute URL is the complete website address with protocal and landing page
details also
23. History is the link to last visited websites in the browser
24. Hyperlink is link to another website or page from the current page
2 MARKS QUESTIONS
1) STAR Topology is topology in which the all the nodes are connected with central
computer. But is Bus topology a single wire runs across the network and all the
nodes are connected to the central bus
2) www is world wide web and it is the protocol to define the website or web
address.e.g.
http://www.google.co.in. This address defines that the website is in the internet.
3) http: is the normal Hyper Text Transfer Protocol but https: is the Secured Hyper Text
Transfer Protocal.
4) The software that are installed with the browser for better performance and utility
are called the Plug-in or Add On
5) Email in our phone uses POP3 protocol to access
6) The MAC address is used to uniquely identify the machine in a network
7) VoIP or Voice Over IP is a protocol used to transmit data
8) FTP or File Transfer Protocol is used to transfer files to the web server for creating
web site
9) Email has used id and the domain name in its complete address
kvs@kvs,gov.in where kvs is used id and kvs,gov.in is domain name
10) Website is the complete software and webpage is just one of the page from the
website like www.ambikapur.kvs.ac.in is website and
https://ambikapur.kvs.ac.in/admin/content?type=school_class_wise_enrolment_po
si is a single web page
11) Gateway is the computer used to connect different networks to one network
12) Router is a dynamic device to connect different networks in real time. Internet
cannot work without routers.
13) Hub is a device that broadcast all the signals so Hub is used in less computers with a
limited speed or bandwidth requirements
14) Website is a single software and web portal is a combination of both online and
offline services given by the webportal . like www.google.co.in is a website and
www.ola.com is aweb portal
15) The most common services provided by the web portal are web hosting and business
website developments.
16) Google is a dynamic website. It connects us directly to the related websites what are
searched. 17) We need to use incognito mode or public mode while accessing
internet in the public place.
18) A VPN software is a software that hides the machine address from the network so
that no one can trace the computer in the network
19) We use Domain name as it is more easy to remember that to remember the IP
Address of the Website.
20) The popups or redirection can be a trap form the hackers to hack your computer so
they needed to check carefully
COMPILED BY
VISHANT D KHOBRAGADE
PGT CS
K V VSN, NAGPUR
TYPES OF NETWORK
•LAN
•MAN
•WAN
NETWORK DEVICES
• MODEM
• HUB
• SWITCH
• REPEATER
• ROUTER
• GATEWAY
NETWORK TOPOLOGIES
• STAR
• BUS
• TREE
• MESH
INTRODUCTION TO INTERNET
WEBSITES
WEB BROWSERS
PREPARED BY
VISHANT D KHOBRAGADE
PGT CS
K V VSN NAGPUR
CLASS XII
INFORMATICS PRACTICES(065)
UNIT IV SOCIETAL IMPACTS
QUESTION BANK
i. Copyright
ii. Copyleft
iii. GPL
iv. FOSS
Ans4. i. Copyright
Q5. __________is the trail of data we leave behind when we visit any website (or use any
online application or portal) to fill-in data or perform any transaction.
i. Offline phishing
ii. Offline footprint
iii. Digital footprint
iv. Digital phishing
(i) Spamming
(ii) Phishing
(iii) Plagiarism
(iv) Trojan
Ans. (iii) Plagiarism
Q12. A mail or message sent to a large number of people indiscriminately without their
consent is called____________
Ans. spam
Q13. According to a survey, one of the major asian country generates approximately about 2
million tonnes of electronic waste per year. Only 1.5 % of the total e-waste gets recycled.
Suggest a method to manage e-waste .
Ans.
1. Buy environmentally friendly electronics
2. Donate used electronics to social programs
3. Reuse, refurbish electronics Recycling e-waste
Q14. Receiving irrelevant and unwanted emails repeatedly is an example of ______________.
Ans. Spam or spamming
Q15. A _______ protects Literacy and Artistic works such as books, novels, compositions, etc.
from getting copied or utilized without permission.
a) Patient
b) IPR
c) Copyright
d) Trademark
Ans. c) Copyright
Q16. Siddhant received an email from an unknown source claiming he has won a reward of
Rs. Five lakh. He need to click on a link and provides some information to claim award, he is
a victim of :
a) Cyber Bullying
b) Virus attack
c) Trojan Attack
d) Phishing
Ans. d) Phishing
Q17. Anita has installed a strong anti-virus on her laptop. She is sure that now she cannot be
a victim of any cybercrime. Anita is
a) 100% correct in her thinking
b) Correct, if she keep updating her antivirus regularly
c) Correct, till she is using websites hosted from Indian Servers.
d) Not correct, as antivirus protects only from virus.
Ans. b) Correct, if she keep updating her antivirus regularly
Q18. .What is the name of the IT law that India is having in the Indian legislature?
a) India's Technology IT Act 2000
b) India's Digital information technology DIT Act, 2000
c) India's Information Technology IT Act, 2000
a) Source code
b) License
c) Software authority
d) Digital rights
Ans. b) License
Q22. Any work / information that exist in digital form idea on internet or on an electronic
device, is known as________________ property.
a) Licence property
b) digital property
c) source code property
d) software property
Ans. b) digital property
a) Wipe monitor’s screen often using the regular microfiber soft cloth.
b) Keep it away from direct heat, sunlight and put it in a room with enough ventilation
for air circulation.
c) Do not eat food or drink over the keyboard
d) All of the above
Ans. d) All of the above
Q26. The process of re-selling old electronic goods at lower prices is called ____
a) refurbishing
b) recycle
c) reuse
d) reduce
Ans. a) refurbishing
Q27. ________ is a kind of cyber crime in which attacker blackmails the victim to pay for
getting access to the data.
a) Phishing
b) Identity theft
c) Ransomware
d) None of the above
Ans c) Ransomware
Q28. ______________ is an activity where fake websites or emails that look original or
authentic are presented to the user.
a) Phishing
b) Hacking
c) Spamming
d) Identity theft
Ans a) Phishing
Q29. ____________ is the act of unauthorized access to a computer, computer network or
any digital system.
a) Sign in
b) Hacking
c) Tracking
d) None of the above
Ans. b) Hacking
Q30. Which of the following is cybercrime?
a) Hacking
b) Phishing
c) Spamming
d) All of the above
Ans. d) All of the above
2Marks type Questions
Q1. List any four benefits of e-waste management.
Your parents, a favorite teacher, school administrators, counselors, and even police
officers can help you deal with cyberbullying.
Q5. What is Phishing? Write any two precautions that you would take to avoid being victim
of phishing.
Ans. Phishing:The fraudulent practice of sending emails purporting to be from reputable
companies in order to induce individuals to reveal personal information, such as passwords
and credit card numbers.
Two precautions:
1. Don’t give your information to an unsecured site
2. Change password regularly
Q1. Nadar has recently shifted to a new city and school. She does not know many people in
her new city and school. But all of a sudden, someone is posting negative, demeaning
comments on her social networking profile etc. She is also getting repeated mails from
unknown people. Every time she goes online, she finds someone chasing her online.
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.
Ans.
i. Nadar has become a victim of cyber bullying and cyber stalking.
ii. She must immediately bring it into the notice of her parents and school
authorities. And she must report this cyber crime to local police with the help of
her parents.
iii. Yes. The Information Technology Act, 2000 (also known as ITA-2000, or the IT Act)
is the primary law in India dealing with cybercrime and electronic commerce.
Q2. What do you understand by plagiarism? Why is it a punishable offence? Mention any two
ways to avoid plagiarism.
Ans. Plagiarism is the act of using or stealing someone else’s intellectual work, ideas etc. and
passing it as your own work. In other words, plagiarism is a failure in giving credit to its source.
Plagiarism is a fraud and violation of Intellectual Property Rights. Since IPR holds a legal entity
status, violating its owners right is a legally punishable offence.
Any two ways to avoid plagiarism:
∙ Be original
∙ Cite/acknowledge the source
Q3. What do you mean by Identity theft? Explain with the help of an example.
Ans. Identity theft is the crime of obtaining the personal or financial information of another
person for the sole purpose of assuming that person's name or identity to make transactions
or use it to post inappropriate remarks, comments etc.
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.
Q4. What do you understand by Net Ettiquetes? Explain any two such ettiquetes.
Ans. Net Ettiquets refers to the proper manners and behaviour we need to exhibit while being
online. These include :
1. No copyright violation: we should not use copyrighted materials without the permission
of the creator or owner. We should give proper credit to owners/creators of open source
content when using them.
2. Avoid cyber bullying: Avoid any insulting, 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.
d. Cyber stalking
Answer(d)
ii. The action that Smridh should take :
a. He should ONLY share with his friends
b. He should NOT share with anyone as it can cause serious problem
c. He should immediately report to the police
d. He should bring to the notice of his parents and school authorities.
Answer : (d)
iii. …………………….. is a set of moral principles that governs the behaviour of a group or
individual and regulates the use of computers.
a. Copyright
b. Computer ethics
c. Property rights
d. Privacy law
Answer: (b)
iv. Smridh needs to protect his personal information or data from unintentional and
intentional attacks and disclosure which is termed as ………...
a. Digital right
b. Copyright
c. Privacy
d. Intellectual property
Answer : (c)
v. The act of fraudulently acquiring someone’s personal and private information, such as
online account names, login information and passwords is called as ……………
a. Phishing
b. Fraud
c. Scam
d. Plagiarism
Answer : (a)
Q2. The school offers Wi-Fi to the students of Class XII. For communication, the network
security-staff of the school is having a registered URL "schoolwifi.edu". On 17th September
2017, 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. On the bases of the above case study, answer the questions given below:
i. Specify which type of cybercrime is it.
a) Spamming
b) Phishing
c) Identity Theft
d) Hacking
Answer: (b) Phishing
d) Spyware
Answer: (c) Spam
iv. WiFi stands for ___________
a) Wireless Internet Frequent Interface
b) Wireless Functioning
c) Wireless Fidelity
d) Wire Free Internet
Answer: c Wireless Fidelity
v. Ideally, what characters should be used in a password to make it strong?
a) Letters and numbers only
c. copyright infringement
d. Intellectual Property right
Answer:(b) :Paraphrasing
ii. Step 2 An act of __________
a. plagiarism
b. copyright infringement
c. Intellectual Property right
d. Digital Footprints
Answer: (a) Plagiarism
iii. Step 3 An act of _________
a. Plagiarism
b. Paraphrasing
c. copyright infringement
d. Intellectual Property right
Answer: (c) Copyright Infringement
Answer: (b)
v. The process of getting web pages, images and files from a web server to local computer is
called
a. FTP
b. Uploading
c. Downloading
d. Remote access
2. When e-waste such as electronic circuit boards are burnt for disposal, the 1
elements contained in them create a harmful chemical called ________which
causes skin diseases, allergies and an increased risk of lung cancer.
i. Hydrogen
ii. Beryllium
iii. Chlorine
iv. Oxygen
13. By restricting the server and encrypting the data, a software company's 1
server is unethically accessed in order to obtain sensitive information. The
attacker blackmails the company to pay money for getting access to the data,
and threatens to publish sensitive information unless price is paid. This kind
of attack is known as:
i. Phishing
ii. Identity Theft
iii. Plagiarism
iv. Ransomware
18. Assertion (A):- To use the Pandas library in a Python program, one must 1
import it.
Reasoning (R): - The only alias name that can be used with the Pandas library
is pd.
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
SECTION B
19. Briefly explain the basic concepts of a web server and web hosting. 2
OR
Rati is doing a course in networking. She is unable to understand the concept of
URL. Help her by explaining it with the help of suitable example.
20. The python code written below has syntactical errors. Rewrite the correct code 2
and underline the corrections made.
Import pandas as pd
df ={"Technology":["Programming","Robotics","3D
Printing"],"Time(in months)":[4,4,3]}
df= Pd.dataframe(df)
Print(df)
23. Differentiate between the active digital footprint and passive digital footprints. 2
24. Complete the given Python code to get the required output as: Rajasthan 2
import _________ as pd
di = {'Corbett': 'Uttarakhand', 'Sariska':
'Rajasthan', 'Kanha': 'Madhya Pradesh’,
'Gir':'Gujarat'}
NP = ___________. Series( _____ )
print(NP[ ___________ ])
SECTION C
26. Based on the SQL table CAR_SALES, write suitable queries for the following: 3
+--------+-------------------+--------+-------+-------+
| NUMBER | SEGMENT | FUEL | QT1 | QT2 |
+--------+-------------------+--------+-------+-------+
| 1 | Compact HatchBack | Petrol | 56000 | 70000 |
| 2 | Compact HatchBack | Diesel | 34000 | 40000 |
| 3 | MUV | Petrol | 33000 | 35000 |
| 4 | MUV | Diesel | 14000 | 15000 |
| 5 | SUV | Petrol | 27000 | 54000 |
| 6 | SUV | Diesel | 18000 | 30000 |
| 7 | Sedan | Petrol | 8000 | 10000 |
| 8 | Sedan | Diesel | 1000 | 5000 |
+--------+-------------------+--------+-------+-------+
i. Display fuel wise average sales in the first quarter.
ii. Display segment wise highest sales in the second quarter.
iii. Display the records in the descending order of sales in the second
quarter.
OR
Predict the output of the following queries based on the table CAR_SALES
given above:
i. SELECT LEFT(SEGMENT,2) FROM CAR_SALES WHERE FUEL=
"PETROL";
ii.SELECT (QT2-QT1)/2 "AVG SALE" FROM CAR_SALES WHERE
SEGMENT= "SUV";
iii. SELECT SUM(QT1) "TOT SALE" FROM CAR_SALES WHERE
FUEL= "DIESEL";
27. Create a DataFrame in Python from the given list: 3
[[‘Divya’,’HR’,95000],[‘Mamta’,’Marketing’,97000],[‘Payal’,’IT’,980000],
[‘Deepak’,’Sales’,79000]]
Also give appropriate column headings as shown below:
29. Richa, recently started using her social media account. Within a few days, she 3
befriends many people she knows and some that she does not know. After
some time, she starts getting negative comments on her posts. She also finds
that her pictures are being shared online without her permission.
Based on the given information, answer the questions given below.
i. Identify the type of cybercrime she is a victim of.
ii. Under which act, she can lodge a complaint to the relevant authorities?
iii. Suggest her any two precautionary measures which she should take in
future while being online to avoid any such situations.
OR
Mention any three health hazards associated with inappropriate and excessive
use of gadgets.
31. Preeti manages database in a blockchain start-up. For business purposes, she 4
created a table named BLOCKCHAIN. Assist her by writing the following
queries:
TABLE: BLOCKCHAIN
32. Ekam, a Data Analyst with a multinational brand has designed the DataFrame 4
df that contains the four quarter’s sales data of different stores as shown below:
Store Qtr1 Qtr2 Qtr3 Qtr4
0 Store1 300 240 450 230
1 Store2 350 340 403 210
2 Store3 250 180 145 160
Answer the following questions:
i. Predict the output of the following python statement:
a. print(df.size)
b. print(df[1:3])
ii. Delete the last row from the DataFrame.
iii. Write Python statement to add a new column Total_Sales which is the
addition of all the 4 quarter sales.
OR
(Option for part iii only)
Write Python statement to export the DataFrame to a CSV file named data.csv
stored at D: drive.
SECTION E
34. XYZ Media house campus is in Delhi and has 4 blocks named Z1, Z2, Z3 and 5
Z4. The tables given below show the distance between different blocks and the
number of computers in each block.
The company is planning to form a network by joining these blocks.
i. Out of the four blocks on campus, suggest the location of the server that
will provide the best connectivity. Explain your response.
ii. For very fast and efficient connections between various blocks within the
campus, suggest a suitable topology and draw the same.
iii. Suggest the placement of the following devices with justification
(a) Repeater
(b) Hub/Switch
iv. VoIP technology is to be used which allows one to make voice calls
using a broadband internet connection. Expand the term VoIP.
v. The XYZ Media House intends to link its Mumbai and Delhi centers.
Out of LAN, MAN, or WAN, what kind of network will be created?
Justify your answer.
Height_cms=[145,141,142,142,143,144,141,140,143,144]
Write suitable Python code to generate a histogram based on the given data,
along with an appropriate chart title and both axis labels.
Also give suitable python statement to save this chart.
OR
Write suitable Python code to create 'Favourite Hobby' Bar Chart as
shown below:
1. iii. Gateway 1
(1 mark for correct answer)
2. ii. Beryllium 1
(1 mark for correct answer)
4. iv. NULL 1
(1 mark for correct answer)
5. iii. LENGTH () 1
(1 mark for correct answer)
9. iv. march 1
(1 mark for correct answer)
15. i. Website 1
(1 mark for correct answer)
17. i. Both A and R are true and R is the correct explanation for A 1
(1 mark for correct answer)
SECTION B
19. Web server: A web server is used to store and deliver the contents of a website 2
to clients such as a browser that request it. A web server can be software or
hardware.
Web hosting: It is a service that allows to put a website or a web page onto
the Internet, and make it a part of the World Wide Web.
(1 mark each for each correct explanation)
OR
URL: It stands for Uniform Resource Locator. It provides the location and
mechanism (protocol) to access the resources over the internet.
URL is sometimes also called a web address. It not only contains the domain
name, but other information as well that completes a web address.
Examples:
https://www.cbse.nic.in, https://www.mhrd.gov.in, http://www.ncert.nic.in,
http://www.airindia.in, etc.
(1 mark for correct explanation)
(1 mark for correct example)
20. import pandas as pd 2
df ={"Technology":["Programming","Robotics","3D
Printing"],"Time(in months)":[4,4,3]}
df= pd.DataFrame(df)
print(df)
(1/2 mark for each correction)
22. 0 -10 2
1 -20
2 -30
3 -10
4 -20
5 -30
(2 marks for correct output)
23. Active Digital Footprints: Active digital footprints include data that we 2
intentionally submit online. This would include emails we write, or responses or
posts we make on different websites or mobile Apps, etc.
Passive Digital Footprints: The digital data trail we leave online
unintentionally is called passive digital footprints. This includes the data
generated when we visit a website, use a mobile App, browse Internet, etc.
(2 marks for correct differentiation)
25. Aggregate functions: These are also called multiple row functions. These 2
functions work on a set of records as a whole, and return a single value for each
column of the records on which the function is applied.
Max(), Min(), Avg(), Sum(), Count() and Count(*) are few examples of multiple
row functions.
(1 mark for correct explanation)
(½ mark each for two correct names)
SECTION C
26. i. SELECT FUEL, AVG(QT1) FROM CAR_SALES GROUP BY FUEL; 3
ii. SELECT SEGMENT, MAX(QT2) FROM CAR_SALES GROUP BY
SEGMENT;
iii. SELECT * FROM CAR_SALES ORDER BY QT2 DESC;
(1 mark for each correct query)
OR
i.
+-----------------+
| LEFT(SEGMENT,2) |
+-----------------+
| Co |
| MU |
| SU |
| Se |
+-----------------+
ii.
+------------+
| AVG SALE |
+------------+
| 13500.0000 |
| 6000.0000 |
+------------+
iii.
+----------+
| TOT SALE |
+----------+
| 67000 |
+----------+
(1 mark each correct output)
30. i. Genre["Num_Copies"]=[300,290,450,760] 3
ii. Genre.loc[4]=["Folk Tale","FT",600]
iii.Genre=Genre.rename({"Code":"Book_Code"},
axis=1)
OR
Genre=Genre.rename({"Code":"Book_Code"},
axis="columns")
(1 mark for each correct statement)
SECTION D
SECTION E
plt.savefig("heights.jpg")
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. Fill in the blanks :
The command used to show legends is
a. display()
b. show()
c. legend()
d. legends()
2. Write the output of the following SQL command.
select round(15.857,-1);
a. 15.8
b. 15.9
c. 15.0
d. 20
3. Given a Pandas series called Sample, the command which will display the
last 3 rows is .
a. print(Sample.tail(3))
b. print(Sample.Tail(3))
c. print(Sample.tails(3)
d. print(Sample.Tails(3))
4. Which of the following is not a valid chart type?
a. Lineplot
b. Bargraph
c. Histogram
d. Statistical
5 Which amongst the following is the first page we normally view on a Website?
a. Home Page
b. Master Page
c. First Page
d. Banner Page
6. The now()function in MySql is an example of .
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
7. A website store the browsing activity through __________
a. chat
b. cookies
c. scam
d. antivirus
8. Gaining unauthorized access to a network or computer with malicious
intensions is an example of ________
a. Hacking
b. Evasdropping
c. Snooping
d. Bullying
9. The command that will display the time and date at which the
command got executed.
a. DateTime()
b. sysdate()
c. systemdate()
d. timenow()
10. Consider name of table is employee(empid, firstname, lastname, doj, department,
salary)
What should be sql query to get average salary of employee department wise.
a. select avg(salary) from employee order by department;
b. select average(salary) from employee group by department;
c. select avg(salary) from employee group by department;
d. None of above
a. 15.87
b. 15.9
c. 15.8
d. 16
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): - To make a Histogram with Matplotlib, we can use the plt.hist()
function.
Reason (R) :- The bin parameter is compulsory to create histogram.
18 Assertion (A): Someone has created a fake social media profile in the name of Saket.
Saket is a victim of cyberstalking.
Reason (R): Cyberstalking is a form of cybercrime.
Reason (R) :-
SECTION B
19 Mr. Amit Mishra is using his internet connection for checking the online account 2
of the company's admin without his knowledge. What do we call this type of
activity? What are the ways by which we can avoid such type of
activities?
20 Mr. Sharma writes the following commands with respect to a table 2
department having fields, deptno, dept_name, head_of_department,
manager.
Command1 : Select count(*) from department;
Command2: Select count(manager) from department;
He gets the output as 8 for the first command but gets an
output 6 for the second command. Explain the output
with justification.
21 What is the difference between the where and having clause when used 2
along with the select statement? Explain with an example.
22 Consider a given Series, Subject:
INDEX MARKS
ENGLISH 75
HINDI 78
MATHS 82
SCIENCE 86
a. PPP
b. HTTPS
c. VoIP
d. PAN
24 What will be the output of following code-
import pandas as pd
s1=pd.Series([1, 2, 2, 7, ’Sachin’, 77.5])
print(s1.head(3))
SECTION C
26. Write the output of queries(a) to (d) based on the table, PERIPHERALS given below 3
Table: EMPLOYEE
.
Write commands to :
i. Add a new column ‘Course’ to the Dataframe with values which are any
computer science related field.
ii. Add a new row with values (Sam,456,Chennai,Data Science)
iii. Display the average of TMarks column
29. What do you mean by Identity theft? Explain with the help of an example. 3
OR
What do you understand by plagiarism? Why is it a punishable offence? Mention any
two ways to avoid plagiarism.
32. 5
33. 5
SECTION E
34 A relationToys is given below:
0 Amit 15 90.0
1 Bhavdeep 16 NaN
2 Reema 17 87.0
a. print(df.marks/2)
b. print(df.loc[:0,’Age’])
c. Write Python statement to display the data of marks who secured marks >85
Write Python statement to compute and display the data of students by filling value as 0 in
place of NaN in the given DataFrame.