26. Write outputs for SQL queries (i) to (iii) which are based on the given table PURCHASE:
TABLE: PURCHASE
| CNO |
CNAME |
CITY |
QUANTITY |
DOP |
| C01 |
GURPREET |
NEW DELHI |
150 |
2022-06-11 |
| C02 |
MALIKA |
HYDERABAD |
10 |
2022-02-19 |
| C03 |
NADAR |
DALHOUSIE |
100 |
2021-12-04 |
| C04 |
SAHIB |
CHANDIGARH |
50 |
2021-10-10 |
| C05 |
MEHAK |
CHANDIGARH |
15 |
2021-10-20 |
i. SELECT LENGTH(CNAME) FROM PURCHASE WHERE QUANTITY>100;
Ans: 8
ii. SELECT CNAME FROM PURCHASE WHERE MONTH(DOP)=3;
Ans: No Output
iii. SELECT MOD (QUANTITY, DAY(DOP)) FROM PURCHASE WHERE CITY= ‘CHANDIGARH’;
Ans:
0
15
27. Write a Python code to create a DataFrame with appropriate column headings from the list given below:
[[101,'Gurman',98],[102,'Rajveer',95],[103,'Samar' ,96],[104,'Yuvraj',88]]
Ans:
import pandas as pd
data=[[101,'Gurman',98],[102,'Rajveer',95],[103,'Samar' ,96],[104,'Yuvraj',88]]
df=pd.DataFrame(data,columns=['Rno','Name', 'Marks'])
28. Consider the given DataFrame ‘Stock’:
| Index |
Name |
Price |
| 0 |
Nancy Drew |
150 |
| 1 |
Hardy boys |
180 |
| 2 |
Diary of a wimpy kid |
225 |
| 3 |
Harry Potter |
500 |
Write suitable Python statements for the following:
i. Add a column called Special_Price with the following data: [135,150,200,440].
Ans: Stock['Special_Price']=[135,150,200,400]
ii. Add a new book named ‘The Secret' having price 800.
Ans: Stock.loc['4']=['The Secret',800]
iii. Remove the column Special_Price.
Ans: Stock=Stock.drop('Special_Price',axis=1)
29. Nadar has recently shifted to a new city and school. She does not know many people in her new city and school. But all of a sudden, someone is posting negative, demeaning comments on her social networking profile etc.
She is also getting repeated mails from unknown people. Every time she goes online, she finds someone chasing her online.
i. What is this happening to Nadar?
Ans: Nadar has become a victim of cyber bullying and cyber stalking.
ii. What immediate action should she take to handle it?
Ans: She must immediately bring it into the notice of her parents and school authorities. And she must report this cyber crime to local police with the help of her parents.
iii. Is there any law in India to handle such issues? Discuss briefly.
Ans: Yes.
The Information Technology Act, 2000 (also known as ITA-2000, or the IT Act) is the primary law in India dealing with cybercrime and electronic commerce.
OR
What do you understand by plagiarism? Why is it a punishable offence? Mention any two ways to avoid plagiarism.
Ans: Plagiarism is the act of using or stealing someone else’s intellectual work, ideas etc. and passing it as your own work. In other words, plagiarism is a failure in giving credit to its source.
Plagiarism is a fraud and violation of Intellectual Property Rights. Since IPR holds a legal entity status, violating its owners right is a legally punishable offence.
Any two ways to avoid plagiarism:
(i) Be original
(ii) Cite/acknowledge the source
30. Based on table STUDENT given here, write suitable SQL queries for the following:
| Roll No |
Name |
Class |
Gender |
City |
Marks |
| 1 |
Abhishek |
XI |
M |
Agra |
430 |
| 2 |
Prateek |
XII |
M |
Mumbai |
440 |
| 3 |
Sneha |
XI |
F |
Agra |
470 |
| 4 |
Nancy |
XII |
F |
Mumbai |
492 |
| 5 |
Himnashu |
XII |
M |
Delhi |
360 |
| 6 |
Anchal |
XI |
F |
Dubai |
256 |
| 7 |
Mehar |
X |
F |
Moscow |
324 |
| 8 |
Nishant |
X |
M |
Moscow |
429 |
i. Display gender wise highest marks.
Ans: SELECT MAX(marks)
FROM student
GROUP BY gender;
ii. Display city wise lowest marks.
Ans: SELECT MIN(marks)
FROM student
GROUP BY city;
iii. Display total number of male and female students.
Ans: SELECT gender, COUNT(gender)
FROM student
GROUP BY gender;
OR
Discuss the significance of Group by clause in detail with the help of suitable example.
SECTION D
31. Write suitable SQL query for the following:
i. Display 7 characters extracted from 7th left character onwards from the string ‘INDIA SHINING’.
Ans: SELECT MID('INDIA SHINING', 7, 7);
ii. Display the position of occurrence of string ‘COME’ in the string ‘WELCOME WORLD’.
Ans: SELECT INSTR('WELCOME WORLD', 'COME');
iii. Round off the value 23.78 to one decimal place.
Ans: SELECT ROUND(23.78, 1);
iv. Display the remainder of 100 divided by 9.
Ans: SELECT MOD(100, 9);
v. Remove all the expected leading and trailing spaces from a column userid of the table ‘USERS’.
Ans: SELECT TRIM(userid) FROM users;
OR
Explain the following SQL functions using suitable examples.
i. UCASE() - It converts the string into upper case.
Example:
SELECT UCASE ('welcome world');
Output:
WELCOME WORLD
ii. TRIM() - It removes the leading and trailing spaces from the given string.
Example:
SELECT TRIM ('Welcome world');
Output:
Welcome world
iii. MID() - It extracts the specified number of characters from given string.
Example:
SELECT MID ('Welcome world,4,,4);
Output:
Come
iv. DAYNAME() - DAYNAME(): It returns the weekday name for a given date
Example:
SELECT DAYNAME ('2022-07-22');
Output:
Friday
v. POWER() - It returns the value of a number raised to the power of another number.
Example:
SELECT POW (6,2);
Output:
36
32. Prime 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 - 55 m
ADMIN TO EXAMINATION - 90 m
ADMIN TO RESULT - 50 m
ACCOUNTS TO EXAMINATION - 55 m
ACCOUNTS TO RESULT - 50 m
EXAMINATION TO RESULT - 45 m
DELHI Head Office to MUMBAI campus - 2150 m
Number of computers installed at various buildings are as follows:
ADMIN - 110
ACCOUNTS - 75
EXAMINATION - 40
RESULT - 12
DELHI HEAD OFFICE - 20
(i) Suggest the most appropriate location of the server inside the MUMBAI campus (out of the four buildings) to get the best connectivity for maximum number of computers. Justify your answer.
Ans: Server should be installed in Admin department as it has maximum number of computers.
(ii) Suggest and draw cable layout to efficiently connect various buildings within the MUMBAI campus for a wired connectivity.
Ans: Star topology
(iii) Which networking device will you suggest to be procured by the company to interconnect all the computers of various buildings of MUMBAI campus?
Ans: Hub / Switch
(iv) Company is planning to get its website designed which will allow students to see their results after registering themselves on its server. Out of the static or dynamic, which type of website will you suggest?
Ans: Dynamic
(v) Which of the following will you suggest to establish the online face to face communication between the people in the ADMIN office of Mumbai campus and Delhi head office?
a) Cable TV
b) Email
c) Video conferencing
d) Text chat
33. Write Python code to plot a bar chart for India’s medal tally as shown below:

Also give suitable python statement to save this chart.
Ans:
import matplotlib.pyplot as plt
Category=['Gold','Silver','Bronze']
Medal=[20,15,18]
plt.bar(Category,Medal)
plt.ylabel('Medal')
plt.xlabel('Medal Type')
plt.title('Indian Medal tally in Olympics')
plt.show()
Python statement to save the chart:
plt.savefig("aa.jpg")
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()
SECTION E
34. Shreya, a database administrator has designed a database for a clothing shop. Help her by writing answers of the following questions based on the given table:
TABLE: CLOTH
| CCODE |
CNAME |
SIZE |
COLOR |
PRICE |
DOP |
| C001 |
JEANS |
XL |
BLUE |
990 |
2022-01-21 |
| C002 |
T SHIRT |
M |
RED |
599 |
2021-12-12 |
| C003 |
TROUSER |
M |
GREY |
399 |
2021-11-10 |
| C004 |
SAREE |
FREE |
GREEN |
1299 |
2019-11-12 |
| C005 |
KURTI |
L |
WHITE |
399 |
2021-12-07 |
i. Write a query to display cloth names in lower case.
Ans: SELECT LOWER(CNAME) From CLOTH;
ii. Write a query to display the lowest price of the cloths.
Ans: SELECT MIN(PRICE) From CLOTH;
iii. Write a query to count total number of cloths purchased of medium size.
Ans: SELECT COUNT(*) From CLOTH Group By SIZE Having SIZE='M';
OR (Option for part iii only)
Write a query to count year wise total number of cloths purchased.
Ans: SELECT YEAR(DOP),COUNT(*) From CLOTH Group By YEAR(DOP);
35. Mr. Som, a data analyst has designed the DataFrame df that contains data about Computer Olympiad with ‘CO1’, ‘CO2’, ‘CO3’, ‘CO4’, ‘CO5’ as indexes shown below. Answer the following questions:
|
School |
Tot_students |
Topper |
First_Runnerup |
| C01 |
PPS |
40 |
32 |
8 |
| C02 |
JPS |
30 |
18 |
12 |
| C03 |
GPS |
20 |
18 |
2 |
| C04 |
MPS |
18 |
10 |
8 |
| C05 |
BPS |
28 |
20 |
8 |
A. Predict the output of the following python statement:
i. df.shape
Ans: (5,4)
ii. df[2:4]
Ans:
|
School |
tot_students |
Topper |
First_Runner_up |
| CO3 |
GPS |
20 |
18 |
2 |
| CO4 |
MPS |
18 |
10 |
8 |
B. Write Python statement to display the data of Topper column of indexes CO2 to CO4.
Ans: Python statement:
print(df.loc['CO2': 'CO4', 'Topper'])
OR (Option for part iii only)
Write Python statement to compute and display the difference of data of Tot_students column and First_Runnerup column of the above given DataFrame.
Ans: print(df.Tot_students-df.First_Runnerup)