IP Book 12 Question Bank
IP Book 12 Question Bank
Ques�on Bank
Chapter 1: Python Pandas
3. Write a Python code to create a Series with the following data: [10, 20, 30, 40, 50].
Ans.
import pandas as pd
s = pd.Series([10, 20, 30, 40, 50])
4. Write a Python code to retrieve the first element of the Series created in ques�on 3.
Ans. print(s[0])
Ans.
import pandas as pd
data = {'Name': ['John', 'Mary', 'Tom'],
'Age': [25, 30, 35],
'Gender': ['Male', 'Female', 'Male']}
df = pd.DataFrame(data)
7. Write a Python code to retrieve the third row of the DataFrame created in ques�on 6.
Ans.
print(df.iloc[2])
8. Write a Python code to retrieve the Age column of the DataFrame created in ques�on 6.
Ans.
print(df['Age'])
9. Write a Python code to add a new column called "Salary" to the DataFrame created in ques�on
6.
Ans.
salary = [50000, 60000, 70000]
df['Salary'] = salary
print(df)
10. Write a Python code to sort the DataFrame created in ques�on 6 by Age in ascending order.
Ans.
df = df.sort_values(by='Age')
print(df)
1. Write a program to read data from a CSV file where separator character is '@'. Perform the
following:
a) The top row is used as data, not as column headers.
b) Only 20 rows are read into dataframe.
Ans.
import pandas as pd
df = pd.read_csv("D:\\PythonProg\\Class12IP\\one.csv", header=None, sep='@')
print(df)
2. Write a program to read from CSV file Employee.csv and create a dataframe from it, Also set the
column Empno as index label:
Ans.
import pandas as pd
D5 = pd.read_csv("E:\csv \\Employee.csv")
D5 = pd.read_csv("E:\csv\\Employee.csv", index_col= 'Empno')
Print(D5)
4. Create a line plot using the following data: x = [1, 2, 3, 4, 5] y = [10, 8, 6, 4, 2].
Ans.
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [10, 8, 6, 4, 2]
plt.plot(x, y)
plt.�tle("Line Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()
Runs in Overs 10 20
MI 110 224
RCB 85 210
Ans.
import matplotlib.pyplot as mpp
overs = [10,20]
mi = [110,224]
mpp.plot(overs,mi,'blue')
rcb=[109,210]
mpp.plot(overs,rcb,'red')
mpp.xlabel('Runs')
mpp.ylabel('Overs')
mpp.�tle('Match Summary')
mpp.show()
6. Write code to plot a line chart to depict the run rate of T20 match from given data:
Overs Runs
5 45
10 79
15 145
20 234
Ans.
import matplotlib as pp
overs = [5,10,15,20]
runs = [54,79,145,234]
pp.plot(overs,runs)
pp.xlabel('Overs')
pp.ylabel('Runs')
pp.show()
8. A company wants to analyze the sales of their products over the past year. Using Matplotlib,
create a line plot showing the monthly sales figures for each product.
Ans.
import matplotlib.pyplot as plt
# Sales data for the products
product1_sales = [1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800, 3000, 3200]
product2_sales = [800, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800, 3000]
# X-axis labels for the months
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
# Plot the sales figures for each product
plt.plot(months, product1_sales, label='Product 1')
plt.plot(months, product2_sales, label='Product 2')
# Add a �tle and axis labels
plt.�tle('Monthly Sales Figures')
plt.xlabel('Months')
plt.ylabel('Sales')
# Show the legend
plt.legend()
# Show the plot
plt.show()
9. A sports club wants to track the performance of their team over the course of a season. Using
Matplotlib, create a bar chart showing the number of wins, losses, and draws for each team in the
league.
Ans.
import matplotlib.pyplot as plt
# Number of wins, losses, and draws for each team
team1_stats = [15, 7, 3]
team2_stats = [12, 10, 3]
team3_stats = [9, 12, 4]
# X-axis labels for the teams
teams = ['Team 1', 'Team 2', 'Team 3']
# Set the width of the bars
barWidth = 0.25
# Plot the data as bars
plt.bar(teams, team1_stats, width=barWidth, label='Wins')
plt.bar([x + barWidth for x in teams], team2_stats, width=barWidth, label='Losses')
plt.bar([x + barWidth*2 for x in teams], team3_stats, width=barWidth, label='Draws')
# Add a �tle and axis labels
plt.�tle('Team Performance')
plt.xlabel('Teams')
plt.ylabel('Number of Matches')
# Show the legend
plt.legend()
# Show the plot
plt.show()
3. What are the limita�ons of file system that can be overcome by a rela�onal DBMS?
Ans. There are certain limita�ons of the file system than can be overcome by a rela�onal DBMS are
as following:
1. Difficulty in access: When you are using a file system you need an applica�on to access those files.
These applica�ons have their own limita�ons, or they are made in such a manner that they allow
only a few kinds of features. These files have a different patern, structure, and format. The database
can read all kinds of data in a specific format.
2. Data Redundancy: In a file system, you don't have an op�on to avoid duplicity of data. If you need
to use data in different files, you must insert them in those files also. It adds extra load on the system
and memory. In the database, you have a rela�onal model that allows rela�onship that maps data
between different tables.
3. Data Inconsistency: It is a process when users are working on a shared pla�orm. When a similar
file is loaded into a different computer system and any DML opera�on (Insert, Update, Delete) is
performed, then data inconsistency will occur. Means in one file it gets changed but not in all shared
files simultaneously.
4. Data Isola�on: The file system does not support any rela�onship or mapping. Hence it very difficult
to retrieve isolated data from different files.
5. Data Dependence: If any modifica�on is done in the format or structure of the file, all the related
applica�ons must be changed. Hence, it requires the upgraded version to access the data files.
6. Control data sharing: Whether it is a large or small organisa�on, data must be shared between
different users. Some of the files are accessed by specific people and some other files with some
other people. So, this type of sharing control is very difficult on file system.
4. A ____ is a property of the en�re rela�on, which ensures through its value that each tuple is
unique in a rela�on.
a. Rows
b. Key
c. Atributes
d. Fields
5. An atribute in a rela�on is a foreign key if it is the ______ key in any other rela�on.
a. Candidate
b. Primary
c. Super
d. Sub
6. Which of the following keywords will you use in the following query to display the unique values
of the column dept_name?
SELECT________ dept_name FROM COMPANY;
a. All
b. From
c. Dis�nct
d. Name
7. Data manipula�on language (DML) includes statements that modify the_____ of the tables of
database.
a. Structure
b. Data
c. User
d. Size
9. Give some examples of DML commands. Or Write the name of any two DML Commands of SQL ?
Ans.
INSERT, UPDATE, SELECT and DELETE
10.What is a tuple?
Ans. A tuple refers to a row of a rela�on.
2. Write a MySQL query to display the names and email addresses of all the female students from
the "students" table.
Ans. SELECT name, email FROM students WHERE gender='female';
3. Write a MySQL query to display the number of students in each grade from the "students" table.
Ans. SELECT grade, COUNT(*) as num_students FROM students GROUP BY grade;
4. Write an MySQL query to display the names of all the students who have scored above 90 in the
"marks" table.
Ans.
SELECT students.name FROM students
INNER JOIN marks ON students.id=marks.student_id
WHERE marks.score>90;
5. Write a MySQL query to display the average score for each subject in the "marks" table.
Ans. SELECT subject, AVG(score) as avg_score FROM marks GROUP BY subject;
6. Consider a table named "sales" with the following columns and write query for a) to e)
a) Write a MySQL query to display the total number of units sold across all products.
Ans. SELECT SUM(units_sold) AS total_units_sold FROM sales;
b) Write a MySQL query to display the average price per unit across all products, rounded to two
decimal places.
Ans. SELECT ROUND(AVG(price_per_unit), 2) AS avg_price_per_unit FROM sales;
c) Write a MySQL query to display the date of the first sale recorded in the "sales" table.
Ans. SELECT MIN(date) AS first_sale_date FROM sales;
d) Write a MySQL query to display the product that generated the highest total sales.
Ans.
SELECT product FROM sales ORDER BY total_sales DESC LIMIT 1;
e) Write a MySQL query to display the total sales for each month of the year, ordered by the month
in ascending order.
Ans.
SELECT MONTH(date) AS month, SUM(total_sales) AS total_sales
FROM sales
ORDER BY month ASC;
7. Consider a table named "sales" with the following columns:
id (int, primary key)
date (date)
product (varchar)
units_sold (int)
price_per_unit (float)
total_sales (float)
b) Display the total sales for each quarter of the year 2022.
Ans.
SELECT QUARTER(date) AS quarter, SUM(total_sales) AS total_sales
FROM sales
WHERE YEAR(date) = 2022
GROUP BY quarter;
c) Display the average number of units sold per day for the month of January 2022.
Ans.
SELECT AVG(units_sold) AS avg_units_sold_per_day
FROM sales
WHERE YEAR(date) = 2022 AND MONTH(date) = 1;
d) Display the date of the earliest sale and the date of the latest sale recorded in the "sales" table.
Ans. SELECT MIN(date) AS earliest_sale_date, MAX(date) AS latest_sale_date FROM sales;
8. Consider two tables named "students" and "courses" with the following columns:
Table "students":
id (int, primary key)
name (varchar)
age (int)
email (varchar)
course_id (int, foreign key references courses.id)
Table "courses":
id (int, primary key)
name (varchar)
instructor (varchar)
credits (int)
b) Add a new course named "Data Structures" with an instructor named "Jane Doe" and 3 credits.
Ans. INSERT INTO courses (name, instructor, credits) VALUES ('Data Structures', 'Jane Doe', 3);
e) Delete the course with ID 4 and all students enrolled in that course.
Ans.
DELETE FROM students WHERE course_id = 4;
DELETE FROM courses WHERE id = 4;
11.Rachna Mital runs a beauty parlour. She uses a database management system(DBMS) to store
the informa�on that she needs to manage her business. This informa�on includes customer
contact details, staff names, the treatments that the parlour offers (for example, ''Hair Massage'')
and appointment that customers have made for treatments. A separate appointment must be
made for each treatment.
The details are stored in a database using the following four rela�ons:
Customer: (CustomerID, FirstName, LastName, TelephoneNumber, EmailAddress)
Staff: (StaffID, FirstName, LastName, IsQualified)
Treatment: (TreatmentName, Price, TimeTaken, NeedsQualifica�on)
Appointment: (CustomerID, TreatmentName, ApDate, ApTime)
• The IsQualified atribute for a member of staff stores one of the value True or False, to indicate if
the member of staff is fully qualified or not.
• The NeedsQualifica�on atribute for a treatment stores True or False to indicate if the treatment
can only be given by a qualified member of staff.
• The TimeTaken atribute for a treatment is the number of minutes (a whole number) that the
treatment takes.
Ans.
a)
CREATE TABLE Staff (
StaffID INT NOT NULL,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
IsQualified BOOLEAN NOT NULL,
PRIMARY KEY (StaffID)
);
b)
INSERT INTO Staff (StaffID, FirstName, LastName, IsQualified)
VALUES (2009, 'Sheril', 'Mark', True);
c) Records of the Treatment table can be deleted without affec�ng any other table because there is
no foreign key constraint that references the Treatment table.
d)
ALTER TABLE Appointment
ADD COLUMN StaffID INT REFERENCES Staff (StaffID);
e)
SELECT Customer.EmailAddress, Customer.FirstName, Customer.LastName
FROM Customer, Appointment, Treatment
WHERE Customer.CustomerID = Appointment.CustomerID
AND Appointment.TreatmentName = Treatment.TreatmentName
AND Treatment.TreatmentName = 'RF Facial'
AND YEAR(Appointment.ApDate) = 2020;
12.Write the SQL commands which will perform the following opera�ons?
a. To display the star�ng posi�on 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.
Ans.
a. select instr(name,lname)
b. select dayname(now()),monthname(now()),year(now());
c. select mod(power(3,5),5);
d. select lcase('I am here'),ucase('I am here');
WAN stands for Wide Area Network. It is a network that covers a larger geographic area, such as a
city or a country. WANs are used to connect devices across mul�ple loca�ons, such as different
offices or branches of a company.
3. What is a router?
Ans. A router is a networking device that connects mul�ple networks together and directs data
traffic between them. It uses rou�ng tables to determine the best path for data packets to travel
from one network to another.
4. What is a firewall?
Ans. A firewall is a security device that monitors and controls incoming and outgoing network traffic.
It is designed to prevent unauthorized access to a network by filtering out poten�ally harmful or
unwanted data packets.
5. What is the use of Repeater in a network?
Ans. In a network, repeater receives a weak signal coming from a source an amplifies it to its original
strength and then again forwards it to the des�na�on. Basically, repeater is used in a network so that
a signal can travel longer distances.
6. Ms. Rani sen, General Manager of Global Na�ons corporate recently discovered that the
communica�on between her company's accounts office and HR office is extremely slow and
signal drop quite frequently. These offices are 125 m away from each other and connected by
Ethernet cable.
(i) Suggest her a device, which can be installed in between the offices for smooth communica�on.
(ii) What type of network is formed by having this kind of connec�vity out of LAN, MAN and
WAN?
Ans.
(i) The device that can be installed between the office for smooth communica�on is repeater.
(ii) The type of network is Local Area Network (LAN)
7. Eduminds University of India is star�ng its first campus in a small town Parampur of central India
with its centre admission office in Delhi. The university has three major buildings comprising of
Admin Building, Academic Building and Research Building in the 5 km area campus. As a network
expert, you need to suggest the network plan as per (i) to (iv) to the authori�es keeping in mind
the distances and other given parameters.
Expected number of computers to be installed at various loca�ons in the university are as follows:
(i) Suggest the authori�es, the cable layout amongst various buildings inside the university
campus for connec�ng the building.
(ii) Suggest the most suitable place (i.e. building) to house the server of this organisa�on, with a
suitable reason.
(iii) Suggest an efficient device from the following to be installed in each of the buildings to
connect all computers.
(a) Gateway
(b) Modem
(c) Switch
(iv) Suggest the most suitable (very high speed) service to provide data connec�vity between
Admission Building located in Delhi and the campus located in Parampur from the following
op�ons:
(a) Telephone line
(b) Fixed line dial-up connec�on
(c) Co-axial cable network
(d) GSM
(e) Leased line
(f) Satellite connec�on.
Ans.
(i) The suggested cable layout is as follows: Using Bus/Star Network
(ii) The most suitable place (i.e. block) to house the server of this university is Academic Block,
because there are maximum number of computers in this block and according to 80-20 rule 80%
of traffic in a network should be local.
(iii) The efficient device to be installed in each of the blocks to connect all the computers is switch.
(iv) For very high-speed connec�vity between Admission Building located in Delhi and campus
located in Parampur is satellite connec�on.
8. Ramji Training Educa�onal Ins�tute is se�ng up its centre in RAIPUR with four specialized
departments for Orthopaedics, Neurology and Paediatrics along with an administra�ve office in
separate buildings. The physical distances between these department buildings and the number
of computers to be installed in these departments and administra�ve office are given as follows.
Answer the queries as raised by them in (a) to (d).
a) Suggest the most suitable loca�on to install the main server of this ins�tu�on to get efficient
connec�vity.
b) Suggest the best cable layout for effec�ve network connec�vity of the building having server with
all the other buildings.
c) Suggest the devices to be installed in each of these buildings for connec�ng computers installed
within the building out of the following: Gateway, switch, Modem
d) Suggest the topology of the network and network cable for efficiently connec�ng each computer
installed in each of the buildings out of the following:
Topologies: Bus Topology, Star Topology
Network Cable: Single Pair Telephone Cable, Coaxial Cable, Ethernet Cable.
Ans.
a) Administra�ve office as it has maximum number of computers.
b) Cable layout will be based on star topology:
Pediatrics
neurology orthopedics
administra�ve
Chapter 7:
2. Google is a ____________________ .
a. Web page
b. Website
c. Applica�on
d. All of these
4. The First Page we generally view when we open the browser is called____________.
a. Default page
b. First page
c. Home page
d. Landing Page
5. Redirec�on or pop-ups in the website are to be checked carefully before forwarding? Why is this
so important?
Ans. The pop-ups or redirec�on can be a trap form the hackers to hack your computer, so they
needed to be checked carefully.
6. The protocols used to send and receive emails, respec�vely, are __________
a. SMTP, MIME
b. SMTP, POP3
c. POP3, SMTP
d. POP3, MIME
7. What is the difference between a sta�c web page and dynamic web page?
Ans.
Sta�c web page:
• In sta�c web pages, Pages will remain same un�l someone changes it manually.
• Sta�c Web Pages are simple in terms of complexity.
• Sta�c Web Page takes less �me for loading than dynamic web page.
Dynamic Webpage:
• In dynamic web pages, Content of pages are different for different visitors.
• Dynamic web pages are complicated.
• Dynamic web page takes more �me for loading.
8. Which of the following protocols is used in real �me internet based communica�on?
a. VoIP
b. SMTP
c. POP3
d. MIME
b. Asser�on (A): Someone has created a fake social media profile in the name of Saket. Saket is a
vic�m of cyberstalking.
Reason (R): Cyberstalking is a form of cybercrime.
Ans. Asser�on (A) and Reason (R) are both true, but Reason (R) is not the correct explana�on of
Asser�on (A).
8. What is cybercrime?
Ans. Cybercrime- Any criminal offence that is facilitated by or involves the use of, electronic
communica�ons or informa�on systems, including any electronic device, computer, or the internet is
referred to as cybercrime. For example:
* Credit card frauds
* Phishing
* Illegal downloading
* Child pornography
* Cyber bullying, etc.
Chapter 9:
1. What is IT Act?
Ans. India's IT Act and IT (Amendment) Act, 2008:
• In India the cyber laws are enforced through Informa�on Technology Act, 2000 (IT Act 2000).
Its prime purpose was to provide legal recogni�on to electronic commerce.
• This act was amended in December 2008 through the IT (Amendment) Act, 2008.
• It came into force from Oct 27, 2009. It provided addi�onal focus on informa�on security
and added several new sec�ons on offences including Cyber Terrorism and Data Protec�on.
Other major amendments of IT Act (2008) included:
a. Authen�ca�on of electronic records by digital signatures gets legal recogni�on.
b. E-documents gets legal recogni�on.
6. What are the problems arising out of the internet addic�on and how can these problems be
solved?
Ans.
1. One suffers from personal, family, academic, financial, and occupa�onal issues, just like these
happen in other types of addic�ons.
2. Sufferers start lying about the �me spent on the internet and avoids interac�on with people
around.
3. Sufferer's changed habits and behaviour lead to loss of trust in the people or rela�ons around him,
and it leads to more loneliness.
4. Mental and emo�onal symptoms: Anger, depression, mood swings, procras�na�on, etc.
5. Physical Symptoms: Ea�ng irregulari�es, upset stomach, headaches, backaches, etc.
How to Overcome Internet Addic�on
1. Help of a qualified doctor or counsellor.
2. Family Support.
3. Self-determina�on.