Question Bank Class XII IP 065 Long Question Answer
Question Bank Class XII IP 065 Long Question Answer
Session : 2023-24
Class –XII
Subject- Informatics Practices (065)
Answer.
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)
Q.2. Write a program in Python Pandas to create the following DataFrame batsman
from a Dictionary:
B_NO Name Score1 Score2
1 Sunil Pillai 90 80
2 Gaurav Sharma 65 45
3 Piyush Goel 70 90
4 Kartik Thakur 80 76
Perform the following operations on the DataFrame :
1)Add both the scores of a batsman and assign to column “Total”
2)Display the highest score in both Score1 and Score2 of the DataFrame.
Answer.
import pandas as pd
d1={'B_NO':[1,2,3,4],
'Name':["Sunil Pillai","Gaurav Sharma","Piyush Goel","Kartik
Thakur"],'Score1':[90,65,70,80], 'Score2':[80,45,95,76]
}
df=pd.DataFrame(d1)
print(df)
df['Total'] = df['Score1']+ df['Score2']
Q.3. Write Python code to plot a bar chart for India’s medal tally as shown below:
Answer.
Q.4. 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.
Answer.
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()
Q.5. 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:
Answer.
A. Output:
i. (5,4)
Q.6. Ekam, a Data Analyst with a multinational brand has designed the DataFrame df that
contains the four quarter’s sales data of different stores as shown below:
Answer.
i. a. 15
b. Store Qtr1 Qtr2 Qtr3 Qtr4
1 Store2 350 340 403 210
2 Store3 250 180 145 160
ii. df=df.drop(2)
OR
df.drop(2,axis=0)
iii. df["total"]=df["Qtr1"]+df["Qtr2"]+df["Qtr3"]+df["Qtr4"]
OR
df.to_csv(“D:\data.csv”)
(1 mark for each correct output/statement)
Answer.
import matplotlib.pyplot as plt #Statement 1
Height_cms=[145,141,142,142,143,143,141,140,143,144]
#Statement 2
plt.hist(Height_cms) #Statement 3
plt.title("Height Chart") #Statement 4
plt.xlabel("Height in cms") #Statement 5
plt.ylabel("Number of people") #Statement 6
plt.show() #Statement 7
(½ mark each for each correct statement 1,2,4,5,6,7)
(1 mark for correct statement 3)
plt.savefig("heights.jpg")
Q.8. Write suitable Python code to create 'Favourite Hobby' Bar Chart as shown below:
Answer.
import matplotlib.pyplot as plt #Statement 1
hobby = ('Dance', 'Music', 'Painting', 'Playing Sports')
#Statement 2
users = [300,400,100,500] #Statement 3
plt.bar(hobby, users) #Statement 4
plt.title("Favourite Hobby") #Statement 5
plt.ylabel("Number of people") #Statement 6
plt.xlabel("Hobbies") #Statement 7
plt.show() #Statement 8
(½ mark for each correct statement)
plt.savefig("hobbies.jpg")
(1 mark for the correct statement)
Q.9. Write Python code to plot a bar chart to depict the programming language usage as shown below:
Answer.
import numpy as np
import matplotlib.pyplot as plt
Q.10. Write a program to plot a bar chart to depict the changing weekly onion prices for four weeks.
Write appropriate code to provide axes labels and save the plot.
week=[1,2,3,4]
prices=[40,50,100,97]
Answer.
import matplotlib.pyplot as plt
week=[1,2,3,4]
prices=[40,50,100,97]
plt.bar(week,prices,label='Weeks',color=['red','blue','orange','yell
ow'])
plt.title("Onion prices in four weeks")
plt.xlabel("weeks")
plt.ylabel('Price')
plt.xticks([1,2,3,4])
plt.show()
Q.11. Pratigya, a data analyst, has designed the dataframe df that contains data about Employees with
‘EO1’, ‘EO2’, ‘EO3’, ‘EO4’, ‘EO5’ as indexes shown below. Answer the following questions:
Answer.
(a) (i) Index(['Name', 'Gender', 'Designation', 'City',’Salary’+, dtype='object')
(ii) E02 Geet M Programmer Mumbai 80000
E03 Rahul M IT Officer Ahmedabad 86000
E04 Rijul M Analyst Lucknow 55000
(b) df.loc['E01':'E03','Designation']
Or
df[„Salary‟] or df.Salary
Answer.
mysql> Select Name,SalesAmt from Store order by noOfEmp;
mysql> Select city, sum(SalesAmt) from store group by City;
mysql> Select count(*),City from store group by City having
count(*)>2;
mysql> Select Min(DateOpen) from Store;
+---------------+
| Min(DateOpen) |
+---------------+
| 2015-02-06 |
+---------------+
mysql> Select Count(StoreId), NoOfEmp from Store group by
NoOfemp having max(SalesAmt)<60000;
+----------------+---------+
| Count(StoreId) | NoOfEmp |
+----------------+---------+
| 1 | 10 |
| 1 | 11 |
|1|5|
|1|7|
+----------------+---------+
(ii) Write the code in python to read the contents of “number.csv” file
consisting of data from a mysql table and print the data of the table on the
screen in tabular form of the table.
Answer.
i)import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="cbse",
database="school"
)
mycursor = mydb.cursor()
mycursor.execute("INSERT INTO student values(3,'Michelle',
'Agartala');")
mydb.commit()
Q.3. Write the SQL functions which will perform the following operations:
i) To display the name of the month of the current date .
ii) To remove spaces from the beginning and end of a string, “ Panorama “.
iii) To display the name of the day eg, Friday or Sunday from your date of birth, dob.
iv) To display the starting position of your first name(fname) from your whole name
(name).
v) To compute the remainder of division between two numbers, n1 and n2
Answer.
i) monthname(date(now()))
ii) trim(“ Panaroma “)
iii) dayname(date(dob))
iv)instr(name, fname)
v) mod(n1,n2)
Write SQL queries using SQL functions to perform the following operations:
a) Display salesman name and bonus after rounding off to zero decimal places.
b) Display the position of occurrence of the string “ta” in salesman names.
c) Display the four characters from salesman name starting from second character.
d) Display the month name for the date of join of salesman
e) Display the name of the weekday for the date of join of salesman
Ans.
i) Select sname, round(bonus,0) from Salesman;
ii) Select instr(Sname, “ta”) from Salesman;
iii) Select mid(Sname,2,4) from Salesman;
alternative answer
iii) Select Substring(Sname,2,4) from Salesman;
iv) Select monthname(DateofJoin) from Salesman;
v) Select dayname(DateofJoin) from Salesman;
Q.5.
Carefully observe the following table named ‘stock’:
Table: stock
Pid PName Category Qty Price
1 Keyboard IO 15 450
2 Mouse IO 10 350
3 Wifi-router NW 5 2600
4 Switch NW 3 3000
5 Monitor O 10 4500
6 Printer O 4 17000
Write SQL queries for the following:
(a) To display the records in decreasing order of price.
(b) To display category and category wise total quantities of products.
(c) To display the category and its average price.
(d) To display category and category wise highest price of the products.
Answer.
(a) select * from stock order by price desc;
(b) select category, sum(qty) from stock group by category;
(c) select category,avg(price) from stock group by category;
(d) select category, max(price) from stock group by category;
Answer.
(a) 193
(b) 194
(c) 93.75
(d) 6
Q.7. Based on the above given table named ‘Student’, Satyam has executed following
queries:
Select count(*) from student;
Select count(MARKS) from student;
Predict the output of the above given queries.
Also give proper justifications of the output generated through each query.
Answer.
First query will produce the output 7.
Justification: count (*) will count and display total number of rows (irrespective of any null
value present in any of the column).
Second query will produce the output 6.
Justification: count (col_name) will count and display total number of not null values in the
specified column.
Answer.
i. select mid('INDIA SHINING',7,7);
ii. select INSTR('WELCOME WORLD','COME');
iii. select round(23.78,1);
Answer.
1. UCASE(): It converts the string into upper case.
Example:
SELECT UCASE(‘welcome world’);
Output:
WELCOME WORLD
2. TRIM(): It removes the leading and trailing spaces from the given string.
Example:
SELECT TRIM(‘ Welcome world ‘ );
Output:
Welcome world
3. MID(): It extracts the specified number of characters from given string.
Example:
SELECT MID(‘ Welcome world,4,,4);
Output:
Come
4. DAYNAME(): It returns the weekday name for a given date
Example:
SELECT DAYNAME(‘2022-07-22’);
Output:
Friday
5. POWER(): It returns the value of a number raised to the power of another number.
Example:
SELECT POW(6,2);
Output:
36
Q.10. 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
Answer.
i. SELECT LOWER(CNAME) FROM CLOTH;
ii. SELECT MIN(PRICE) FROM CLOTH;
Q.11. Preeti manages database in a blockchain start-up. For business purposes, she created a
table named BLOCKCHAIN. Assist her by writing the following queries:
TABLE: BLOCKCHAIN
Answer.
i. SELECT YEAR(MIN(TRANSACTION_DATE)) FROM BLOCKCHAIN;
ii. SELECT MONTH(MAX(TRANSACTION_DATE)) FROM BLOCKCHAIN;
iii. SELECT * FROM BLOCKCHAIN WHERE MONTHNAME
(TRANSACTION_DATE)='MAY';
iv. SELECT COUNT(ID) FROM BLOCKCHAIN WHERE
YEAR(TRANSACTION_DATE)=2022;
(1 mark for each correct query)
Answer.
i. SELECT POWER(3,4);
Answer.
Q.14. Write the SQL commands which will perform the following operations?
a. To display the starting position of your last name (lname) from the whole name
(name).
b. To display dayname, month name and year from today‟s date.
c. To display the remainder on dividing 3 raised to power 5 by 5.
d. To display „I am here‟ in lower as well as uppercase.
Answer.
select instr(name,lname)
select dayname(now()),monthname(now()),year(now());
Answer.
Select scod, round(Sales,1) from Salesman
Select dayname(Dojoin) from Salesman
Select instr(Sname,”a”) from Salesman
Select substr(Sname,2,3) from Salesman where name like “%t”
Q.16. Write the SQL commands which will perform the following operations?
a. To display the position of space character in your name (myname).
b. To display day, month and year from today‟s date.
c. To compute 5 raised to the power remainder on dividing 15 by 4.
d. To display the leftmost as well as the rightmost character of the string „PYTHON‟.
Answer.
select instr(myname,‟ „)
select day(now()),month(now()),year(now());
select pow(5,mod(15,4));
select left('PYTHON',1),right('PYTHON',1);
Answer.
select area,max(sales) from Salesman group by area
select monthname(dojoin) from salesman
select(Address) from salesman where Address like „%i%‟
select left(Sname,2) from Salesman where Address=”Delhi”
Q.18. Write the SQL functions which will perform the following operations:
i) To display the name of the month of the current date .
ii) To remove spaces from the beginning and end of a string, “ Panorama “.
iii) To display the name of the day eg, Friday or Sunday from your date of birth, dob.
iv) To display the starting position of your first name(fname) from your whole name
(name).
Answer.
i) monthname(date(now()))
ii) trim(“ Panaroma “)
iii) dayname(date(dob))
iv)instr(name, fname)
Write SQL queries using SQL functions to perform the following operations:
a) Display company name and body wheel base after rounding off to nearest ten’s
decimalplaces.
b) Display the position of occurrence of the string “dan” in body style.
c) Display the 3 characters from company name starting from second character.
d) Display the year of manufacturing for sedan;
Answer.
a) Select company, round(wheel-base,-1) from automobile;
b) Select instr(body-style,’dan’) from automobile;
c) Select substr(company,2,3) from automobile; /mid(company,2,3)
d) Select year(dateofmanufacture) from automobile where body-style=’sedan’;
Q.20. Write the SQL functions which will perform the following operations:
Answer.
i)select monthname(‘1998-11-20’);
ii)select ltrim(‘ Python’);
iii)select dayname(now());
iv)select left(‘Nitin’,3);
v)Select power(2,3);
Answer.
i) Most suitable layout according to distance is :
Q.2. “Anutulya Creations”-A start-up fashion house has set up its main centre at Kanpur,
Uttar Pradesh for its dress designing, production and dress supplying activities. It has 4
blocks of buildings.
Distance between the various blocks is as follows:
A to D 50 m
A to P 60 m
A to S 110m
D to S 60m
P to S 50m
P to D 150m
Numbers of computers in each block
Block A - 20
Block D - 80
Block P - 15
Block S - 8
Answer.
(a) LAN
As computers are placed with-in the same campus with-in a small range.
½ Mark for correct answer
½ Mark for correct justification
(b) Star topology
Answer.
(i) Server should be installed in Admin department as it has maximum number of
computers
(ii)
Q.4. XYZ Media house campus is in Delhi and has 4 blocks named Z1, Z2, Z3 and Z4. The
tables given below show the distance between different blocks and the number of computers
in each block.
Answer.
iii. Repeater: To be placed between Block Z2 to Z4 as distance between them is more than
100 metres.
Hub/Switch: To be placed in each block as each block has many computers that needs to be
included to form a network.
iv. Voice Over Internet Protocol
v. WAN as distance between Delhi and Mumbai is more than 40kms.
(1 mark for each correct answer)
Q.5. Shop Biz Ltd. is an international educational organization. It is planning to set up its India
campus in Bengaluru with its head office in Delhi. The Bengaluru campus has four main buildings—
ADMIN, ENGINEERING, BUSINESS and MEDIA.
You, as a network expert, have to suggest the best network-related solutions for the
problems raised in (a) to (e), keeping in mind the distances between the buildings and
other given parameters.
Shortest distance between various buildings:
Answer.
(a) ADMIN (due to a maximum number of computers) or MEDIA (due to shorter distance from other
buildings).
(b) The cable layout for connecting computers in the Bengaluru campus:
Q.6. Perfect Edu. Services Ltd. is an educational organization. It is planning to set up its India campus
at Chennai
with its head office in Delhi. The Chennai campus has four main buildings—ADMIN, ENGINEERING,
BUSINESS and MEDIA. 4
You, as a network expert, have to suggest the best network-related solutions for their problems
raised in
(a) to (d), keeping in mind the distances between the buildings and other given parameters.
Answer.
(a) ADMIN (due to maximum number of computers) or MEDIA (due to shorter distance from other
buildings)
(b) The suitable cable layout is:
Q.7. 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 given
below:
Answer.
(a) The cable layout of connection between the blocks is:
(b) HR Centre because it consists of the maximum number of computers to house the server.
(c) Switch should be placed in each of these blocks.
(d) MAN will be formed as Sales counters are in the same city.
Q.8. Indian School, in Mumbai is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL. The
distance between various buildings is as follows:
Server can be placed in the ADMIN building as it has the maxium number of computer.
Repeater can be placed between ADMIN and SENIOR building as the distance is more
than 110 m.
Also, hub/switch to be used in each building.
Radiowaves can be used in hilly regions as they can travel through obstacles.
Block Computers
Human Resource 25
Finance 120
Conference 90
a. What will be the most appropriate block, where TTC should plan to install their server?
b. Draw a block to cable layout to connect all the buildings in the most appropriate
manner for efficient communication.
c. What will be the best possible connectivity out of the following, you will suggest to
connect the new setup of offices in Bangalore with its London based office: Satellite
Link, Infrared, Ethernet Cable
d. Which of the following device will be suggested by you to connect each computer in
each of the buildings: Switch, Modem, Gateway
Answer.
Finance block because it has the maximum number of computers.
Q.10. ABC is an online corporate training provider company for IT related courses. The
company is setting up their new campus in Kolkata. You as a network expert have to
study the physical locations of various blocks and the number of computers to be
installed. In the planning phase, provide the best possible answers for the queries (i) to
(iv) raised by them.
Block Computers
Administrative 20
Finance 40
Faculty studio 120
a. Suggest the most appropriate block, where ABC 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? LAN, MAN, WAN
d. Which wireless channel out of the following should be opted by ABC to connect to
students from all over the world? Infrared, Microwave, Satellite.
Answer.
Faculty studio
Star topology
LAN
Satellite Connection
B3 TO B1 40 M
B1 TO B2 50 M
B2 TO B4 15 M
B4 TO B3 150 M
B3 TO B2 115 M
B1 TO B4 90 M
B1 140
B2 20
B3 18
B4 30
Computers in each block are networked but blocks are not networked. The company has
now decided to connect the blocks also
a. Suggest the most appropriate topology for the connections between the blocks.
b. The company wants internet accessibility in all the blocks. The suitable and cost-
effective technology for that would be ___.
c. Which device will you suggest for connecting all the computers within each of their
blocks?
d. The company is planning to link its head office situated in New Delhi with the offices in
hilly areas. Suggest a way to connect it economically:
Answer.
Star topology
Broadband
Switch/Hub
Radio waves
Q.12. The Virtual Connects organization has set up its new centre at Noida for its office
and web-
based activities. It has 4 blocks of buildings as shown in the diagram below:
Answer.
(i) The most suitable place to install the server is Block C as this place has maximum
number of
computers.
(ii)Switch
(iii) Repeater may be placed when the distance between 2 buildings is more than 70
metres, i.e.,
Block B to Block C
Block A to Block D
Block B to Block D
(iv) Radio waves, because these waves are easy to generate, can travel long distances
and can
penetrate mountains easily.
Societal Impacts
Q.1. Match the following:
Column A Column B
Answer.
Answer. It is very important to have a clean and secure digital footprint because:-
We can avoid plagiarism while referring to someone's else's creation by giving credit
whenever we use
• Another person's idea, opinion, or theory.
• Quotations of another person's actual spoken or written words.
• Paraphrase of another person's spoken or written words
• Anti-Temper Solutions: - There are many anti-tamper solution available today which
ensure that your digital property is tamper-proof. These anti-temper solutions use a host
of advanced technologies to prevent hackers from hacking, reverse-engineering or
manipulating your digital properties such as utility tools, software, apps, video games
and so forth.
• Legal Clauses: - Add legal clause in the clauses of use of your software/digital
properties. You must include a transparent clause in your software's Terms of Service
that prohibits the scraping of your software's source code for reuse. This is a sound legal
backup for you.
• Limit the sharing of software code: - You should share your software code only with
trusted individuals who are part of development team. You should also use a Digital
Rights Management (DRM) solution to protect your software from being scraped for
source code using decompilers etc.
(i) GNU General Public License (GPL):- The GNU General Public License (GPL) is
probably one of the most commonly used licenses for open-source projects. The GPL
grants and guarantees a wide range of rights to developers who work on open-source
projects. Basically, it allows users to legally copy, distribute and modify software.
(ii) GNU Lesser General Public License (LGPL):- It offers lesser rights to a work than the
standard GPL license. The LGPL is used to license free software so that it can be
incorporated into both free software and proprietary software. The LGPL and GPL
licenses differ with one major exception; with LGPL the requirement that you have to
release software extensions in open GPL has been removed.
Mostly, LGPL is used by libraries. LGPL is also called GNU libraries and formally called
the Library GPL.
(iii) BSD License: - BSD licenses represent a family of permissive free software licenses
that have fewer restrictions on distribution compared to other free software licenses such
as the GNU General Public License.
(iv) MIT License: - The MIT License is the shortest and probably broadest of all the
popular open-source licenses. Its terms are very loose and more permissive than most
other licenses.
(v) Apache License: - The Apache License, grants a number of rights to users. These
rights can be applied to both copyrights and patents.
1. Impact on Hearing: - Studies have proven that listening to music that loud for more
than 15 minutes cause hearing damage over time. Also, it has been said that using
headphones increases the bacteria levels in your ears over 700 times when used for
more than an hour. This shocking statistic came from a study way back in 1992 when
experts measured bacteria on 20 headsets.
2. Impact on Bones and Joints: - Use of technology has affected our postures. Most of
the times, we sit in the same postures and make similar, repetitive movements, e.g.,
thumb movements on mobile phones. Slouching, or using your joints and muscles in
repetitive movements all cause strain on our muscles and joints. A Repetitive Strain
Injury (RSI) is an injury or disorder of the muscles, nerves, tendons, ligaments and joints.
3. Eye Problems: - Constant exposure to smart phone, laptops and computer screens
impacts our vision and may lead to other eye related problems. The blue light that
comes from our phones and computers is very damaging on the retina, even more than
UV light; this may even lead to vision loss. Computer Vision Syndrome (CVS) is a
technology related health condition affecting eyesight.
4. Sleep Issues: - Excessive smartphone, computer and tablet use can disrupt our sleep.
Bright lights from these devices block melatonin secretion, the hormone that regulates
sleep and this leads to smaller sleep cycles and disrupted sleep. Sleep is so essential
for overall health that it impacts our normal thinking and behavioral patterns, memory
and attention span.
5. Mental Health Issues: - Excessive use of technology leads to isolation as people don't
get time to physically socialize. It sometimes also leads to anxiety and depression as by
looking at picture perfect social media profile of others, people often tend to think that
their "connections" have "perfect rosy lives" while they are not.
Excessive use of technology and Internet leads to addiction. People keep obsessively
looking through emails and messages. They start feeling stress if they don't get some
likes or replies on their posts etc. This problem is formally termed as Internet addiction
disorder.
Answer.
(i) Free software: - Software available free of cost and also can be copied and
redistributed but no source code is available.
Open source software: - Software whose source code is available and which can be
modified, copied and redistributed.
(ii) Open source software: - Software whose source code is available and which can be
modified, copied and redistributed.
FLOSS: - Free Libre and Open Source Software or to Free Livre and Open Source
Software. The term FLOSS is used to refer to a software which is both free software as
well as open source software. Here the words libre (a Spanish word) and livre (a
Portuguese word) mean freedom.
(iii) Proprietary software: - Proprietary software is the software that is neither open nor
freely available. Its use is regulated and further distribution and modification is either
forbidden or requires special permission by the supplier or vendor. Source code of
proprietary software is normally not available.
Free software: - Software available free of cost and also can be copied and redistributed
but no source code is available.
(iv) Freeware: - The term freeware is generally used for software, which is available free
of cost and which allows copying and further distribution, but not modification and whose
source code is not available. Freeware should not be mistaken for open software or for
free software. Freeware is distributed in binary form (ready to run) without any licensing
fee. In some instances the right to use the software is limited to certain types of users,
for instance, for private and non-commercial purposes. One example is Microsoft
Internet Explorer, which is made available as freeware.
(v) Freeware: - The term freeware is generally used for software, which is available free
of cost and which allows copying and further distribution, but not modification and whose
source code is not available. Freeware should not be mistaken for open software or for
free software. Freeware is distributed in binary form (ready to run) without any licensing
fee. In some instances the right to use the software is limited to certain types of users,
Free software: - Software available free of cost and also can be copied and redistributed
but no source code is available.