12 SM Ip
12 SM Ip
12 SM Ip
CONTENT TEAM
(2) DataFrame: It is a tabular data structure comprised of rows and columns. DataFrame is
defined as a standard way to store data which has two different indexes i.e., row index and column
index.
S1 S2
A 10 A 80
B 40 B 20
C 34 C 74
D 60 D 90
Write the command to find the sum of series S1 and S2
Q.1. Mr. Ankit is working in an organisation as data analyst. He uses Python Pandas and
Matplotlib for the same. He got a dataset of the passengers for the year 2010 to 2012 for January,
March and December. His manager wants certain information from him, but he is facing some
problems. Help him by answering few questions given below:
iii. Choose the correct statement/ method for the required output:
i. df.loc[['Month','Passengers']][df['Month']=='Jan']
ii. df[['Month','Passengers']][df['Month']=='Jan']
iii. df.iloc[['Month','Passengers']][df['Month']=='Jan']
iv. df(['Month','Passengers']][df['Month']=='Jan')
Answer: (ii) df[['Month','Passengers']][df['Month']=='Jan']
v. Mr. Ankit wants to change the index of the Data Frame and the output for the same is
given below. Identify the correct statement to change the index.
i. df.index[]=["Air India","Indigo","Spicejet","Jet","Emirates"]
ii. df.index["Air India","Indigo","Spicejet","Jet","Emirates"]
iii. df.index=["Air India","Indigo","Spicejet","Jet","Emirates"]
iv. df.index()=["Air India","Indigo","Spicejet","Jet","Emirates"]
Matplotlib for analysing and visualising the data, respectively. She has created a Data frame
“SportsDay” to keep track of the number of First, Second and Third prizes won by different
houses in various events.
Answer: b. Name
v. Which command will give the output 24:
a. print(df.size)
b. print(df.shape)
c. print(df.index)
d. print(df.axes)
Answer: a. df.size
Short Answer Type Questions
Q. Consider the following Series object, S_amt
Table 350
Chair 200
Sofa 800
Stool 150
i. Write the command which will display the name of the furniture having rent>250.
ii. Write the command to name the series as Furniture.
Ans:
i. print(S_amt[S_amt>250])
ii. S_amt.name= 'Furniture
Q. Consider the following DataFrame, classframe
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)
Ans:
i. classframe[‘Activity’]=[‘Swimming’,’Dancing’,’Cricket’, ‘Singing’]
ii. classframe.loc[‘St5’]=[5,’Mridula’, ‘X’,‘F’, 9.8, ‘Science’]
Q. Create a dataframe using dictionary of ndarrays.
Ans:
import pandas as pd
data = {'Name':['Tom', 'Jack', 'Steve', 'Ricky'], 'Age':[28,34,29,42]}
df =pd.DataFrame(data, index= ['rank1','rank2','rank3','rank4'])
print (df )
• at
• Transpose
• empty
Q. Write a Pandas program to get the powers of an array values element-wise.
Ans: import numpy as np
import pandas as pd
first_array=nparange(6)
second_array=np.arange(6)
print(first_array)
print(second_array)
power_array=np.power(first_array,second_array)
arr1=np.array([first_array,power_array])
df=pd.DataFrame(arr1,index=['num1','power'])
print(df)
Q. Write a Pandas program to create and display a DataFrame from a specified dictionary data
which has the index labels. Ans: import pandas aspd
importnumpyas np
exam_data={'name':['Parul','Dimple','Himanshu','Dhruv',
'Anoushka','Sushant','Adarsh'],
'score':[12.5,9,16.5,np.nan,9,20,14.5],
'attempts':[1,3,2,3,2,3,1],
qualify':['yes','no','yes','no','no','yes','yes']}
labels =['a','b','c','d','e','f', ‘g’]
df=pd.DataFrame(exam_data, index=labels)
print(df)
Q. Write a Pandas program to display a summary of the basic information about a specified
DataFrame and its data.
Ans:
import pandas aspd
importnumpyas np
exam_data={'name':['Parul','Dimple','Himanshu','Dhruv','Anoushka',
'Sushant','Adarsh'],
'score':[12.5,9,16.5,np.nan,9,20,14.5],
'attempts':[1,3,2,3,2,3,1],
'qualify':['yes','no','yes','no','no','yes','yes']}
labels =['a','b','c','d','e','f', ‘g’]
df=pd.DataFrame(exam_data,
index=labels) print(df)
print("Summary of the basic information about this DataFrame:")
print(df.info())
Q. Pushp, a student of class-XII, has been assigned a code to create a panda series S1, as shown
below.
a 100
b 200
c 300
d 400
e 500
dtype: int64
With reference to the above answer given questions:
i. Choose the command that will give the following output-
b
2
0
0
3
0
0
dtype: int64
ii. Help him to identify the correct statement that can be used to extract t hevalue with the
index 'c'
iii.Which command will give the following output-
b
2
0
0
d
4
0
0
dtype: int64
iv. Which of the following command will display the series by adding 10 in each value.
v. Pushp wants to delete the value against index 'd'. Help him to choose the suitable option
to do so:
Solution:
i. c) print(s1[1:3])
ii. d) print(S1 ['c'])
iii. d) print(S1.iloc[1:4:2])
iv. b) print(S1+10)
v. b) S1=S1.drop('d')
Q.21. HR Department of ABCTech has created following dataframe to store data about salaries
and bonus paid to their employees:
import pandas as pd import numpy as np
d1={'EName':[ 'Kavita', 'Sudha', 'Garima’]'],
'Sal':[50000,60000,55000],'Bonus':[3000,4000,5000]}
df1=pd.DataFrame(d1)
Choose the python statement using suitable functions for the following tasks:
Q.Create a dataframe with the above data (Q-5) and display the sum of the given numbers:
import pandas as pd
def df_SingleColumn():
l = [33,55,66,39,45]
sum1=0
df = pd.DataFrame(l)
sum1=df.sum()
print("Sum of given numbers:", sum1.to_string(index=False))
df_SingleColumn()
Q.What will be the output of following code:
import pandas as pd
def df_data():
df1=pd.DataFrame([22,56,78])
df2=pd.DataFrame([[11,43,67]])
print(df1)
print(df2)
df_data()
Answer:
0
0 22
1 56
2 78
0 1 2
0 11 43 67
import pandas as pd
def df_booking():
data = [['T0001','Anuj Maheta',5,1355],
['T0002','Sandeep Oza',2,1169,],
['T0003','Manavi Sharma',6,1988]]
booking=pd.DataFrame(data,
columns=['Tcode','Name','Tickets','Amount'])
print(booking.to_string(index=False))
df_booking()
Q. Create a dataframe furniture shown in the following table:
Stainless
Sofa Steel Silver 55000
Answer:
Creating Dataframe:
import pandas as pd
def df_furniture():
data = [['Sofa','Wooden','Maroon',25000],
['Dining Table','Plywood','Yellow',20000],
['Chair','Plastic', 'Red',1500],
['Sofa','Stainless Steel', 'Silver',55000],
['Chair','Wooden', 'Light Blue',2500],
['Dining Table','Aluminum', 'Golden',65000],]
furniture=pd.DataFrame(data,columns=['Item','Material','Colour','P
rice'])
print(furniture.to_string(index=False))
df_furniture()
a) print(furniture[furniture[‘Item’]==’Sofa’],”n”,furniture[furniture[‘Item’]==’Chair’])
b) print(furniture[furniture[‘Price’]>25000])
c) print(furniture[furniture[‘Price’]<10000])
d) print(furniture.iloc[::2])
Blue House 98 85 88
Red House 87 76 80
Green House 59 67 91
Yellow House 78 99 55
Answer:
import pandas as pd
def df_CCA():
data = {'House':['Blue
House','RedHouse','GreenHouse','YellowHouse'],
'Activity1':[98,87,59,78],
'Activity2':[85,76,67,99],
'Activity3':[88,80,91,55]}
furniture=pd.DataFrame(data)
print(furniture.to_string(index=False))
df_CCA()
Create a dataframe using the 2d dictionary with values as dictionary objects which
store data of CCA activities for two terms:
import pandas as pd
def df_CCA():
r={'Term1':200,'Term2':189}
g={'Term1':350,'Term2':250}
b={'Term1':400,'Term2':400}
y={'Term1':380,'Term2':300}
c={'Red':r,'Green':g,'Blue':b,'Yellow':y}
df=pd.DataFrame(c)
print(df)
df_CCA()
Create a dataframe using the following matrix by ndarray, assign row, and column
labels like MS excel.
A B C
1 98 56 87
2 32 76 65
3 55 99 88
import pandas as pd
import numpy as np
def df_ndArray():
nda=np.array([[98,56,97],[32,76,65],[55,99,88]])
df=pd.DataFrame(nda,columns=['A','B','C'],index=[1,2,3])
print(df)
df_ndArray()
Functions in SQL
A function is used to perform some particular tasks and it returns zero or more values as a
result.
Functions can be applied to work on single or multiple records (rows) of a table. Depending on
their application in one or multiple rows, SQL functions are categorised as Single row functions
and Aggregate functions.
SQL Functions
Max() Function
POWER() NOW()
UCASE()
ROUND() DATE()
LCASE() MONTH()
MOD()
MID() MONTHNAME()
LENGTH() YEAR()
LEFT() DAY()
RIGHT() DAYNAME()
INSTR()
LTRIM()
RTRIM ()
TRIM()
(A) Numeric Functions Three commonly used numeric functions are POWER(), ROUND() and
MOD().
Function Description Example with output
POWER(X,Y) Calculates X to the power Y. mysql>SELECT POWER (2,3);
OR Output: 8
POW(X,Y) mysql>SELECT POW (4,-2);
Output: 0.0625
ROUND(N,D Calculates X to the power Y. Rounds off mysql>SELECT
) number N to D number of decimal places. ROUND(2912.564, 1);
Note: If D=0, then it rounds off the Output: 2912.6
number to the nearest integer mysql>SELECT ROUND(283.2);
Output: 283
MOD(A, B) Returns the remainder after dividing mysql> SELECT MOD(21, 2);
number A by number B. Output: 1
MOD (A,B )-This function can be used to find modulus (remainder) when one number is
divided by another.
Examples:
mysql>select mod(5,3);
+-------------+
| mod(5,3) |
+-------------+
|2|
+-------------+
i) SELECT MOD(7,2) 1
v) SELECT MOD(0,5); 0
TABLE - INVENTORY
a) Calculate GST as 12 per cent of Price and display the result after rounding it off to one
decimal place.
mysql> SELECT ROUND(12/100*Price,1) "GST" FROM INVENTORY;
GST
69913.6
80773.4
68043.7
77743.0
42624.6
78589.7
61680.0
73680.0
Output:-
b) Calculate and display the amount to be paid each month (in multiples of 1000) which is to
be calculated after dividing the FinalPrice of the car into 10 instalments and remaining
amount.
mysql> SELECT CarId, FinalPrice, ROUND(FinalPrice-MOD(FinalPrice,1000)/10,0) "EMI"
FROM INVENTORY;
OUTPUT:-
String Functions- String functions accept character value as input, and return either
character or numeric values as output.
Function Description Example with output
UCASE(string) Converts string into uppercase. mysql> SELECT UCASE(“Informatics
OR Practices”);
UPPER(string) Output: INFORMATICS PRACTICES
LOWER(string) Converts string into lowercase. mysql> SELECT LOWER(“Informatics
OR Practices”);
LCASE(string) Output: informatics practices
mysql>SELECT UCASE('hello');
+-------------------+
| UCASE('hello') |
+-------------------+
| HELLO |
+------------------+
+-----------------------------------------+
SUBSTR ('exam@cbse.nic.in',3,5)|
+-----------------------------------------+
| am@cb |
+-----------------------------------------+
2. LENGTH( ) : This function returns the number of characters in the given text.
Syntax:- SELECT LENGTH(Sring); or
SELECT LENGTH(Column) FROM Table name;
Examples:
1) mysql> SELECT LENGTH ('HELLO WORLD');
+--------------------------------------+
| LENGTH('HELLO WORLD') |
+-------------------------------------+
| 11 |
+-------------------------------------+
1 row in set (0.00 sec)
3. LEFT( ) :Returns the specified number of characters including space starting from the
leftmost characters. Parameters required: text, number of characters to be extracted.
Syntax- SELECT LEFT(StrING,N); or
SELECT LEFT(column) FROM Table name;
Examples:
mysql>SELECT LEFT('INFORMATICS PRACTICES’,5);
LEFT('INFORMATICS PRACTICES’,5)
INFOR
4. RIGHT( ) :Returns the specified number of characters including space starting from the
right of the text.Parameters required : text, number of characters to be extracted.
Syntax- SELECT RIGHT(String,N);
SELECT RIGHT(column) FROM Table name;
Examples: mysql> SELECT RIGHT('INFORMATICS PRACTICES’,5);
RIGHT('INFORMATICS
PRACTICES’,5)
TICES
5. INSTR( ) :Returns the position of the first occurrence of the substring in the given string.
Returns 0, if the substring is not present in the string.
Syntax- SELECT INSTR(String,SubString); or
SELECT INSTR(String,SubString) FROM table name;
Examples:
mysql> SELECT INSTR('MySql Functions',’Sql’);
INSTR('MySql Functions',’Sql’)
3
6. LTRIM( ) :To trim the spaces, if any, from the beginning of the text.
Syntax- SELECT LTRIM(String); or
SELECT LTRIM(Column) FROM table name;
Examples:
mysql> SELECT LTRIM(' HELLO');
LTRIM(' KENDRIYA ')
‘KENDRIYA ‘
7. RTRIM( ) : Returns the given string after removing trailing white space characters.
Syntax- SELECT RTRIM(String); or
SELECT RTRIM(Column) FROM table name;
Examples:
mysql> SELECT RTRIM(' HELLO');
RTRIM(' KENDRIYA ')
‘KENDRIYA ‘
8. TRIM( ): To trim the spaces, if any, from the beginning and end of the text.
Syntax- SELECT TRIM(String); or
SELECT TRIM(Column) FROM table name;
Examples:
mysql> SELECT TRIM(' KENDRIYA ');
Let us use Customer relation shown in Table to understand the working of string functions.
TABLE -CUSTOMER
a) Display customer name in lower case and customer email in upper case from table
CUSTOMER.
mysql> SELECT LOWER(CustName), UPPER(Email) FROM CUSTOMER;
LOWER(CustName) UPPER(Email)
amitsaha AMITSAHA2@GMAIL.COM
Rehnuma REHNUMA@HOTMAIL.COM
charvinayyar CHARVI123@YAHOO.COM
gurpreet GUR_SINGH@YAHOO.COM
b) Display the length of the email and part of the email from the email id before the
character ‘@’. Note - Do not print ‘@’.
mysql> SELECT LENGTH(Email), LEFT(Email, INSTR(Email, "@")-1) FROM
CUSTOMER;
LENGTH(Email) LEFT(Email, INSTR(Email, "@")-1)
19 amitsaha2
19 rehnuma
19 charvi123
19 gur_singh
* The function INSTR will return the position of “@” in the email address. So, to print
email id without “@” we have to use position -1.
C) write the SQL query to display the area code (3 rd to 6th digit from left side in phone
no.)of the customer
mysql> SELECT MID(Phone,3,4) FROM CUSTOMER;
MID(Phone,3,4)
64587
2768
1163
1105
d) Display emails after removing the domain name extension “.com” from emails of
the customers.
mysql> SELECT TRIM(“.com” from Email) FROM CUSTOMER;
amitsaha2@gmail
rehnuma@hotmail
charvi123@yahoo
gur_singh@yahoo
Let us use the EMPLOYEE table of CARSHOWROOM database to illustrate the working of
some of the date and time functions.
TABLE-EMPLOYEE
a) Select the day, month number and year of joining of all employees.
mysql> SELECT DAY(DOJ), MONTH(DOJ), YEAR(DOJ) FROM EMPLOYEE;
DAY(DOJ MONTH(DOJ) YEAR(DOJ)
)
12 12 2017
5 6 2016
8 1 1999
2 12 2010
1 7 2012
b) If the date of joining is not a Sunday, then display it in the following format "Wednesday,
26, November, 1979."
mysql> SELECT DAYNAME(DOJ), DAY(DOJ), MONTHNAME(DOJ), YEAR(DOJ) FROM
EMPLOYEE WHERE DAYNAME(DOJ)!='Sunday';
+-----------------------+--------------+----------------------------+----------------+
| DAYNAME(DOJ) | DAY(DOJ) | MONTHNAME(DOJ) | YEAR(DOJ) |
+-----------------------+--------------+----------------------------+----------------+
| Tuesday | 12 | December | 2017 |
| Friday | 8 | January | 1999 |
| Thursday | 2 | December | 2010 |
+----------------------+---------------+---------------------------+-----------------+
c) Display the details of those Employee who have joined in the month of December
-> SELECT * FROM Employee WHERE Month (DOJ)=12;
d) Select the Employee name and designation of 1975 born.
->SELECT EmpName ,Designation FROM Employee WHERE Year(DOB)=1975;
Aggregate Functions
Aggregate functions are also called multiple row functions. These functions work on a set
of records as a whole, and return a single value for each column of the records on which the
fu
Type of Aggregate Function
4. SUM(column)- Returns the sum of the values for the specified column.
Syntax- SELECT SUM(Column) FROM Table_name;
mysql> SELECT SUM(Price) FROM INVENTORY;
Output:
SUM(Price)
2984614
TABLE- INVENTORY
CarId CarName Price Model YearManufacture FuelType FinalPrice
D001 Dzire 582613.00 LXI 2017 Petrol 652526.6
D002 Dzire 673112.00 VXI 2018 Petrol 753885.4
D003 Dzire 567031.00 Sigma NULL NULL 635074.7
E001 EECO 647858.00 Delta1 2017 CNG 397829.6
S001 SWIFT 514000.00 5 STR 2018 CNG 725601.0
Example:-
->Selects details of all the Inventory in ascending order of their Price.
SELECT * FROM INVENTORY
ORDER BY Price;
*By default Price values arrange in ascending order
->Display the Car name ,Price and year of manufacture in ascendingCar Name and descending
order of YearManufacture.
Mysql>SELECT CarName,PriceYearManufactureFROM Inventory
ORDER BY YearManufactureASC ,CarName DESC;
OUTPUT:-
CarName Price YearManufacture
Baleno 567031 NULL
Dzire 673112 2018
Dzire 582613 2017
EECO 647858 2017
SWIFT 514000 2018
Order By would return all records sorted by the YearManufacture column in ascending order with
a secondary sort by Car name in descending order.
*Null comes before the non-Null values in ascending order and in descending order Null will
appear last in result set.( In Mysql , Null is lower than non Null Values)
GROUP BY in SQL- 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.
o To divide the rows in a table into smaller groups of information, group by clause is used.
o It combines all identical rows in a group of fields.
o A column name is used for grouping
NOTE-
● Group by expression specifies the columns whose values determine the basics for grouping rows
● WHERE clause is always before GROUP BY if required.
Having clause
● This clause is used to restrict rows resulting after grouping.
● Steps followed in execution of select with group by and having clause
1. Rows are grouped according to the columns in the group by clause.
2. Then the group function is applied.
3. Groups matching with Having clauses are displayed.
WHERE CLAUSE VS HAVING CLAUSE
Where Clause Having Clase
WHERE Clause is used to filter HAVING Clause is used to filter record
the records from the table based from the groups based on the specified
on the specified condition. condition.
WHERE Clause can be used HAVING Clause cannot be used
without GROUP BY Clause without GROUP BY Clause
Syntax:- Select * from table_name
Select * from table_name Group by col_name
Where condition Having condition;
Group by col_name;
TABLE- SALE
a) Display the number of cars purchased by each customer from the SALE table.
mysql> SELECT CustID, COUNT(*) "Number of Cars" FROM SALE GROUP BY CustID;
OUTPUT:-
CustID Number of Cars
C0001 2
C0002 2
C0003 1
C0004 1
b) Display the customer Id and number of cars purchased if the customer purchased more
than 1 car from SALE table.
mysql> SELECT CustID, COUNT(*) FROM SALE GROUP BY CustID HAVING Count(*)>1;
CustID COUNT(*)
C0001 2
C0002 2
c) Display the number of people in each category of payment mode from the table SALE.
mysql> SELECT PaymentMode, COUNT(PaymentMode) FROM SALE GROUP BY
Paymentmode ORDER BY Paymentmode;
OUTPUT:-
PaymentMod Count(PaymentMode)
e
Bank Finance 2
Cheque 1
)Credit Card 2
Online 1
d) Display the PaymentMode and number of payments made using that mode more than
once.
mysql> SELECT PaymentMode, Count(PaymentMode) FROM SALE GROUP BY Paymentmode
HAVING COUNT(*)>1 ORDER BY Paymentmode;
OUTPUT:-
PaymentMode Count(PaymentMode)
Bank Finance 2
Credit Card 2
True / False
1. False 2. False 3. True 4. False 5. False 6. True 7. False 8. False9. False 10. False 11. True 12
True13 False 14. False 15. False 16 False17 False 18 True 19 False
SHORT ANSWER TYPE QUESTION
1. Meena is learning about database terms. She is a bit confused about HAVING clause and
WHERE clause. Help her to understand the difference between them along with suitable
example.
Where Clause Having Clase
WHERE Clause is used to filter HAVING Clause is used to filter record
the records from the table based from the groups based on the specified
on the specified condition. condition.
WHERE Clause can be used HAVING Clause cannot be used
without GROUP BY Clause without GROUP BY Clause
Syntax:- Select * from table_name
Select * from table_name Group by col_name
Where condition Having condition;
Group by col_name;
Ans
4. Sanam has executed following queries based on the above given table named ‘Exam’:
5. What is the purpose of Order By clause in SQL? Explain with the help of suitable example.
Ans:- Order By clause: The ORDER BY command is used to sort the result set in ascending
or descending order. The following SQL statement displays all the customer’s names in
alphabetical order: SELECT Cname FROM Customers ORDER BY Cname;
2. TRIM(): It removes the leading and trailing spaces from the given string.
Example:
SELECT TRIM(‘ Welcome world ‘ );
Output:
Welcome world
Q8. Why is it not allowed to give String and Date type arguments for SUM( ) and AVG( )
functions ?
Ans:- SUM( ) and AVG( ) functions works only with numbers and not with strings and dates.
Q9. Prachi has given the following command to obtain the highest marks
Select max(marks) from student where group by class;
But she is not getting the desired result. Help her by writing the correct command.
Ans. Select max(marks) from student group by class;
1. Which SQL aggregate function is used to count all records of a table?
COUNT(*)
2. Write a query to display current date on your system.
SELECT CURDATE();
3. Write a query to extract month part from date 3rd Feb 2021 .
SELECT MONTH(‘2021-08-03’);
4. Write a query to display name of weekday for date 03rd Feb 2021.
SELECT DAYNAME(‘2021-02-03’);
(i) To display WNO, NAME, GENDER from the table WORKER in descending order of WNO.
(ii) To display the NAME of all the FEMALE workers from the table WORKER.
(iii) To display the WNO and NAME of those workers from the table WORKER, who
are born between ‘1987-01-01’ and ‘1991-12-01’
(iv) To count and display MALE workers who have joined after ‘1986-01-01’
Ans: - SELECT WNO, NAME, GENDER FROM WORKER ORDER BY WNO DESC;
(ii) SELECT NAME FROM WORKER WHERE GENDER "FEMALE";
(iii) SELECT WNO, NAME FROM WORKER WHERE DOB BETWEEN ‘1987-01-01’ AND
‘1991-12-01’;
iv) SELECT COUNT(*) FROM WORKER WHERE GENDER "MALE" AND DOJ > ‘1986-01-
01’;
a. List the names of those students who have obtained DIV I sorted by NAME.
b. Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend received in a year
assuming that the STIPEND is paid every month.
c. To count the number of students who are either PHYSICS or COMPUTER SC graduates.
Ans:- a. SELECT NAME from GRADUATE where DIV = ‘I’ order by NAME;
b. SELECT NAME, STIPEND, SUBJECT, STIPEND*12 from GRADUATE;
c. SELECT SUBJECT, COUNT(*) from GRADUATE group by SUBJECT having
SUBJECT=’PHYISCS’ or SUBJECT=’COMPUTER SC’;
Q10. Consider the table ‘FANS’ and answer the following.
Table :-FAN
Q7. Consider the following Teacher table: Write SQL commands for (i) and (ii)
Teacher
Physics 2
Ans:-
MAX(Class)
9
ii)
iii)
Game1 COUNT(*)
A 3
B 2
C 1
count(distinct city)
6
2.
3.
avg(sale)
40600
avg(Cust_percentage) sum(sale)
82.623 1674000
4.
⮚ Cost saving
⮚ Time saving
⮚ Increased storage
TYPES OF NETWORKS
On the basis of geographical spread, networks may be classified as:
1. PAN 2. LAN 3. MAN 4. WAN
PAN (Personal Area Network):
A PAN is a network of Communicating devices (Computer, Phone, MP3/MP4 Player,
Camera etc.) in the proximity of an individual. It can cover an area of a few meters radius.
Local Area Network (LAN)
LAN is a privately owned computer network covering a small geographical area (small
physical area), like a home, office or a building such as a school. It can cover an area
spread over a few metres to a radius of a few kilometres.
Data transfer rate speed over a Local Area Network can vary from 10 mbps to 1 gbps.
The following table summarizes the characteristics of PANs, LANs, MANs and WANs.
NETWORK DEVICES :
Modem: A MODEM (Modulator DEModulator) is an electronic device that enables a
computer to transmit data over telephone lines. It is a device used to convert digital
signals into analog signals and vice versa.
RJ-45 Connector:
RJ-45 is a short term for Registered Jack-45. It is an eight-wire connector used to connect
computers on LANs, especially Ethernets.
Ethernet Card: It is a hardware device that helps in the connection of nodes within a
network. Ethernet card is also known as a network card, network adapter or NIC (network
interface card). It is a card that allows computers to communicate over a computer
network. On Ethernet card, a physical address of each communicating computer is
mentioned. Physical address is known as MAC address.
Hub:
A Hub is an electronic device that connects several nodes to form a network and
redirects the received information to all the connected nodes in broadcast mode.
Switch: A Switch is an intelligent device that connects several nodes to form a network
and redirects the received information only to the intended node(s).
A Repeater is a device that is used to regenerate a signal which is on its way
through a communication channel. A repeater regenerates the received signal
and re-transmits it to its destination.
ROUTER:
A router is more powerful and intelligent than hub or switch. It has advanced capabilities
as it
can analyze the data and decide the data is packed and send it to the other network. It
can
handle huge packets. It can be wired or wireless, both. A wireless router can provides
access
to many devices like smartphones, and connected devices
Network Topologies:
A Topology is an arrangement of physical connections among nodes in a network.
Types of Topologies
Basically, there are five types of topologies and each topology has some advantages and
disadvantages.
Mesh Topology
In mesh topology, each computer is connected with the other computer. There is a point-
to-point link between each dedicated node (workstation).
Star Topology:
In star topology each node is directly connected to a hub/switch. If any node has to send
some information to any other node, it sends the signal to the hub/switch. This signal is
then broadcast (in case of a hub) to all the nodes but is accepted by the intended node(s).
In the case of a switch the signal is sent only to the intended node(s).
Bus Topology:
In bus topology all the nodes are connected to a main cable called backbone.If any node
has to send some information to any other node, it sends the signal to the backbone. The
signal travels through the entire length of the backbone and is received by the node for
which it is intended. A small device called terminator is attached at each end of the
backbone. When the signal reaches the end of backbone, it is absorbed by the terminator
and the backbone gets free to carry another signal. This prevents the reflection of signal
back on the cable and hence eliminates the chances of signal interference.
Characteristics of Bus topology:
⮚ It is easy to install.
⮚ down.
⮚ down.
Tree Topology:
Tree topology is a combination of bus and star topologies. It is used to combine multiple
star topology networks. All the stars are connected together like a bus.
This bus-star hybrid approach supports future expandability of the network
The Internet
The Internet is the global network of computing devices
including desktop, laptop, servers, tablets, mobile
phones, other handheld devices
Applications of Internet
Following are some of the broad areas or services
provided through Internet:
• The World Wide Web (WWW)
• Electronic mail (Email)
• Chat
• Voice Over Internet Protocol (VoIP)
WWW is a set of programs and protocols that allows the user to create and display
multimedia web pages and is linked to the internet.
URL is Uniform Resource Locator and provides the location and mechanism (protocol) to
access the resource. Examples of URI identifying resources using location (i.e., URL) are:
https://www.mhrd.gov.
in, http://www.ncert.nic.in.
URL is sometimes also called a web address.
In the above URL, http is the protocol name, it can be https, http, FTP, Telnet, etc. www is
a subdomain. ncert.nic.in is the domain name.
Some of the popular email service providers are Google (gmail), Yahoo (yahoo mail),
Microsoft (outlook), etc.
Chat
Chatting or Instant Messaging (IM) over the Internet means communicating to people at
different geographic locations in real time through text message(s). It is a forum where
multiple people connect to each other, to discuss their common interests.
VoIP
Voice over Internet Protocol or VoIP, allows us to have voice call (telephone service) over
the Internet, i.e., the voice transmission over a computer network rather than through the
regular telephone network.
VoIP works on the simple principle of converting the analogue voice signals into digital
and then transmitting them over the broadband line.
IP Address: Every machine in a network has another unique identifying number, called its
IP Address. An IP address is a group of four bytes (or 32 bits) each of which can be a
number from 0 to 255. A typical IP address looks like this:
59.177.134.72
Web Page :
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 in the form of paragraphs, lists, tables, etc.
● images
● audio
● video
● software application
● other interactive contents
The first page of the website is called a home page.
A dynamic web page is one in which the content of the web page can be different for
different users. The difference in content may be because of different choices made by
the user. When a request for a dynamic web page is made to the web server, it does not
simply retrieve the page and send. Before sending the requested web page, the server
may perform some additional processes like getting information from the
database, updating date and time, updating weather information, etc. The content of such
pages changes frequently. They are more complex and thus take more time to load than
static web pages.
Dynamic web pages can be created using various languages such as JavaScript, PHP,
ASP.NET, Python, Java, Ruby, etc. These are complex to construct and design, as the
code
Web Server :
Web server is used to store and deliver the contents of a website to clients such as a
browser that request it. A web server can be software or hardware. The web browser from
the client computer sends a request (HTTP request) for a page containing the desired
data or service. The web server then accepts, interprets, searches and responds (HTTP
response) to the request made by the web browser. The requested web page is then
displayed in the browser of the client.
Hosting of a Website :
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. Once a website is created using a hardware
server, we need to connect it to the Internet so that users across the globe can access.
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 :
A cookie is a text file, containing a string of information, which is transferred by the
website to the browser when we browse it. This string of information gets stored in the
form of a text file in the browser. The information stored is retransmitted to the server to
recognise the user, by identifying pages that were visited, choices that were made while
browsing various menu(s) on a particular website. It helps in customising the information
that will be displayed.
1)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
4) Which is the name of the network topology in which there are bi-directional links
between each possible node?
(a) Ring (b) Mesh (c) Tree (d) None of these
5) In specific, if systems use separate protocols, which one of the following devices is
used to link two dissimilar systems?
(a) Repeater (b) Gateway (c) Bridge (d) Hub
6) Network device that sends the data over optimizing paths through connected loop is :
(a) gateway (b) hub (c) router (d) bridge
8) Computer Network:
A. Is a collection of hardware components and computers?
B. Is interconnected by communication channels
C. Allows sharing of resources and information
D. All of the above
9) Which of the following is not the Networking Devices?
A. Gateways B. Linux C. Routers D. Firewalls
Answers :
1 a 8 d
2 d 9 b
3 a 10 b
4 b 11 c
5 b 12 d
6 c 13 b
7 a 14
Assertion (A): - Internet cookies are text files that contain small pieces of data, like a username,
password and user’s preferences while surfing the internet.
Reasoning (R):- To make browsing the Internet faster & easier, its required to store certain information
on the server’s computer.
Q-2 ) I :
• am a key access point.
• acts as a “gate” between an organization’s network and the outside
world of the Internet.
• serves as the entry and exit point of a network.
• all data coming in or going out of a network must first pass through
me in order to use routing paths.
Who am I?
Ans :Gateway
Q- 3) Name any two popular web servers.
Ans:
i.Apache Web Server
ii. Microsoft Internet Information Server (Microsoft IIS)
● Adobe Acrobat.
● Adobe Flash.
● Java
Q-6) Give one advantage and disadvantage each of Bus and Star topology 1
Ans. Bus topology is a type of network to pology in which all devices in the network are
connected by one central network cable or coaxial cable.
Advantage: Since there is a single common data path connecting all the nodes, the bus
topology uses a very short cable length which considerably reduces the installation cost.
Disadvantage: Fault detection and isolation are difficult. This is because control of the
network is not centralized in any particular node. If a node is faulty on the bus, detection of
fault may have to be performed at many points on the network. The faulty node has then
to be rectified at that connection point.
Q- 7) I :
● am a small text file
● contain small pieces of data — like a username, password and user’s browsing
history as well as preferences
● may help to improve user’s web browsing experience.
● Who am I?
Ans : Cookies
Q-8) Name any two chat software.
Ans. MSN Messenger, Yahoo Messenger
Q- 9) What is difference between star topology and bus topology of network?
Аnswer: In star topology, nodes are connected to server individually whereas in bus
topology all nodes are connected to server along a single length of cable.
Q-10) Aman, a freelance web site developer, has been assigned a task to design few web
pages for a book shop. Help Aman in deciding out of static web page and dynamic web
page, what kind of web pages should be designed by clearly differentiating between static
and dynamic web pages on at least two points.
Q- 11) Differentiation between static and dynamic web pages:
Q- 14) Muskan, a beginner in IT field has just started learning web technologies. Help her
in understanding the difference between website and web pages with the help of a
suitable general example of each.
Ans :
Q-15 ) Ruhani wants to edit some privacy settings of her browser. How can she
accomplish her task?
On your PC or Android phone or tablet, open the browser.
1. To the right of the address bar, tap More Settings.
2. Tap Privacy and security.
Q-16 )Priyanka, a beginner in IT field has just started learning web technologies. Help her
in understanding the difference between website and web pages with the help of a
suitable general example of each.
Ans : The difference between a website and a web page is that a website is a collection of
different web pages containing information on a particular topic. A web page is an
individual page of a big website usually containing more specific information. If we
compare a website with a book, then a webpage can be compared with a single page of
that book.
Q- 17) Navya has just created a website for her company and now need to host it. Briefly
discuss the role of a web server in hosting a website.
Ans :
Role of web server in hosting a website:
A web server is the main centralized computer system that hosts and runs the websites. It
has a computer program that distributes web pages as they are requisitioned. The basic
role of the web server is to store, process and deliver the web pages to the users as and
when required.
Q-19) Parul has created a video and uploaded it on her website but she is facing a
problem in opening it on some browsers. She has heard of add-ons and plug-ins but
doesn’t know the difference between them. Help her in understanding these terms.
Add-ons and plug-ins are the tools that help to extend and modify the functionality of the
browser.
Ans : Add-ons: Add-ons are tools that get integrated into our browsers. They are similar
to regular apps or programs, but only run when the browser runs. Add-ons can allow the
viewing of certain types of web content.
Plug-in: A plug-in is a piece of software that acts as an add-on to a web browser and
gives the browser additional functionality. Plug-ins can allow a web browser to display
additional content it was not originally designed to display.
Q- 20) Sonakshi has just started learning computer networking. She is confused about the
difference between IP address and MAC address. Help her understand the difference.
IP Address MAC Address
IP stands for Internet Protocol address It stands for Media Access Control
address.
It is a logical address of a computer that It is a physical address of a computer
that
consists of 4-digit hexadecimal numbers
consists of 12-digit hexadecimal
which uniquely identify a computer
numbers
connected to a network.
assigned to the Network Interface Card
for
use as a network address in
communications
within a network segment.
Q-21 ) Tilak wants to set up a network in his office that deals with different products and
services. He wants to connect all the computers using bus topology. But he is confused
about the advantages and disadvantages of this topology. Help him understand this
topology. 2
Ans. Bus topology is a type of network to pology in which all devices in the network are
connected by one central network cable or coaxial cable.
Advantage: Since there is a single common data path connecting all the nodes, the bus
topology uses a very short cable length which considerably reduces the installation cost.
Disadvantage: Fault detection and isolation are difficult. This is because control of the
network is not centralized in any particular node. If a node is faulty on the bus, detection of
fault may have to be performed at many points on the network. The faulty node has then
to be rectified at that connection point.
Q- 22) Define Voice over Internet Protocol (VoIP). Also, explain its advantages.
Ans. VoIP is an IP telephony term for a set of facilities used to manage the delivery of
voice information over Internet. It enables a user to make cheap telephone calls over a
broadband Internet connection, instead of using a regular telephone service.
A major advantage of VoIP is that avoids the tolls charged by ordinary telephone service.
A user can make a call locally or
in other parts of US or Canada, or anywhere else in the world, eliminating long distance
fees by using a VoIP service.
The concept of VoIP is used in wireless LAN networks and sometimes referred to as
WVoIP, VoFI, VoWi-Fi and Wi-Fi VoIP.
Advantages of VoIP
(i) The biggest single advantage of VoIP has over standard telephone systems is low cost.
(ii) Using services such as true VoIP, subscribers can call one another at no cost to other
party.
(iii) Routing phone calls over existing data networks eliminate the need for separate voice
and data networks.
(iv) The ability to transmit more than one telephone call over a single broadband
connection.
(v) VoIP consists advance telephone features, e.g. call routing, screen POP and IVR.
(a) Suggest the most appropriate block where RCI should plan to install the server.
(b) Suggest the most appropriate block-to-block cable layout to connect all three blocks
for efficient communication.
(c) Which type of network out of the following is formed by connecting the computers of
these three blocks?
(i) LAN (ii) MAN (iii) WAN
(d) Which wireless channel out of the following should be opted by RCI to connect to
students from all over the world?
(i) Infrared (ii) Microwave (iii) Satellite
Ans. (a) Faculty recording block (due to maximum number of computers)
(b)
(c) (i) LAN
(d) (iii) Satellite
Q-24) Wipro Methodologies is planning to expand their network in India starting with three
cities in India to build infrastructure for research and development of their chemical
products. The company has planned to setup their main office in Pondicherry at three
different locations and have named their offices as Back Office, Research Lab and
Development Unit. The company has one more research office namely
Corporate Unit in Mumbai. A rough layout of the same is as follows:
(i) Suggest the kind of network required (out of LAN, MAN, WAN) for connection each of
the following office unit.
(a) Research Lab and Back Office
(b) Research Lab and Development Unit
(ii)Which of the following devices will you suggest for connecting all the computers with
each of their office units?
(a) Switch/Hub
(b) Modem
(c) Telephone
(iii) Suggest a cable/wiring layout for connecting the company’s local office units located in
Pondicherry. Also, suggest an effective method/technology for connecting the company’s
office located in Mumbai.
Ans :
(i) (a) The type of network between the Research Lab and the Back Office is LAN (Local
Area Network).
(b) The type of network between Research Lab and Development Unit is MAN
(Metropolitan Area Network).
(ii) (a) The suitable device for connecting all the computers within each of their office units
is switch/hub.
(iii) The cable/wiring layout for connection is as follows:
(a) Suggest the most suitable Topology for networking the computers of all wings.
(b) Name the wing where the Server is to be installed. Justify your answer.
(c) Suggest the placement of Hub/Switch in the network.
(d) Mention how economic technology will provide internet accessibility to all wings.
Ans :
(a) Star Topology can be used to network the computers of all wings.
(b) The Server should be installed in Wing A as Wing A has maximum number of
computers and installing the server in this wing will help reduce the network traffic.
(c) Hub/Switch will be required in all the wings.
(d) The economic way to provide internet accessibility to all the wings is to use the proxy
server at Wing A and connect to the internet through an Ethernet cable using routers and
switch.
Q-26) Great Studies University is setting up its academic schools at Sunder Nagar and
planning to set up a network. The university has 3 academic schools and one
administration centre as shown in the diagram below:
Centre-to-centre distance between various buildings:
(a) Suggest the most suitable place (i.e., schools/centre) to install the server of this
university with a suitable reason.
(b) Suggest an ideal layout for connecting these schools/centre for a wired connectivity.
(c) Which device will you suggest to be placed/installed in each of these schools/centre to
efficiently connect all the computers within these schools/centre?
(d) The university is planning to connect its admission office in the closest big city, which
is more than 350 km from the university. Which type of network out of LAN, MAN or WAN
will be formed? Justify your answer.
Answers :
(a) Admin Centre because it has the maximum number of computers, or Business
School because it is closest to all other centres (minimum cable length required).
(b) BUS topology is the most suitable cable layout.
(c) Switch
(d) WAN is the preferred network for this purpose because 350 km is more than the range
of LAN and MAN.
Q-27 ) Sony has set up its Branch at Srinagar for its office and web-based activities. It has
four Zones of buildings as shown in the diagram:
Unsolved
Q-28) ABC International School, Delhi has different wings Administrative Wing (W1),
Primary Wing (W2), Middle Wing(W3) and Secondary Wing(W4) as shown in the
diagram :
The school also has a branch in Mumbai. The school management wants 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 85m
W1 TO W2 40m
W2 TO W4 25m
W4 TO W3 120m
W3 TO W2 150m
W1 TO W4 170m
Q-29)
Platinum Computer services Ltd. is an international educational organization. It is planning to set up its
India campus at Mumbai with its head office in Delhi. The Mumbai office campus has four main
buildings-ADMIN, ACCOUNTS, EXAMINATION and RESULT.
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.
.
Shortest distances between various buildings:
ADMIN TO ACCOUNTS 55m
90m
ADMIN TO EXAMINATION
ADMIN TO RESULT 50m
55m
ACCOUNTS TO EXAMINATION
ACCOUNTS TO RESULT 50m
EXAMINATION TO RESULT 45m
DELHI Head Office to MUMBAI 2150m
campus
Data Protection:
Data protection secures sensitive data—from databases to big data, cloud, file system and other
crucial applications.
This can be achieved by taking proper and careful measures while working online in the
following ways:
• Through Data Encryption.
• Not sharing private information such as passwords, credit card credentials, etc.
• Not over sharing on social networking sites using public domain.
• Adopting complete security mechanism for protection against possible threats.
• Avoiding opening phishing emails.
• Being careful about using Wi-Fi connections.
• Being alert to impersonators.
Intellectual property rights (IPR)
Intellectual property refers to creations of the intellect (hence, the name); inventions,
literary and artistic works, symbols, names, images, and designs used in commerce are part of it.
Answers: (a) digital property (b) plagiarism (c) intellectual (d) shareware (e) identity theft (f)
phishing
(a) Using someone else’s Twitter handle to post something will be termed as:
(i) Fraud (ii) Identity theft (iii) Online stealing (iv) Violation
(b) Intellectual Property Rights protect the use of information and ideas that are of:
(i) Ethical Value (ii) Moral Value (iii) Social Value (iv) Commercial Value
(c) Credit card fraud may include:
(i) Stealing of credit card (ii) Unauthorized and illegal use of credit card
(iii) Stealing information (iv) Phishing
(d) The term “Intellectual Property Rights” covers:
(i) Copyrights (ii) Trademarks (iii) Patents (iv) All of these
(e) Which of the following is a/an open-source software?
(i) Microsoft Windows (ii) Adobe Photoshop (iii) MySQL (iv) MS Powerpoint
(f) Online personal account, personal websites are examples of:
(i) Digital Wallet (ii) Digital Property (iii) Digital Certificate (iv) Digital Signature
(g) Unsolicited commercial email is known as ........................ .
(i) Spam (ii) Malware (iii) Virus (iv) Spyware
Answers: (a) (ii) (b) (iv) (c) (ii) (d) (iv) (e) (iii) (f) (ii) (g) (i)
SHORT ANSWER QUESTIONS
6. Explain phishing.
Ans. Phishing is the fraudulent attempt to obtain sensitive information such as usernames,
passwords and credit card details (and money), often for malicious reasons, by disguising as a
trustworthy entity in an electronic communication. Phishing is typically carried out by email
spoofing or instant messaging, and it often directs users to enter personal information at a fake
website, the look and feel of which is identical to the legitimate one and the only difference is
the URL of the website in question.
Note: Question paper will be prepared following the General Instructions given below.
General Instructions:
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.
SECTION A
1. Which among the following network topologies has the highest transmission 1
speed ?
i. LAN
ii. WAN
iii. MAN
iv. Both LAN and WAN have equal transmission speeds.
2. The practice of taking someone’s work or ideas and passing them off as one’s 1
own is known as _____.
i. Identity Theft
ii. Spamming
iii. Hacking
iv. Plagiarism
3. Which of the following constitute e-waste? 1
i. Discarded computers
ii. Damaged printers
iii. Useless CDs
iv. All of the above
4. Which is the subset of SQL commands used to manipulate Oracle Database 1
Structures, including tables?
i. gh
ii. 23
iii. bc
iv. ab
6. Samyra’s continuous online classes and increasing use of computer made his 1
mother worried about his health. Which of the following point should not be
suggested her mother to take care of ?
i. Sit in right posture
ii. Take breaks and do some physical activity
iii. Keep the gadget above your height
iv. Periodically rotate and watering eyes
7. Which of following is incorrect SQL? 1
8. Which one of the following set of operations is a valid set of aggregate functions 1
in SQL?
i. COUNT,MAX,AVG,SUM
ii. MAX,AVG,SUM,SELECT
iii. UNION,COUNT,MIN,DESC
iv. AVG,MIN,MAX,ASC
9. Which MySQL aggregate functions is used to retrieve minimum value? 1
i. MAX( )
ii. MIN( )
iii. AVG( )
iv. MINIMUM( )
10. To display first five rows of a series object ‘S’, you may write: 1
i. S.head()
ii. S.Tail(5)
iii. S.Head(5)
iv. S.tail()
11. Which of the following statement is correct for importing pandas in Python? 1
i. import pandas
ii. import pandas as pd
iii. import pandas as pds
iv. All of the above
12. Which of the following statement for creating dataframe is valid? 1
i. df=pd.dataframe(dict1)
ii. df=pd.Dataframe(dict1)
iii. df=pd.dataFrame(dict1)
iv. df=pd.DataFrame(dict1)
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
i. Both (A) and (R) are true and (R) is the correct explanation for (A)
ii. Both (A) and (R) are true and (R) is not the correct explanation for (A)
iii. (A) is True but (R) is False
iv. (A) is false but (R) is True
17. Assertion (A): - The internet is a collection of interconnected computer 1
networks, linked by transmission medium such as copper wires, fiber-
optic cables, wireless connections etc.
18. Assertion (A):pandas is an open source Python library which offers high 1
performance , easy-to-use data structure and data analysis tools.
Reasoning (R): - Developers and professionals are using the pandas library in
data science and machine learning.
SECTION B
19. Difference between website and webpage. 2
OR
Explain Bus and Star topology.
20. Adesh, a database administrator needs to display house wise total number of 2
activities of ‘Ashoka’ and ‘Tagore’ house. He is encountering an error while
executing the following query:
Help her in identifying the reason of the error and write the correct query by
suggesting the possible correction (s).
21. What is the purpose of Group By clause in SQL? Explain with the help of 2
suitable example.
22. Write a program to create a series from dictionary that stores classes 2
(6,7,8,9,10) as keys and number of students as values.
23. Mention any four steps to recycling and recovery under e-waste management. 2
OR
Write any four steps towards awareness about health concerns related to the
usage of technology.
24. What will be the output of the following code: 2
import pandas ad pd
import numpy as num
arr=num.array([31,47,121])
S1=pd.Series(arr, index=(1,11,111))
print(S1[111])
25. Write code statements for a dataframe df for the following – 2
TABLE: STATIONARY
INO INAME CITY QTY DOP
I01 PENCIL RAIPUR 80 2022-09-22
I02 PEN BILASPUR 120 2022-09-23
I03 PAPER DURG 500 2022-12-04
I04 ERASER BHILAI 50 2022-10-10
I05 SHARPNER JANJGIR 60 2022-10-20
29. 3
i. Explain following terms.
(a) Phishing (b) Denial-of-service (c ) Identity theft
OR
What do you mean by a hacker? Mention their types (any two).
30. Based on table EMPLOYEE given here, write suitable SQL queries for the 3
following:
32. Ravya Industries has set up its new center at Kaka Nagar for its office and web 5
based activities. The company compound has 4 buildings as shown in the
diagram below:
Building
Jazz
Harsh
Building
Building
Center to center distances between various building is as follows :
Harsh Building to Raj Building 50m
Raj Building to Fazz Building 60m
Fazz Building to Jazz Building 25m
Jazz Building to Harsh Building 170m
Harsh Building to Fazz Building 125m
Raj Building to Jazz Building 90m
OR
Draw 4 horizontal bars with a beautiful green color. Give suitable
title also and save this file.
SECTION E
34. Consider the following table Teacher. Write SQL commands for the following 1+1+2
Statements.
No. Name Age Department Dateofjoin Salary Sex
1. Jugal 34 Computer 10/01/97 12000 M
2. Sharmil 31 History 24/03/98 20000 F
a
3. Sandee 32 Maths 12/12/96 30000 M
p
4. Sangeet 35 History 01/07/99 40000 F
a
5. Rakesh 42 Maths 05/09/97 25000 M
6. Shyam 50 History 27/06/98 30000 M
1. i. LAN 1
2. iv. Plagiarism 1
5. i. gh 1
8. i. COUNT,MAX,AVG,SUM 1
9. ii. MIN() 1
10. i. S.head() 1
15. i. Copyright 1
1 mark for correct answer
17. ii. Both (A) and (R) are true and (R) is not the correct explanation for 1
(A)
1 mark for correct answer
18. i. Both A and R are true and R is the correct explanation for A 1
1 mark for correct answer
19. Website: A website is a collection of publicly accessible, interlinked 2
Web pages that share a single domain name.
Web Page: A Web Page is a part of a website and is commonly written
in HTML. It can be accessed through a web browser.
20. The problem with the given SQL query is order by apply on column followed 2
by ascending/descending.
To correct the error, DESC should be used after column name.
Corrected Query:
SELECT HOUSE, COUNT (ACTIVITIES) FROM STUDENT
ORDER BY NAME DESC;
26. i. 6400 3
2500
3600
ii. DURG
iii. 3
1 mark for each correct output
OR
GROUP BY clause is used in a SELECT statement in combination with
aggregate functions to group the result based on distinct values in a column.
HAVING clause is used to apply a filter on the result of GROUP BY
based on the specified condition.
For example:
To display total number of male and female employees from the table
Employee, we need to first group records based on the gender then we should
count records with the help of count() function. To filter the record gender
wise, HAVING clause is used.
Considering the following table EMPLOYEE:
Emp No Name Design Gender City Salary
9 Anushka Manager M Raipur 89430
10 Vandana HR M Durg 76440
11 Vibha Sales F Agra 65470
12 Dhrishti HR F BBSR 75492
13 Bhoomi Manager M Delhi 87360
14 Aditi Sales F Dehradun 68256
15 Monika Engineer F Mysore 83324
16 Priyanshi Engineer M Mysore 84429
Output:
Gender Count(Gender)
M 4
F 4
Building
Harsh Jazz
Building Building
(ii) The most suitable place/ block to house the server of this organisation
would be Raj Building, as this block contains the maximum number of
computers, thus decreasing the cabling cost for most of the computers
as well as increasing the efficiency of the maximum computers in the
network.
(iii) (a) Raj Building since it contains largest number of computers.
(b) In the suggested layout, a hub/switch each would be needed in all
the buildings, to interconnect the group of cables from the different
computers in each block.
(iv) The type of network that shall be formed to link the sale counters
situated in various parts of the same city would be a MAN, because
MAN (Metropolitan Area Networks) are the networks that link computer
facilities within a city.
(iv) Add ons
1 Mark for each correct answer
33. (i) 5
import matplotlib.pyplot as plt
x=[1,2,3]
y=[2,4,1]
plt.plot(x,y, color=’g’)
plt.xlabel('x-axis')
plt.ylabel('y-axis')
plt.title('IMy first graph!')
plt.show()
(ii) plt.savefig("aa.jpg")
(iii)plt.plot(x,y,color=’k
’)
OR
Statement1 :
swimming 2
tt 4
skating 6
khokho 8
bb 10
chess 12
football 14
cricket 16
statement2:
chess 6
football 7
cricket 8
statement3:
2
Statement4:
Skating 3
Khokho 4
1 mark for each correct statement
OR
(i) pd
(ii) DataFrame
(iii) Df[[‘Month’,’Passengers’]]]df[‘Month’]==’Jan’]
(iv) Df.index=[“Air India”, “Indigo”,”Spicejet”,”Jet”,”Emirate”]
1 mark for each correct answer
OR
print(df.Tot_students-df.First_Runnerup)
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. Which of the following is used in computer network? 1
v. Hub
vi. Repeater
vii. Gateway
viii. All the above
2. As soon we get any good news from any source in social media. 1
v. We should forward to many people so that they can be benefited.
vi. We should never forward to anyone.
vii. We should confirm the news from any reliable source before forwarding.
viii. We should forward to our family and friends only.
3. Which of the following are Net Etiquette? 1
v. Be Ethical
vi. Be Respectful
vii. Be Responsible
viii. All of the above
4. Write SQL command to display the name of current month : 1
v. SELECT MONTH(CURDATE())
vi. SELECT NAMEOFMONTH(CURDATE())
vii. SELECT MONTHNAME(CURDATE())
viii. All of the above
5. Consider the string ‘infopractice’.Write SQL command to display first five 1
characters:
6. ________ are the records and traces that we left behind as we use internet. 1
v. Digital Footprints
vi. Data Protection
vii. Plagiarism
viii. Digital Data
7. Which of following function returns an integer that indicates the position of the 1
first occurrence of the sub-string within the string?
v. INSTR()
vi. RTRIM()
vii. LENGTH()
viii. TRIM
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
v. Both (A) and (R) are true and (R) is the correct explanation for (A)
vi. Both (A) and (R) are true and (R) is not the correct explanation for (A)
vii. (A) is True but (R) is False
viii. (A) is false but (R) is True
17. Assertion (A): - Digital footprint is the trail of data we leave behind when 1
we visit any website (or use any online application or portal) to fll-in data
or perform any transaction.
OR
Name any two mail service providers
Showing output of the (i) query is 10 and (ii) query is 08. Ankit is confused
about the above result. Help him to identifying the errors if any. Explain the
suggestive reason for the above output.
21. What is the purpose of Having clause in SQL? Explain with the help of suitable 2
example.
22. Write a program in Python to create the pandas series of all the characters in the 2
name accepted from user.
23. Suggest any four method to avoid the problems occurred during use of electronic 2
gadgets.
OR
Mention any four kind of illness due to heavy use of electronic devices.
24. What will be the output of the following code: 2
import pandas as pd
L1=list(“My name is Ravi Kumar”)
S1=pd.Series(L1)
print(S1[11])
25. 2
Consider the following Series object, S_num
Pen 20
Pencil 15
Gel pen 30
Eraser 10
TABLE: SCHOOL
ADN CLASS STREAM
PERCENT DOA
A001 12 SCIENCE 90.32 2022-06-11
A002 11 COMMERCE 89.6 2022-02-19
A003 11 ARTS 78.12 2021-12-04
A004 12 SCIENCE 81.83 2021-10-10
A005 12 ARTS 95.13 2021-10-20
OR
Discuss the significance of ORDER by clause in detail with the help of
suitable example.
SECTION D
31. Write suitable SQL query for the following: 5
i. To display Power of 12.
ii. Display the Length of ‘Vidyanjali’.
iii. Display the date of today.
iv. Display ‘Tej’ from string ‘SaiTeja’.
v. Display total marks obtained by a student in PT1column from
student table.
OR
i. trim():
ii. instr():
iii. day():
iv. count(*):
v. group by :
32 Quick learn University is setting up its Academic blocks at Prayag Nagar and
planning to set up a network. The university has 3 academic blocks and one Human
Resource Centre as shown in the diagram below:
Business Technology
Block Block
Law HR
Block Center
Law Block 15
Technology Block 40
HR Centre 115
Business Block 25
(i) Suggest the most suitable place (i.e. Block/Centre) to install the server of
this university with a suitable reason.
(ii) Suggest an ideal layout for connecting these blocks/centre for a wired
connectivity.
(iii) Which device you will suggest to be placed/installed in each of these
blocks/centre to efficiently connect all the computers with in these
blocks/centre.
(iv) The university is planning to connect its admission office in the closest big
city, which is more than 250 km from university, which type of network
out of LAN, MAN, WAN will be formed? Justify your answer.
OR
Write a python program to plot a line chart based on the given data to depict
the runs scored by India.
Over=[10,20,30,40,50]
Runs=[0,25,50,75,100]
SECTION E
34. 1+1+2
Find the output from (a) to (f) from given Table: Hospital:
TABLE:Hospital
No Name Department DOA Charges Sex
1 Sandeep Surgery 23/02/20 300 M
2 Ravina Orthopedic 20/01/20 200 F
3 Karan Orthopedic 19/02/20 200 M
4 Tarun Surgery 01/01/98 300 M
5 Zubin ENT 12/02/20 250 M
6 Ketaki ENT 24/02/20 300 F
7 Ankita Cardiology 20/02/20 800 F
8 Zareen Gynecology 22/02/20 300 F
9 Kush Cardiology 13/01/20 800 M
10 Shaliya Nuclear Medicine 19/02/20 400 M
( i) Write a query to display names in upper case.
(ii) Write a query to count total number of departments.
(iii) Write a query to find average of charges of female .
OR (Option for part iii only)
2. iii. We should confirm the news from any reliable source before 1
forwarding.
1 mark for correct answer
3. iv. All of the above 1
6. i. Digital Footprints 1
7. i. INSTR() 1
17. ii. Both (A) and (R) are true and (R) is not the correct explanation for 1
(A)
1 mark for correct answer
18. i. Both A and R are true and R is the correct explanation for A 1
1 mark for correct answer
19. 2
He must see to the settings/ extension option in the browser & then
allow add ons and plugins from it to activate its working.
1 mark for correct explanation of each term
Or
Gmail/Outlook/ProtonMai/AOL/Zoho Mail/iCloud Mail/Yahoo!
Mail/GMX etc.
1 mark for each
20. The problem with the given SQL query is that WHERE clause should not be 2
used with Group By clause.
To correct the error, HAVING clause should be used instead of
WHERE. Corrected Query:
SELECT HOUSE, COUNT(*) FROM STUDENT GROUP BY HOUSE
HAVING HOUSE= ‘RED’ OR HOUSE=’YELLOW’;
OR
ORDER BY clause to display the output table of a query in either ascending or
descending alphabetical order. The ORDER BY clause must be the last clause
that you specify in a query.
For example:
30
Business Technology
Block Block
40 15
Law HR
Block Center
(iii) Switch
(iv) WAN because LAN and MAN cannot cover 250 km.
(v) Firewall
OR
import matplotlib.pyplot as plt
Over=[10,20,30,40,50]
Runs=[0,25,50,75,100]
plt.plot(Over,Runs)
plt.show()
import pandas as pd
vend={'vname':['A','B','C','E','F'],
'item':['chair','table','pen','eeraser','sketch pen'],
'area':['east','west','south', 'SW','NE'], 'qty':[30,45,23,12,100]}
vendor=pd.DataFrame(vend,index=[200,201,202,203,204])
print(vendor)
PART A
01 The main computer in any network is called as 1
a. Client
b. Server
c. Hub
d. Switch
02 Sending the email to any cc means 1
a. Sending the mail with a carbon copy
b. Sending the mail without a carbon copy
c. Sending the email to all and hiding the address
d. All of the above
03 Which of the following reduce e-waste? 1
a. purchasing more and more gadgets
b. using them for a short time and then discarded
c. good maintenance
d. all of these
04 Consider the following query : 1
SELECT name FROM stu WHERE subject LIKE ‘_______ Computer Science’;
Which one of the following has to be added into the blank space to select the
subject which has Computer Science as its ending string?
a) $
b) _
c) ||
d) %
05 If column “Marks” contains the data set {25, 35, 25, 35, 38}, what will be the 1
output after the execution of the given query?
SELECT MARKS (DISTINCT) FROM STUDENTS;
a) 25, 35, 25, 35, 38
b) 25, 25, 35, 35
c) 25, 35, 38
d) 25, 25, 35, 35
06 The term FLOSS is associated with: 1
a) Non-open source software
b) proprietary software
c) Open Source software
d) None of these
07 Which of the following sublanguages of SQL is used to query information from 1
the data base and to insert tuples into, delete tuples from, and modify tuples
in the database?
a) DML (Data Manipulation Language)
b) DDL (Data Definition Language)
c) Query
d) Relational Schema
08 In SQL, which command is used to SELECT only one copy of each set of 1
duplicable rows
a) SELECT DISTINCT
b) SELECT UNIQUE
c) SELECT DIFFERENT
d) All of the above
09 An attribute in a relation is foreign key if it is the _________key in any other 1
relation.
a) Candidate
b) Primary
c) Super
d) Sub
10 Pandas mainly used for 1
a) Data Recovery
b) Data Backup
c) Data Visualizations
d) Data Analysis
11 Which of the following statement is not correct for Pandas? 1
a) Pandas is open source built in library
b) Pandas offers high-performance, easy to use data structures
c) Pandas provides tools for backup and recovery
d) Pandas provides tools for data analysis
12 You can create a Python pandas series using? 1
a) sequence
b) ndarray
c) tuple
d) all of the above
13 An application that can be accessed via a web browser, over a network 1
connection is called a ___________.
a. Web-based application
b. Server-based application
c. Both a) and b)
d. None of the above
14 Which of the following queries contains an error? 1
a) Select * from emp where empid = 10003;
b) Select empid from emp where empid=10006;
c) Select empid from emp;
d) Select empid where empid=1009 and lastname=’GUPTA’;
15 With SQL, how can you return the number of not null record in the Project 1
field of “Students” table?
a) SELECT COUNT (Project) FROM Students
b) SELECT COLUMNS (Project) FROM Students
c) SELECT COLUMNS (*) FROM Students
d) SELECT COUNT (*) FROM Students
16 A______ is property of the entire relation, which ensures through its value 1
that each tuple is unique in a relation.
a) Rows
b) Key
c) Attribute
d) fields
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 footprint is the trail of data we leave behind when we 1
visit 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): pandas is an open source Python library which offers high 1
performance, easy-to-use data
structures and data analysis tools.
Reason (R): Professionals and developers are using the pandas library in data
science and machine learning.
PART B
19 What is the difference between STAR and BUS topologies? 2
OR
Why we use a domain name address in place of IP address of the Server to
access any web site?
20 Anjali 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;
She gets the output 4 for the first command but get an output 3 for the second
command. Explain the output with justification.
21 Make difference between DELETE and DROP command. Explain with suitable 2
examples of each.
22 Write a python code to create a dataframe with appropriate headings from 2
the list given below:
['S101', 'Amy', 70], ['S102', 'Bandhi', 69], ['S104', 'Cathy', 75], ['S105',
'Gundaho', 82]
# initialize list of lists
data = [['S101', 'Amy', 70], ['S102', 'Bandhi', 69], ['S104', 'Cathy', 75], ['S105',
'Gundaho', 82]]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns = ['ID', 'Name', 'Marks'])
# printdataframe. print(df )
(½ mark for correct initialization, 1 mark for correct
dataframe and ½ mark for printing dataframe)
23 What do you understand by e-waste management? Explain. 2
OR
Explain Digital Rights Management. How can we protect our content?
24 Predict the output of the following code fragments. 2
x=np.array([1,2,3])
y=np.array([3,2,1])
z=np.concatenate([x,y])
prit(z)
25 Write one python program to find the following from the given dataframe DF: 2
Rollno Name Age Marks
11 Aruna 18 68
12 Mohini 14 47
13 Kiya 13 78
14 Lakshmi 16 87
15 Ravisha 14 60
a) Maximum marks and minimum marks
b) sum of all the marks
PART C
26 A Gift Gallery has different stores in India. Database Administrator Abhay 3
wants to maintain database of their Salesmen in SQL to store the data, He has
decided that
Name of the database: GiftGallery
Name of the table: Salesman
Attributes of the tables: Scode – Numeric, Sname – Character 25, Address -
Character 25, Dojoin - Date, Sales – Numeric and Area – Character 10
Consider the following records in ‘Salesman’ table and answer the given
questions:
df = pd.DataFrame(exam_data , index=labels)
print(df)
28 Write the code in pandas to create the following dataframes: 3
df1 df2
mark1 mark2 mark1 mark2
0 10 15 0 30 20
1 40 45 1 20 25
2 15 30 2 20 30
3 40 70 3 50 30
Write the commands to do the following operations on the dataframes
given above:
(i) To add dataframes df1 and df2.
(ii) To subtract df2 from df1
(iii) To rename column mark1 as marks1in both the dataframes df1 and df2.
(iv) To change index label of df1 from 0 to zero and from 1 to one.
29 Rishi has to prepare a project on “Swachh Bharat Shreshth Bharat”. He decides 3
to get information from the Internet. He downloads three web pages
(webpage1, webpage 2, webpage 3) containing information on the given topic.
1. He read a paragraph on from webpage 1 and rephrased it in his own words.
He finally pasted the rephrased paragraph in his project.
2. He downloaded three images of from webpage 2. He made a collage for his
project using these images.
3. He also downloaded an icon from web page 3 and pasted it on the front
page of his project report.
i. Step1 An Example of __________
a. Plagiarism
b. Paraphrasing
c. copyright infringement
d. Intellectual Property right
ii. Step 2 An act of __________
a. plagiarism
b. copyright infringement
c. Intellectual Property right
d. Digital Footprints
iii. Step 3 An act of _________
a. Plagiarism
b. Paraphrasing
c. copyright infringement
d. Intellectual Property right
OR
Explain the role of online social media campaigns, crowdsourcing and smart
mobs in society.
30 Based on table CLUB given here, write suitable SQL queries for the following: 3
OR
What will be the output of the following code:
import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,5,1])
plt.show()
PART E
34 Write SQL queries for (i) to (iv) which are based on the tables. 1+1+2
Table: ACCOUNT
ANO ANAME ADDRESS
Table: TRANSACT
(i)To display details of all transactions of TYPE Deposit from Table TRANSACT
(ii)To display the ANO and AMOUNT of all Deposits and Withdrawals done in
the month of October 2017 from table TRANSACT.
(iii)To display the last date of transaction (DOT) from the table TRANSACT for
the Accounts having ANO as 103.
OR (OPTION FOR PART iii ONLY)
To display all ANO, ANAME and DOT of those persons from tables ACCOUNT
and TRANSACT who have done transactions less than or equal to 3000.
35 Suppose a data frame contains information about student having columns 1+1+2
rollno, name, class and section. Write the code for the following:
(i) Add one more column as fee
(ii) Write syntax to transpose data frame.
(iii) Write python code to delete column fee of data frame.
OR (OPTION FOR PART iii ONLY)
Write the code to append df2 with df1
PART A
01 The main computer in any network is called as 1
a. Client
b. Server
c. Hub
d. Switch
Ans b
1 mark for correct answer
02 Sending the email to any cc means 1
a. Sending the mail with a carbon copy
b. Sending the mail without a carbon copy
c. Sending the email to all and hiding the address
d. All of the above
Ans : a
1 mark for correct answer
03 Which of the following reduce e-waste? 1
a. purchasing more and more gadgets
b. using them for a short time and then discarded
c. good maintenance
d. all of these
Ans c
1 mark for correct answer
04 Consider the following query 1
SELECT name FROM stu WHERE subject LIKE ‘_______ Computer Science’;
Which one of the following has to be added into the blank space to select the
subject which has Computer Science as its ending string?
a) $
b) _
c) ||
d) %
ans d
1 mark for correct answer
05 If column “Marks” contains the data set {25, 35, 25, 35, 38}, what will be the 1
output after the execution of the given query?
SELECT MARKS (DISTINCT) FROM STUDENTS;
a) 25, 35, 25, 35, 38
b) 25, 25, 35, 35
c) 25, 35, 38
d) 25, 25, 35, 35
Ans C
1 mark for correct answer
06 The term FLOSS is associated with: 1
a) Non-open source software
b) proprietary software
c) Open Source software
d) None of these
Ans c
1 mark for correct answer
07 Which of the following sublanguages of SQL is used to query information from 1
the data base and to insert tuples into, delete tuples from, and modify tuples
in the database?
a) DML (Data Manipulation Language)
b) DDL (Data Definition Language)
c) Query
d) Relational Schema
Ans A
1 mark for correct answer
08 In SQL, which command is used to SELECT only one copy of each set of 1
duplicable rows
a) SELECT DISTINCT
b) SELECT UNIQUE
c) SELECT DIFFERENT
d) All of the above
Ans A
1 mark for correct answer
09 An attribute in a relation is foreign key if it is the _________key in any other 1
relation.
a) Candidate
b) Primary
c) Super
d) Sub
Ans b
1 mark for correct answer
10 Pandas mainly used for 1
a) Data Recovery
b) Data Backup
c) Data Visualizations
d) Data Analysis
Ans d
1 mark for correct answer
16 A______ is property of the entire relation, which ensures through its value 1
that each tuple is unique in a relation.
a) Rows b) Key c) Attribute d) fields
Ans b
1 mark for correct answer
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 footprint is the trail of data we leave behind when we 1
visit 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.
Ans B
1 mark for correct answer
18 Assertion (A): pandas is an open source Python library which offers high 1
performance, easy-to-use data
Structures and data analysis tools.
Reason (R): Professionals and developers are using the pandas library in data
science and machine learning.
Ans A
25 Write one python program to find the following from the given dataframe DF: 2
Rollno Name Age Marks
11 Aruna 18 68
12 Mohini 14 47
13 Kiya 13 78
14 Lakshmi 16 87
15 Ravisha 14 60
a) Maximum marks and minimum marks
b) sum of all the marks
Ans:
a. print(“Maximum marks = “ , DF[“Marks”].max())
print(“Minimum marks = “ , DF[“Marks”].min())
b. print(“Sum of marks = “ , DF[“Marks”].sum())
1 mark for each correct answer
PART C
26 A Gift Gallery has different stores in India. Database Administrator Abhay 3
wants to maintain database of their Salesmen in SQL to store the data, He has
decided that
Name of the database: GiftGallery
Name of the table: Salesman
Attributes of the tables: Scode – Numeric, Sname – Character 25, Address -
Character 25, Dojoin - Date, Sales – Numeric and Area – Character 10
Consider the following records in ‘Salesman’ table and answer the given
questions:
ii. Which of the following commands will display the details of all sales record
of North Area, regardless of case (whether North / NORTH / north):
Ans: Select * from salesman where upper(area)=’NORTH’;
iii. Help Priya to display sname and sales of east and west areas
ANS: Select sname, sales from Salesman where area=” East” or area=” West”;
Sample DataFrame:
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily',
'Michael', 'Matthew', 'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Ans:
import pandas as pd
import numpy as np
df = pd.DataFrame(exam_data , index=labels)
print(df)
1 mark for Import statement
1 mark for creating dictionary
1 mark for Creating DataFrame and output
28 Write the code in pandas to create the following dataframes: 3
df1 df2
mark1 mark2 mark1 mark2
0 10 15 0 30 20
1 40 45 1 20 25
2 15 30 2 20 30
3 40 70 3 50 30
Write the commands to do the following operations on the dataframes
given above:
(i) To add dataframes df1 and df2.
(ii) To subtract df2 from df1
(iii) To rename column mark1 as marks1in both the dataframes 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':[30,40,15,40], 'mark2':[20,45,30,70]});
df2 = pd.DataFrame({'mark1':[10,20,20,50], 'mark2':[15,25,30,30]});
print(df1) print(df2)
(i) print(df1.add(df2))
(ii) print(df1.subtract(df2))
(iii) df1.rename(columns={'mark1':'marks1'}, inplace=True) print(df1)
(iv) df1.rename(index = {0: "zero", 1:"one"}, inplace = True) print(df1)
(1 mark for creating each dataframe and ½ mark for each correct command)
29 Rishi has to prepare a project on “Swachh Bharat Shreshth Bharat”. He decides 3
to get information from the Internet. He downloads three web pages
(webpage1, webpage 2, webpage 3) containing information on the given topic.
1. He read a paragraph on from webpage 1 and rephrased it in his own words.
He finally pasted the rephrased paragraph in his project.
2. He downloaded three images of from webpage 2. He made a collage for his
project using these images.
3. He also downloaded an icon from web page 3 and pasted it on the front
page of his project report.
i. Step1 An Example of __________
a. Plagiarism
b. Paraphrasing
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
1 mark for each correct option
OR
Explain the role of online social media campaigns, crowdsourcing and smart
mobs in society.
Ans:
Role of Social Media Campaigns: -
A social media campaign should focus around a singular business goal,
whether it's on Facebook or Instagram. Common goals for social media
campaigns include:
• Getting feedback from users.
• Building email marketing lists
• Increasing website traffic
-> Crowdsourcing is the practice of engaging a ‘crowd’ or group for a common
goal — often innovation, problem solving, or efficiency. It is powered by new
technologies, social media and web 2.0. Crowdsourcing can take place on
many different levels and across various industries.
-> Smart mobs, so named because each person in the
group uses technology to receive information on where to go and what to do.
This ability to stay on top of current events makes smart mobs extremely
effective
(1 mark for one correct role of social media campaign, 1 mark for one correct
role of Crowdsourcing and 1 mark for one correct role of Smart mob)
30 Based on table CLUB given here, write suitable SQL queries for the following: 3
e. 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 Fiber ii) Co-axial Cable iii) Ethernet Cable
Ans:
a. Suitable layout
b. Block C because of the highest no of computer
c. VPN in Internet or Satellite communication can be use
d. Switch in Block A, B and C. repeater in Block C or Head Office
e. Optical Fiber
1 Mark for each correct answer
33 Write a Python program to draw a line as shown below using given axis values 5
with suitable label in the x axis, y axis and a title and also save the graph in a
file.
Ans:
Ans:
Table: TRANSACT
(i)To display details of all transactions of TYPE Deposit from Table TRANSACT
(ii)To display the ANO and AMOUNT of all Deposits and Withdrawals done in
the month of October 2017 from table TRANSACT.
(iii)To display the last date of transaction (DOT) from the table TRANSACT for
the Accounts having ANO as 103.
Ans:
(i) SELECT * FROM TRANSACT WHERE TYPE = 'Deposit';
(ii) SELECT ANO,AMOUNT FROM TRANSACT WHERE DOT >= '2017-10-01' AND
DOT <= '2017-10-31';
1 mark for each correct query
OR
SELECT ANO,AMOUNT FROM TRANSACT WHERE DOT BETWEEN '2017-10-01'
AND '2017-10-31';
(iii) SELECT MAX(DOT) FROM TRANSACT WHERE ANO = 103;
OR (OPTION FOR PART iii ONLY)
To display all ANO, ANAME and DOT of those persons from tables ACCOUNT
and TRANSACT who have done transactions less than or equal to 3000.
Ans:
SELECT ACCOUNT.ANO,ANAME,DOT FROM ACCOUNT,TRANSACT WHERE
ACCOUNT.ANO=TRANSACT.ANO AND AMOUNT <=3000; OR
SELECT A.ANO,ANAME,DOT FROM ACCOUNT A,TRANSACT T WHERE
A.ANO=T.ANO AND AMOUNT <=3000;
2 marks for correct query
35 Suppose a data frame contains information about student having columns 1+1+2
rollno, name, class and section. Write the code for the following:
(i) Add one more column as fee
(ii) Write syntax to transpose data frame.
(iii) Write python code to delete column fee of data frame.
OR (OPTION FOR PART iii ONLY)
Write the code to append df2 with df1
Ans:
I. Df1[‘fee’]=([100,200,300])
II. Df1=Df1.T
1 mark for each correct query
III. Df2.pop(‘fee’)
Df2=Df2.append(Df1)
2 marks for correct query
PART A
01 A network with all client computer and no server is called 1
a. Networking
b. Peer to Peer Computing
c. Client Server Computing
d. Any of them
23 What is plagiarism? How can you avoid plagiarism while referring to someone’s 2
else’s creation?
OR
What is the common gender and disability issues faced while teaching / using
computers in classrooms?
25 Write one python program to find the following from the given dataframe DF: 2
Rollno Name Age Marks
11 Aruna 18 68
12 Mohini 14 47
13 Kiya 13 78
14 Lakshmi 16 87
15 Ravisha 14 60
a) Mean and mode of age of the students
b) Count the no of rows present in the dataframe
PART C
26 A Gift Gallery has different stores in India. Database Administrator Abhay wants 3
to maintain database of their Salesmen in SQL to store the data, He has decided
that
Name of the database: GiftGallery
Name of the table: Salesman
Attributes of the tables: Scode – Numeric, Sname – Character 25, Address -
Character 25, Dojoin - Date, Sales – Numeric and Area – Character 10
Consider the following records in ‘Salesman’ table and answer the given
questions:
i. The command to display the name of the salesman along with the sales amount
rounded off to one decimal point will be:
ii. Which of the following commands will display the details of all sales record of
North Area, regardless of case (whether North / NORTH / north):
iii. Help Priya to display sname and sales of east and west areas
27 Write a Pandas program to create and display a DataFrame from a specified 3
dictionary data which has the index labels.
Sample DataFrame:
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael',
'Matthew', 'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
28 Consider the following dataframe 3
(a) List the names of those students who have obtained DIV I sorted by NAME.
(b) Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend
received in a year assuming that the STIPEND is paid every month.
(c) To count the number of students who are either PHYSICS or COMPUTER SC
graduates.
OR
(i) There is column salary in table employee. The following two statements are
giving different outputs. What may be the possible reasons?
Select count(*) from employee select count(salary) from employee
(ii) Mr. Sanghi created two tables with City as Primary Key in Table1 and Foreign
key in Table2 while inserting row in Table2 Mr Sanghi is not able to enter value in
the column City. What is the possible reason for it?
(iii) Difference between Alter and Drop
PART D
31 Write suitable SQL query for the following: 5
i. Display 7 characters extracted from 7th left character onwards from the string
‘INDIA SHINING’.
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 remainder of 100 divided by 9.
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. UCASE() ii. TRIM() iii. MID() iv. DAYNAME() v. POWER()
32 Zetking industries has set up its new center at Raipur for its office and web-based 5
activities. The company compound has 4 buildings as shown in the diagram
below:
OR
Write a python program to plot a line chart based on the given data to depict the
changing weekly average temperature in Delhi for four weeks.
Week=[1,2,3,4]
Avg_week_temp=[40,42,38,44]
PART E
34 Write SQL queries for (i) to (iv) which are based on the tables. 1+1+2
Table: ACCOUNT
(i)To display the ANO and AMOUNT of all Deposits and Withdrawals done in the
month of October 2017 from table TRANSACT.
(ii)To display the last date of transaction (DOT) from the table TRANSACT for the
Accounts having ANO as 103.
(iii)To display all ANO, ANAME and DOT of those persons from tables ACCOUNT
and TRANSACT who have done transactions less than or equal to 3000.
(iv) SELECT ANO, ANAME FROM ACCOUNT WHERE ADDRESS NOT IN ('CHENNAI',
'BANGALORE');
OR (OPTION FOR PART iii ONLY)
To display all ANO, ANAME and DOT of those persons from tables ACCOUNT and
TRANSACT who have done transactions less than or equal to 3000.
35 Assume following data is stored in data frame named as df1 1+1+2
Write following commands:
(i)Find total sales per state (ii) find total sales per employee
(iii)find total sales both employee wise and state wise
OR (OPTION FOR PART iii ONLY)
find mean, median and min sale state wise
Marking Scheme SET - 4
CLASS: XII SUB: INFORMATICS PRACTICES (Python) (065)
Max Marks: 70 TIME: 03 HOURS
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35
against part c only.
8. All programming questions are to be answered using Python Language only.
PART A
01 A network with all client computer and no server is called 1
a. Networking
b. Peer to Peer Computing
c. Client Server Computing
d. Any of them
Ans b
1 mark for correct answer
02 Which of these is not a communication channel? 1
(a) Satellite
(b) Microwave
(c) Radio wave
(d) Wi-Fi
Ans d
1 mark for correct answer
03 What is the use of Bridge in the network? 1
(a) To connect LANs (b) To separate LANs
(c) To control network speed (d) All of the above
Ans a
1 mark for correct answer
a) Count (attribute)
b) Count (*)
c) Avg
d) Sum
Ans b
1 mark for correct answer
16 Consider following SQL statement. What type of statement is this? 1
a) DML
b) DDL
c) DCL
d) Integrity constraint
Ans b
1 mark for correct answer
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): An Internet troll is a person who deliberately sows discord on the 1
Internet by starting quarrels or upsetting people.
Reason (R): We can download and use any material available on the Internet.
Ans c
1 mark for correct answer
18 Assertion (A): Data visualization refers to the graphical representation of 1
information and data using visual elements like charts, graphs and maps etc.
Reason (R): To install matplotlib library we can use the command
pip install matplotlib.
Ans B
PART B
19 What is difference between a website and a webpage? 2
Ans: Website is the complete software and webpage is just one of the pages from
the website like www.ambikapur.kvs.ac.in is website and
https://ambikapur.kvs.ac.in/admin/content?
type=school_class_wise_enrolment_posi is a single web page
1 mark for correct explanation of each term
OR
How website is not same as web portal?
Ans: Website is a single software and web portal is a combination of both online
and offline services given by the web portal. like www.google.co.in is a website
and www.ola.com is a web portal
2 marks for correct reason
20 Gopi Krishna is using a table Employee. It has the following columns: 2
Code, Name, Salary, Deptcode
He wants to display maximum salary departmentwise. He wrote the following
command:
SELECT Deptcode, 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.
Ans: SELECT Deptcode, Max(Salary)
FROM Employee
GROUP BY Deptcode;
1 Mark for error identification
1 Mark for writing correct query
21 What is the difference between group by and order by clause of MYSQL? Give an 2
example of each.
And: 01 Marks for correct difference and 01 marks for correct example
22 Write a small python codeto create a dataframewith headings (a and b) from the 2
list given below:
[[1,2],[3,4],[5,6],[7,8]]
Ans:
import pandas as pd
df = pd.DataFrame([[1, 2], [3, 4]], columns = ['a','b'])
df2 = pd.DataFrame([[5, 6], [7, 8]], columns = ['a','b'])
df = df.append(df2)
(½ mark for correct initialization, 1 mark for correct dataframe and ½ mark for
printing dataframe)
23 What is plagiarism? How can you avoid plagiarism while referring to someone’s 2
else’s creation?
Ans: 01 Marks for gender issue
01 marks for correct disability issue
OR
What is the common gender and disability issues faced while teaching / using
computers in classrooms?
Ans: 01 marks for definition of computer forensics
01 marks for explanation of important practices.
24 Write the output of following code: 2
import pandas as pd
import numpy as np
data = np.array([54,76,88,99,34])
s1 = pd.Series(data,index=['a','b','c','d','e'])
s2=s1.rename(index={'a':0,'b':1})
print(s2)
Ans:
0 54
1 76
c 88
d 99
e 34
dtype: int32
(2 marks for correct output)
25 Write one python program to find the following from the given dataframe DF: 2
Rollno Name Age Marks
11 Aruna 18 68
12 Mohini 14 47
13 Kiya 13 78
14 Lakshmi 16 87
15 Ravisha 14 60
a) Mean and mode of age of the students
b) Count the no of rows present in the dataframe
Ans:
a. print(“Mean of Age = “,DF[“Age”].mean())
print(“Mode of Age = “,DF[“Age”].mode())
b. print(“No of rows = “,DF.count())
1 mark for each correct answer
PART C
26 A Gift Gallery has different stores in India. Database Administrator Abhay wants 3
to maintain database of their Salesmen in SQL to store the data, He has decided
that
Name of the database: GiftGallery
Name of the table: Salesman
Attributes of the tables: Scode – Numeric, Sname – Character 25, Address -
Character 25, Dojoin - Date, Sales – Numeric and Area – Character 10
Consider the following records in ‘Salesman’ table and answer the given
questions:
i. The command to display the name of the salesman along with the sales amount
rounded off to one decimal point will be:
Ans: Select sname, round(sales,1) from salesman;
ii. Which of the following commands will display the details of all sales record of
North Area, regardless of case (whether North / NORTH / north):
Ans: Select * from salesman where upper(area)=’NORTH’;
iii. Help Priya to display sname and sales of east and west areas
ANS: Select sname, sales from Salesman where area=” East” or area=” West”;
1 mark for each correct output
27 Write a Pandas program to create and display a DataFrame from a specified 3
dictionary data which has the index labels.
Sample DataFrame:
exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael',
'Matthew', 'Laura', 'Kevin', 'Jonas'],
'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19],
'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Ans:
import pandas as pd
import numpy as np
df = pd.DataFrame(exam_data , index=labels)
print(df)
1 mark for Import statement
1 mark for creating dictionary
1 mark for Creating DataFrame and output
28 Consider the following dataframe 3
iii. 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
Answer : (c) Downloading
1 mark for each correct option
OR
Ms Samtha has many electronics gadgets which are not usable due to outdated
hardware and software. Help her to find any three best ways to dispose the used
electronic gadgets.
Ans:
1. Give Your Electronic Waste to a Certified E-Waste Recycler
2. Donating Your Outdated Technology
3. Give Back to Your Electronic Companies and Drop Off Points.
(1 mark for each correct ways of disposing e waste)
30 Based on table GRADUATE given here, write suitable SQL queries for the 3
following:
(a) List the names of those students who have obtained DIV I sorted by NAME.
(b) Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend
received in a year assuming that the STIPEND is paid every month.
(c) To count the number of students who are either PHYSICS or COMPUTER SC
graduates.
Ans:
(a) SELECT NAME FROM GRADUATE WHERE DIV='I’ ORDER BY NAME;
(b) SELECT NAME, STIPEND, SUBJECT, STIPEND*12 STIPEND_YEAR FROM
GRADUATE;
(c) SELECT SUBJECT, COUNT(NAME) FROM GRADUATE GROUPBY (SUBJECT)
HAVING SUBJECT='PHYSICS' OR SUBJECT='COMP. Sc.';
1 mark for each correct query
OR
(i) There is column salary in table employee. The following two statements are
giving different outputs. What may be the possible reasons?
Select count(*) from employee select count(salary) from employee
(ii) Mr. Sanghi created two tables with City as Primary Key in Table1 and Foreign
key in Table2 while inserting row in Table2 Mr Sanghi is not able to enter value in
the column City. What is the possible reason for it?
(iii) Difference between Alter and Drop
Ans:
(i) contain null values
(ii) 14 Mr Sanghi was trying to enter the name of City in Table2 which is not
present in Table1 i.e., Referential Integrity ensures that value must exist in
referred table.
(iii) alter is used to change the structure of object while update is used to update
the record in a table
1 mark for each correct Answer
PART D
31 Write suitable SQL query for the following: 5
i. Display 7 characters extracted from 7th left character onwards from the string
‘INDIA SHINING’.
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 remainder of 100 divided by 9.
v. Remove all the expected leading and trailing spaces from a column userid of
the table ‘USERS’.
Ans:
i. select mid('INDIA SHINING',7,7);
ii. select INSTR('WELCOME WORLD','COME');
iii. select round(23.78,1);
iv. select mod(100,9);
v. select trim(userid) from users;
1 mark for each correct query
OR
Explain the following SQL functions using suitable examples.
i. UCASE()
ii. TRIM()
iii. MID()
iv. DAYNAME()
v. POWER()
Ans:
1. UCASE(): It converts the string into upper case.
Example:
SELECT UCASE(‘welcome world’);
Output:
WELCOME WORLD
2. TRIM(): It removes the leading and trailing spaces from the given string.
Example:
SELECT TRIM(‘ Welcome world ‘ );
Output:
Welcome world
3. MID(): It extracts the specified number of characters from given string.
Example:
SELECT MID(‘ Welcome world,4,,4);
Output:
Come
Ans:
a. Suitable layout
b. Raj Building because of Max Number of Computers
c. Both in Raj Building
d. MAN
e. Jazz Building
1 Mark for each correct answer
33 Write a Python program to draw line charts of the financial data of Alphabet Inc. 5
between October 3, 2016 to October 7, 2016.
Sample Financial data (fdata.csv):
Date,Open,High,Low,Close
10-03-16,774.25,776.065002,769.5,772.559998
10-04-16,776.030029,778.710022,772.890015,776.429993
10-05-16,779.309998,782.070007,775.650024,776.469971
10-06-16,779,780.47998,775.539978,776.859985
10-07-16,779.659973,779.659973,770.75,775.080017
The code snippet gives the output shown in the following screenshot:
Ans:
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('fdata.csv', sep=',', parse_dates=True, index_col=0)
df.plot()
plt.show() 01 mark for each correct statement
OR
Write a python program to plot a line chart based on the given data to depict the
changing weekly average temperature in Delhi for four weeks.
Week=[1,2,3,4]
Avg_week_temp=[40,42,38,44]
Ans:
import matplotlib.pyplot as plt
Week=[1,2,3,4]
Avg_week_temp=[40,42,38,44]
plt.plot(Week,Avg_week_temp)
plt.show()
1 mark for each correct statement
PART E
34. Write SQL queries for (i) to (iv) which are based on the tables. 1+1+2
Table: ACCOUNT
(i)To display the ANO and AMOUNT of all Deposits and Withdrawals done in the month of
October 2017 from table TRANSACT.
(ii)To display the last date of transaction (DOT) from the table TRANSACT for the Accounts
having ANO as 103.
(iii)To display all ANO, ANAME and DOT of those persons from tables ACCOUNT and
TRANSACT who have done transactions less than or equal to 3000.
(iv) SELECT ANO, ANAME FROM ACCOUNT WHERE ADDRESS NOT IN ('CHENNAI',
'BANGALORE');
Ans:(i) SELECT * FROM TRANSACT WHERE TYPE = 'Deposit';
(ii) SELECT ANO,AMOUNT FROM TRANSACT WHERE DOT >= '2017-10-01' AND DOT <=
'2017-10-31'; OR
SELECT ANO,AMOUNT FROM TRANSACT WHERE DOT BETWEEN '2017-10-01' AND '2017-
10-31';
1 mark for each correct query
(iii) SELECT MAX(DOT) FROM TRANSACT WHERE ANO = 103;
OR (OPTION FOR PART iii ONLY)
To display all ANO, ANAME and DOT of those persons from tables ACCOUNT and
TRANSACT who have done transactions less than or equal to 3000.
Ans:
SELECT ACCOUNT.ANO,ANAME,DOT FROM ACCOUNT,TRANSACT WHERE
ACCOUNT.ANO=TRANSACT.ANO AND AMOUNT <=3000; OR
SELECT A.ANO,ANAME,DOT FROM ACCOUNT A,TRANSACT T WHERE A.ANO=T.ANO AND
AMOUNT <=3000;
2 marks for correct query
Assume following data is stored in data frame named as df1 1+1+2
Write following commands:
(i)Find total sales per state
(ii) find total sales per employee
(iii)find total sales both employee wise and state wise
OR (OPTION FOR PART iii ONLY)
find mean, median and min sale state wise
Ans:
(i) pv1=pd.pivot_table(dfN,index=[‘State’], values=[‘Sales’],aggfunc=np.sum)
(ii) pv1=pd.pivot_table(dfN,index=[‘Name of Employee’],
values=[‘Sales’],aggfunc=np.sum)
1 mark for each correct query
(iii) pv1=pd.pivot_table(dfN,index=[‘Name of
Employee’,’State’],values=[‘Sales’],aggfunc=np.sum) 2 marks for correct query
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
INFORMATICS PRACTICES (065)
SAMPLE QUESTION PAPER, SET -5 (2022-2023)
Class XII
Max Marks: 70 Marks Time: 3 Hrs
General Instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2 sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 4 case-based sub-parts.
An examinee is to attempt any 4 out of the 5 sub parts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two questions have internal
options.
b. Section-II is long answer questions of 3 marks each in which two questions have
internal options.
c. Section-III is very long answer questions of 5 mark each in which one question has
internal option.
PART A
Section - I
Attempt any 15 questions from questions 1 to 21
1 Which of the following is not covered under IPR? 1
(a) Music (b) Insurance (c) Logo Designed (d) Invention
2 Point out the incorrect combination with regards to kind keyword for graph plotting. 1
(a) ‘bar’ for bar plot (b) ‘hist’ for histogram
(c) ‘line’ for line plot (d) All above are correct
SELECT MOD(14,3);
6 Fill in the blanks with correct library to execute the given code. 1
import ________ as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10, 5, 7])
plt.plot(ypoints)
plt.show()
7 An_______ is a software extension that adds extra features to a program. 1
8 Rahul wants to print the row labels of the dataframe. He should use the ______ attribute of a
dataframe. 1
9 __________websites are ones that are fixed and display the same content for every user, 1
usually written exclusively in HTML.
10 Which of the network topology can be a preferred for a company that would like to keep 1
adding more and more computers to the topology economically as they grow?
11 What will be the result of the following query based on the table given here. 1
SELECT COUNT(Salary) FROM Instructor;
12 What is the maximum number of years that a patent would be valid in India? 1
13 What will be the output of the following code? 1
import pandas as pd
import numpy as np
s = pd.Series(np.random.randn(4))
print (s.ndim)
14 The networking device that forwards data packets between computer network is 1
15 Write the expansion of the following terms 1
(a) HTTP (b) URL
16 Give any two examples of e-waste. 1
17 A mail or message sent to a large number of people indiscriminately without their
consent is called ________________
18 Plagiarism is a cybercrime under Indian IT Act. (True / False) 1
19 Write the command to delete all the data of the table ‘activity’ retaining only structure. 1
20 Which networking device with similar functionality can be used to replace a hub? 1
21 Give one disadvantage of Open Source Software. 1
Section -II
Both the case study based questions (22 & 23) are compulsory. Attempt any four sub
parts from each question. Each sub question carries 1 mark.
22 Consider the following Dataframe named happy_df created using following command
happy_df=pd.read_csv("Dataset3.csv")
(i) Complete the following command to display first five rows of the above Dataframe. 1
print(happy_df.iloc[:]
(ii) Write the command to display number of rows and columns of the above Dataframe. 1
(v) Which of the following commands would display maximum value of every column? 1
(a) print(happy_df.max)
(b) print(happy_df.max())
(c) print(happy_df.max(axis=1))
(d) print(happy_df.max, axis=1)
23 Consider a table showing air quality of a city taken over period of time. The name of the table is
cityair.
Odate PM25 PM10 CO SO2
2019-03-01 114.56 104.08 0.82 12.89
2019-03-02 176.07 97.02 0.66 30.02
2019-03-03 38.85 95.51 0.6 20.68
2019-03-04 43.48 98.1 0.81 6.32
2019-03-05 53.2 95.25 0.81 17.25
2019-03-06 58.19 83.69 0.81 11.03
2019-03-07 39.87 85.68 0.78 4.02
2019-03-08 38.91 89.41 0.77 5.58
2019-03-09 36.46 115.57 0.83 5.6
(i) Which of the following command will give the latest date for which data is available in 1
the above table?
(a) SELECT MAX(ODate) FROM cityair;
(b) SELECT MIN(ODate) FROM cityair;
(c) SELECT COUNT(ODate) FROM cityair;
(ii) Which of the following commands will display ‘Mar’ for Date column? 1
(a) SELECT MONTH(ODate) FROM cityair;
(b) SELECT MONTHNAME(ODate) FROM cityair;
(c) SELECT DATE(ODate) from cityair;
(iii) What will be the output of the following query? 1
SELECT ROUND(PM25,1) FROM cityair WHERE Odate = ‘2019-03-01’
(iv) What will be the output of the following query? 1
SELECT DAY(Odate) FROM cityair WHERE SO2 <5;
(a) 7
(b) 3
(c) Empty Table
(v) Write a command to delete the data of 1st Mar 2019 in the table. 1
Part – B
Section – I
24 Write a program to create a Series having 10 random numbers in the range of 10 and 20. 2
25 What is importance of primary key in a table? How many primary keys can be there for a 2
table?
OR
Explain working of TRIM( ) function with proper examples.
26 Consider the following ‘Student’ table. 2
(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.
27 Consider the following Series ‘s’ 2
0 4.0
1 5.0
2 7.0
3 NaN
4 1.0
5 10.0
dtype: float64
(i) Write a Python code to add 1 to all the elements.
(ii) Rewrite the above code to add 1 to all the elements assuming NaN to be value 0.
5 of 8
28 Explain the working of ORDER BY clause of SELECT query with proper example. 2
6 of 8
37 Consider a MySQL table ‘product’ 3
Section -III
38 Consider the following Dataframe named housing_df. 5
7 of 8
39 Consider the below mentioned table of ‘CLOTH’ 5
DCODE DESCRIPTION PRICE MCODE LAUNCHDATE
10001 FORMAL SHIRT 1250 M001 12–JAN–08
10020 FROCK 750 M004 09–SEP–07
10012 INFORMAL SHIRT 1450 M002 06–JUN–08
10019 EVENING GOWN 850 M003 06–JUN–08
10090 TULIP SKIRT 850 M002 31–MAR–07
10023 PENCIL SKIRT 1250 M003 19–DEC–08
10089 SLACKS 850 M003 20–OCT–08
8 of 8
office?
9 of 8
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
Class XII INFORMATICS PRACTICES (065)
(2022-2023)
MARKING SCHEME-SET 5
PART A
S.No. Section - I Marks
Attempt any 15 questions from questions 1 to 21
1 Insurance 1
2 ‘line’ for line plot 1
3 4 1
1 mark for correct answer
4 1
6 matplotlib.pyplot 1
7 Add-on 1
8 Index 1
9 Static 1
10 Tree/Star 1
11 5 1
12 Surfing website / online ticket booking or any two correct activities that can leave 1
digital footprint.
13 1 1
14 Router 1
15 (a) Hyper Text Transfer Protocol (b) Uniform Resource Locator 1
16 Any two examples of e-waste. 1
17 Spam 1
18 Any two health hazards 1
10 of
19 Delete from activity; 1
20 Switch 1
21 Any one disadvantage 1
22 (i) print(happy_df.iloc[0 : 5 ] 1
(ii) print(df.shape) 1
(iii) (a) print(happy_df.Region) and (d) print(happy_df.iloc[:,1]) 1
(iv) 4 Canada 1
5 Finland
6 Netherlands
Name: Country, dtype: object
(v) (b) print(happy_df.max()) 1
23 (i) (a) SELECT MAX(ODate) FROM cityair; 1
(ii) (b) SELECT MONTHNAME(ODate) FROM cityair; 1
(iii) 114.6 1
(iv) 7 1
(v) DELETE FROM cityair WHERE Odate = “2019-03-01”; 1
24 import pandas as pd 2
import numpy as
np
arr= np.random.randint(10,20,(10,))
s = pd.Series(arr)
½ mark for correct imports.
1 mark for correct numpy array creation.
½ mark for correct creation of Series.
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;
11 of
SELECT TRIM(' bar ');
-> 'bar'
1 mark for stating purpose of the functions
1 mark for correct example.
26 (i) Gender column datatype char(1) as all the possible values can be accommodated and 2
it will be space efficient.
(ii) INSERT INTO Student (Rollno, Sname, Subject, Marks) VALUES
(“003”, ”SUMAN”, “IP”, 75);
OR
30 (i) print(sales_df.sum().loc[‘July’]) 2
(ii) sales_df.insert(4,column="August",value=[70,94,80,93] )
1 mark each for above or any other correct line(s) of code
31 1 mark each for any two correct advantages 2
12 of
32 ½ mark each for any four correct nettiquettes
33 Cyberbullying is bullying with the use of digital technologies. It can take place on 2
social media, messaging platforms, gaming platforms and mobile phones. It is repeated
behaviour, aimed at scaring, angering or shaming those who are targeted.
13 of
OR
x = emp_df['Name']
y = emp_df['Salary']
pl.bar(x,y)
pl.xlabel("Name")
pl.ylabel("Salary")
pl.title("Name vs Salary")
pl.show()
print(housing_df[housing_df.loc[:,'bath']==2]) # 1Mark
print(housing_df.loc[:,'price']*100000) # 1 Mark
print(housing_df.head(3)) # 1 Mark
Give marks for any alternate method or the task done in multiple steps.
14 of
39
(i) SELECT LEFT(DESCRIPTION,3) FROM CLOTH; 5
(ii) SELECT LTRIM(DESCRIPTION) FROM CLOTH;
(iii) SELECT LEN(DESCRIPTION) FROM CLOTH;
(iv) SELECT COUNT(DISTINCT MCODE) FROM CLOTH;
(v) SELECT DAYNAME(LAUNCHDATE) FROM CLOTH;
OR
(i) SELECT SUM(PRICE) FROM CLOTH WHERE YEAR(LAUNCHDATE) = 2008;
(ii) SELECT MIN(PRICE) FROM CLOTH GROUP BY MCODE;
(iii) SELECT MAX(LAUNCHDATE) FROM CLOTH;
(iv) SELECT LOWER(DESCRIPTION) FROM CLOTH;
(v) SELECT MOD(PRICE,10) FROM CLOTH;
1 mark each for correct query. Any alternate method also should be given due credit.
40 (i) Block C would be the most suitable place to house server as it has maximum 5
number of computers.
(ii) The most suitable layout would be
A B
C D
Topology : Star/Tree
(iii) Modem should be placed where the server is therefore it should be placed at Block C.
Dynamic website as the dynamic website can alter based on customer’s choice.
(iv) WAN as the distance between the two locations would be more than 100KM
1 mark for correct answer.