0% found this document useful (0 votes)
143 views

QB Ip 12-1

The document contains a question bank with multiple choice questions related to Informatics Practices for Class 12. There are questions related to Python, Pandas, SQL, networks and cybersecurity. The questions cover topics like data visualization using Matplotlib, dataframes in Pandas, functions in SQL, network devices and topologies, cybercrimes, and digital properties. The document contains the questions, possible answers and the correct answers to test knowledge of key concepts in Informatics Practices.

Uploaded by

Nidhi Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views

QB Ip 12-1

The document contains a question bank with multiple choice questions related to Informatics Practices for Class 12. There are questions related to Python, Pandas, SQL, networks and cybersecurity. The questions cover topics like data visualization using Matplotlib, dataframes in Pandas, functions in SQL, network devices and topologies, cybercrimes, and digital properties. The document contains the questions, possible answers and the correct answers to test knowledge of key concepts in Informatics Practices.

Uploaded by

Nidhi Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

INFORMATICS PRACTICES (065) (QUESTION BANK)

CLASS-XII
1 mark questions
1.

The command used to show legends is


a. display()
b. show()
c. legend()
d. legends()
Ans: legend()
2.
Given a Pandas series called Sample, the command which will display
the last 3 rows is
a. print(Sample.tail(3))
b. print(Sample.Tail(3))
c. print(Sample.tails(3)
d. print(Sample.Tails(3))
Ans: print(Sample.tail(3))
3.
Given the following Series S1 and S2:
S1 S2
A 10 A 5
B 20 B 4
C 30 C 6
D 40 D 8
Write the command to find the multiplication of series S1 and s S2
Ans: print(S1*S2)
4.
Which of the following is not a valid chart type?
a. Line plot
b. Bar graph
c. Histogram
d. Statistical
Ans: Statistical
5.
The command used to give a heading to a graph is _________
a. plt.show()
b. plt.plot()
c. plt.xlabel()
d. plt.title()
Ans: plt.title()
6. Source code is available for proprietary software. (True/False)
Ans: False
7. Which device is used to regenerate for signals over long distance data transmission?
Ans: Repeater.
8. Which network device is used to perform modulation and demodulation during data transmission?
Ans: Modem
9. Which keyword is used to get data in descending order in mysql?
Ans: Desc.
10. State whether True or False :
i) The MAC address refers to the physical address assigned by NIC manufacturer
ii) OSS and Proprietary software are freely available.
Ans: (i) True (ii) False
11. Write the output of the following SQL command.
select pow(8,-3);
a. 512
b. 51.2
c. 0.0019531
d. 15.8
Ans: c
12. In a DataFrame, Axis= 0 represents the_____________ elements.
a. Column
b. Row
Ans. b
13. In ________________topology, If one link fails the network can still function.
a. Ring
b. Star
c. Mesh
d. Bus
Ans: Star
14. ___________________is used to host the web sites and deliver the resources requested through
web browser.
a. Webpage
b. Web Server
c. Web Browser
d. Web Client
Ans: Web Server
15. Having clause is used with ____________________________function.
a. Math function
b. Text function
c. Date Function
d. Aggregate Function
Ans: Aggregate Function
16. ______________________is the use of technology to harass, threaten or humiliate a target.
Ans: Cyberbullying
17. In Pandas the function used to gets rows (or columns) with particular labels from
the index.
Ans: loc()
18. Identify the web server from following:
a. Google Chrome
b. Firefox
c. Edge
d. Apache Tomcat
Ans: d
19. The ____________command can be used to makes changes in structure of a table in SQL.
Ans: Describe
20. Write the output of the query:
select instr('Toolbarbar','bar');
Ans: 5
21. _________________________________is a cybercrime in which a target or targets are contacted
by email, telephone or text message by someone posing as a legitimate institution to lure individuals
into providing sensitive data such as personally identifiable information, banking and credit card
details, and passwords.
Ans: Phishing
22. _______________ is networking device capable to convert protocols so that two different network
architecture based system can communicate with each other.
a. Router
b. Bridge
c. Gateway
d. Modem
Ans: c
23. Suggest two ways to dispose off E-waste.
1. Ans. 1. Give Back to Your Electronic Companies and Drop Off Points.
2. 2. Visit Civic Institutions.
3. 3. Donating Your Out-dated Technology.
4. 4. Sell Off Your Out-dated Technology.
24. Write the output of the following SQL command.
select substr(“COMPUTER”,3,4);
Ans: MPUT
25. The command used to display the title for x-axis to a graph is _________
Ans: plt.xlabel()
26. Given a Pandas series called p_series, the command which will display the last 4 rows is
__________________
Ans: print (p_series.tail(4))
27. Define the term firewall.
Ans: A system designed to prevent unauthorized access to or from a private network.
5. 28. To represent data column wise in a DataFrame the axis is __________
6. Ans: 1
29. In network terms UTP stands __________________
Ans: Unshielded Twisted Pair
7. 30. The now() function in MySql is an example of ___________________.
8. Ans: Date function
9. 31. The _________ command is used to make the changes in a table permanent.
10. Ans: Commit
11. 32. Give SQL command that will display the current month from the date and time.
12. Ans: month()
33. Give an advantage of using the star topology in a computer network.
Ans: 1. Easy to add new stations.
2. Easy to monitor and troubleshoot.
34. What is meant by Cyber Security?
Ans: Cyber security is the combination of best processes and practices to ensure the security of
Networks
35. Write the output of the SQL command Select round(458.46, 1);
Ans: 458.5
36. A table Sports1 in a database has 3 columns and 30 rows. Another similar table Sports2 has 3
columns and 50 rows. All the records from Sports2 are added into Sports1 table What is the degree
and cardinality of Sports1 table now?
Ans: Degree 3 and Cardinality 80
37. Axes of a plot can be labelled using _____ and ______ functions
Ans: xlabel and ylabel
38. Website contains multiple ____________
Ans: Webpages.
39. Which Network topology has a centralized control of all nodes connected in the network ?
Ans: Star Topology
40. Which method is used to access vertical subset of a dataframe.?
Ans: Iteritems()

41. What is the difference between Static and dynamic webpage?


Ans: Static web pages data do not changes until someone changes it manually and hence data
is static in nature. On other hand for Dynamic web page data is first interoperate at server side and
due to which it does not remain same on every call and this makes data dynamic in nature.

42. Which of the following keywords will you use in the following query to display all the records of
students whose name start with S?
Ans: SELECT * from student where name like “S%”.

43. ________________________ is any information about you or created by you that exists in digital
form, either online or on an electronic storage device.
Ans: Digital Property

44. Which of the following is an aggregate function:


a.) UPPER()
b.) TRIM()
c.) DATE()
d.) SUM()
Ans: d

45. Which of the following is not a valid plotting function of pyplot?


a.) bar()
b.) hist()
c.) his th()
d.) barh()
Ans: c

46. Online personal accounts like Paytm account, Phonepe account etc. are examples of ______.
Ans: Digital Wallets

47. State whether True or False


a. A series object is size mutable
b. A Dataframe object is value mutable
Ans. a. False
b.True
48. Write the output of the following SQL command SELECT left(“Meerut Region”, 5);
Ans: egion

49. Name the type of Network that is limited to the proximity of an individual and covers a range up to
10-20 meter of distance.

Ans: PAN

50. Which laws have been incorporated for punishing all types of crimes that are done on
Computer/phones or over internet?
Ans: Cyber laws

51. 1 Which of the following is not covered under IPR?


(a) Music (b) Insurance (c) Logo Designed (d) Invention
Ans: b

52. What will be the output of the following code?


SELECT MOD(14,3);
Ans: 2
53. What will be the output of the following code?
import pandas as pd
s = pd.Series(6,index=range(0,5))
print(s)
Ans: 0 5
1 5
2 5
3 5
4 5
dtype int64
54. Fill in the blanks with correct library to execute the given code.
import____________________ as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10, 5, 7])
plt.plot(ypoints)
plt.show()
Ans: matplotlib.pyplot

55. An_______ is a software extension that adds extra features to a program.


Ans: Add on

56. Rohan wants to print the row labels of the dataframe. He should use the __________ attribute of
a dataframe.
Ans: Index

57. _______ websites are ones that are fixed and display the same content for every user, usually
written exclusively in HTML.
Ans: Static

58. Which of the network topology can be a preferred for a company that would like to keep
adding more and more computers to the topology economically as they grow?
Ans: Tree/Star.

59. What is the maximum number of years that a patent would be valid in India?
Ans: 20 years.

60. The networking device that forwards data packets between computer network is
__________.
Ans: Router
61. Write the expansion of the following terms
(a) HTTP (b) URL
Ans. a.) Hyper Text Transfer Protocol b.) Uniform Resource Locator
62. Give any two examples of e-waste.
Ans: telecommunications and TV equipment. - Computers. - Laptops. - Printers. - Mobile phones. -
Televisions.(any two)
63. A mail or message sent to a large number of people indiscriminately without their consent is
called ______________
Ans. Spam
64. Plagiarism is a cybercrime under Indian IT Act. (True / False)
Ans: False
65. Write the command to delete all the data of the table ‘activity’ retaining only structure.
Ans: Delete from activity;
66. Which networking device with similar functionality can be used to replace a hub?
Ans: Switch
67. Give one disadvantage of Open Source Software.
Ans: 1. Some open source applications may be tricky to set up
2.Compatibility issues - Many types of proprietary hardware need specialised drivers to run
open source programs, which are often only available from the equipment .
68. Statement import pyplot.matplotlib is a valid statement for working on pyplot functions. (True /
False).
Ans: False
69. State whether True or False:
a. A worm is a self-replicating program.
b. Firewall can be implemented in software as well as in hardware.
Ans: a.) True
b.) True

70. Fill in the blanks:


Which command is used to show a chart:
a. chartshow()
b. show()
c. display()
d. showchart()
Ans: b

71. Write the output of the following SQL command:


select round(458.45, - 1)
Ans: 460

72. Given a Pandas series called Sequences, the command which will display the last 7 rows is
_______________.
Ans: print(Sequences.tail(7)).

73. Full form of bcc in the context of email is ______________.


Ans: Blind Carbon Copy.

74. In Pandas, _________ function will return the total number of rows in a dataframe.
Ans: len()

75. Which amongst the following is not an example of Antivirus ?


i. a. Avast
ii. b. Quick Heal
iii. c. Edge
iv. d. McAfee
Ans: c
76. The __________ command is used to sort a column’s data in SQL in ascending order.
Ans: order by

77. Write the SQL command that removes leading and trailing spaces from a given string.
Ans: Select Trim()
78. The _______ topology has a central controller.
Ans: Star

79. Which of the following is not a network topology :


Star, Mesh , Tree, Bug , Bus
Ans: Bug

80. For web pages where the information is changed frequently, for example, stock prices, weather
information which out of the following options would you advise?
a) Static web page
b) Dynamic web page
Ans: Dynamic web page

81. State whether True or False :


i. Digital Software Penetration is carried out with tools such as cracks, keygen etc.
ii. In Freeware the source code is hidden from the user.
Ans: i) True ii) True

82 Using Python Matplotlib histograms can be used to count how many values fall into each
interval. Each interval is known as
a. hist
b. class
c. bin
d. label
Ans: bin

83. In network terms UTP stands __________________


Ans: Unshielded Twisted Pair

84. Matplotlib allows you to create


a.) table b.) charts c.) maps d.) infographics
Ans: b

85. The _______ module of Pyplot lets you draw box plots.
Ans: boxplot()

86. Write a Python code to create an empty dataframe.


Ans: import pandas as pd
df= pd.DataFrame()
print(df)
87. To create object __________method is used.
Ans: Series()

88. DataFrame has ______indices.


Ans: two

89. How to check if a DataFrame df has any missing values?


Ans: df.isnull().values.any()

90. A DataFrame called Grade. Write a command to delete the 3rd and 5th rows of Grade.
Ans. Gr= pd.DataFrame(Grade)
Gr.drop([2,4])
91. Hitesh wants to display the last four rows of the dataframe df and has written the following code:
df.tail()
But last 5 rows are being displayed. Identify the error and rewrite the correct code so that last 4 rows
get displayed.
Ans: df.tail(4)
92. By default ORDER BY clause sorts the result set in descending order.
Ans: False

93. Which keyword eliminates redundant data from a query result?


Ans. DISTINCT
94. What is Having clause?
Ans. Having clause is used in combination with Group By clause in a Select statement to put condition
on groups.

Write the output of the following SQL queries from Qus 95 to 109.

95. SELECT MOD(23,2);

96. SELECT MID(‘HONESTY WINS’,3,4);

97. SELECT RIGHT(CONCAT(‘PRACTICES’,’INFORMATICS’),5);

98. SELECT MONTHNAME(‘2015-01-16’);

99. SELECT INSTR(“INTERNATIONAL”, “NA”);

100. SELECT LENGTH(CONCAT(“NETWORK”,”ING”));

101. SELECT ROUND(563.345, -2);

102. SELECT DAYOFYEAR(“2014-01-30”);

103. SELECT SUBSTR('123456789', INSTR('abcabcabc', 'b'), 4) FROM DUAL;

104. SELECT SUBSTR('abcdefghij', 6, 2) FROM DUAL;

105. SELECT ROUND(45.926, -1) FROM DUAL;

106. SELECT LENGTH(CONCAT(“NETWORK”,”NULL”))

107. SELECT POW(ROUND(2.34),2);

108.SELECT MID(CONCAT(RIGHT(“GOOD MORNING”,4), LEFT(“GOOD MORNING”,4)),2)


109. SELECT DAY('2019-10-14')

Ans.
95. 1
96. NEST
97. ATICS
98. January
99. 6
100. 10
101. 600
102. 30
103. 2345
104. fg
105. 50
106. 11
107. 4
108. INGGOOD
109. 14

Qus from 110 to 115 are based on Python Series

110. Storing even numbers from 1 to 20 with default indexes.

Ans. import pandas as pd


import numpy as np
evenno=np.arange(2,21,2)
s=pd.Series(evenno)
print(s)

111. Storing following percentages of 5 students stored in the form of a list with indexes from 1 to 5.

90, 85, 78.5, 90.5, 56.5

Ans. import pandas as pd


import numpy as np
L=[90,85,78.5,90.5,56.5]
s=pd.Series(L)
print(s)
112. Storing value 100 with indexes as odd numbers from 1 to 10.
Ans. import pandas as pd
import numpy as np
a=np.arange(1,10,2)
b=pd.Series(100,index=[a])
print(b)
OUTPUT
1 100
3 100
5 100
7 100
9 100
113. Storing value “Pass and Promoted” for 5 students with names: Ajay, Vikas, Sunesh, Rita, Ramya
Store names of the students as index of the series.
Ans: import pandas as pd
import numpy as np
a=np.array(['Ajay','Vikash','Sunesh','Rita','Ramya'])
b=pd.Series('Pass and Promoted',index=[a])
print(b)

OUTPUT
Ajay Pass and Promoted
Vikash Pass and Promoted
Sunesh Pass and Promoted
Rita Pass and Promoted
Ramya Pass and Promoted
114. Storing numbers from 1 to 5 as indexes and their square values as data.

Ans: import pandas as pd


import numpy as np
a=np.arange(1,5)
b=a*a
c=pd.Series(b,index=[a])
print(c)
OUTPUT
1 1
2 4
3 9
4 16
115. Consider list – MonthNames, containing names of months and list- NoOfDays, containing number
of days in each month. Create a series with month names as indexes and number of days as data
corresponding to each index.
Ans:
import pandas as pd
import numpy as np
a=np.array(['Jan','Feb','Mar''Apr','May','Jun','July','Aug','Sep','Oct','Nov','Dec'])
b=np.array([31,30,31,30,31,30,31,31,30,31,30,31])
c=pd.Series(b,index=[a])
print(c)
OUTPUT
Jan 31
Feb 30
Mar 31
Apr 30
May 31
Jun 30
July 31
Aug 31
Sep 30
Oct 31
Nov 30
Dec 31
Qus from 116-123
Consider the following two series:
ser1=pd.Series([2,5,7,9,6], index=['A','B','C','D','E'])
ser2=pd.Series([8,2,6,3,9], index=['A','K','D','M','E'])
Write Python statements to perform the following operations. Also give output that will be obtained
after performing the desired operation.
116. Add ser1 to ser2
Ans. print(ser1+ser2)
117. Add ser2 to ser1 filling missing indexes with value 10.
Ans. print (ser2.add(ser1,fill_value=10))
118. Subtract ser1 from ser2
Ans. print(ser2-ser1)
119. Subtract ser2 from ser1 filling missing indexes with value 5.
Ans. print(ser1.sub(ser2,fill_value=5))
120. Multiply ser1 with ser2
Ans. print(ser1*ser2)
121. Multiply ser2 with ser1 filling missing index values with 0
Ans. print(ser2.mul(ser1,fill_value=0))
122. Divide ser1 by ser2
Ans. print(ser1/ser2)
123. Divide ser2 by ser1 filling missing index values with 5.
Ans. print(ser2.div(ser1,fill_value=5))

Qus 124 to 131 Consider the following dictionary:

states={'A':'Andhra Pradesh', 'B':'Bihar', 'D':'Delhi', 'K':'Kerala', 'R':'Rajasthan', 'T':'Tamil Nadu'}

124. Create a series from the above dictionary and write Python statements for the following:

Ans. import pandas as pd

states={'A':'Andra pradesh','B':'Bihar','D':'Delhi',

'k':'keerla','R':'Rajasthan','T':'Tamil'}

s=pd.Series(states)

125. To display 1st,3rd,5th elements of the series.

Ans. import pandas as pd

states={'A':'Andra pradesh','B':'Bihar','D':'Delhi',

'k':'keerla','R':'Rajasthan','T':'Tamil'}

s=pd.Series(states)

print(s[[0,2,4]])

OUTPUT

A Andra pradesh

D Delhi

R Rajasthan

126. To display all elements from 2nd to 5th present in the series.

Ans. import pandas as pd

states={'A':'Andra pradesh','B':'Bihar','D':'Delhi',

'k':'keerla','R':'Rajasthan','T':'Tamil'}

s=pd.Series(states)

print(s[2:])
OUTPUT

D Delhi

K Keerla

R Rajasthan

T Tamil

127. To replace the value of index ‘K’ by ‘Karnataka’.

Ans. import pandas as pd

states={'A':'Andra pradesh','B':'Bihar','D':'Delhi',

'k':'keerla','R':'Rajasthan','T':'Tamil'}

s=pd.Series(states)

s[[2,5]]='My pride'

print(s)

OUTPUT

A Andra pradesh

B bihar

D My pride

K keerla

R rajasthan

T My pride

To assign value ‘My Pride’ to 3rd - 6th elements

To display first three elements of the series

To display last five elements of the series

To display the series in reverse order


128. What will be output produced by the following program?
Import pandas as pd
Info = pd.Series(data=[31,41,51])
Print(info)
Print(info>40)
Ans: Output 1 41
2 51
Qus from 129 to 132 are based on the following information
vls=pd.Series(*11,23,61,87,93+, index=*‘a’,’b’,’c’,’d’,’e’,’f’+)
Consider a Series object vls, write statements to do the following:
129. Retrieve the third element and print it.
130. Retrieve and print the first three elements.
131. Retrieve and print the last two elements.
132. Retrieve print alternate elements, starting from index ‘b’.

Ans 129. print(vls[2])


130. print(vls[:3])
131. print(vls[-2:])
132. print(vls**‘b’,’e’,’f’++)

Case Study Based Questions


Attempt any four sub parts from each question. Each sub question carries 1 mark
Consider the following DataFrame df and answer any four questions from (i)- (v)

EmpNo Name Quarter1 Quarter2 Quarter3 Quarter4

0 1 Prem 2000 5800 20000 1400

1 2 Prakash 4000 2500 16000 3700

2 3 Meena 5000 5400 7000 1700

3 4 Ram 4400 3000 3600 2000

4 5 Raj 10000 2900 8200 6000

i. Write down the command that will give the following output.

EmpNo 5
Name Ram
Quarter1 10000
Quarter2 5800
Quarter3 20000
Quarter4 6000
dtype:object

a. print(df.max)
b. print(df.max())
c. print(df.max(axis=1))
d. print(df.max, axis=1)

ii. The Employer needs to know the Quarterly Revenue by Employee with Emp No -4. Help Employer
to identify the correct set of statement/s from the given options :
a. df1=df[df[‘EmpNo’]==4]
print(df1)
b. df1=df[EmpNo ==4]
print(df1)
c. df1=df[df. EmpNo =4]
print(df1)
d. df1=df[df. EmpNo =4]
print(df1)
iii Which of the following statement(s) will give the exact number of values in each column of the
dataframe?
i. print(df.count()) ii. print(df.count(0))
iii. print(df.count) iv. print(df.count(axis=’index’))
Choose the correct option:
a. both (i) and (ii)
b. only (ii)
c. (i), (ii) and (iii)
d. (i), (ii) and (iv)

iv. Which of the following command will display the column labels of the DataFrame?
a. print(df.columns())
b. print(df.column())
c. print(df.column)
d. print(df.columns)

v. HR wants to add a new column, the scores of APR Grade with the values, ‘ A’, ‘B’, ‘A’, ‘A’, ‘B’ ,to the
DataFrame. Help HR to choose the command to do so:
a. df.column=*’A’,’B’,’A’,’A’,’B’,’A’+
b. df [‘Grade’]=[’A’,’B’,’A’,’A’,’B’,’A’]
c. df.loc*‘Grade’+= *’A’,’B’,’A’,’A’,’B’,’A’+
d. Both (b) and (c) are correct

Consider the following DataFrame emp


s)
empno Name Dept salary Experience (in Years)
1 Ram Singh IT 15000 2.5
2 Shyam Singh HR 18000 3
3 Nidhi Gupta IT 9000 2
4 Puja Sharma EXE 24000 8
5 Rohan Malik HR 20000 6

133. Write down the command that will give the following output.
Empno 5
Name Rohan Malik
Dept HR
Salary 20000
Experience 6
dtype: object
a. print(emp.max)
b. print(emp.max())
c. print(emp.max(axis=1))
d. print(emp.max,axis=1)
Ans. b
134. The CEO needs to know the salary of the employee with empno 4. Help him to
identify the correct set of statement/s from the given options:

a. emp1=emp*emp*‘empno’+==4+
print(emp1)
b. emp1=emp[emp]
print(emp1)
c. emp1=emp[emp.empno=4]
print(emp1)
d. emp1=emp[emp.empno==4]
print(emp1)
Ans a and d

135. Which of the following statement/s will give the exact number of values in each column of
the dataframe?
i. print(emp.count())
ii. print(emp.count(0))
iii. print(emp.count)
iv. print(emp.count(axis=’index’))

Choose the correct option:


a. both (i) and(ii)
b. only(ii)
c. (i), (ii) and(iii)
d . (i), (ii) and(iv)

136. Which of the following command will display the column labels of the DataFrame?

a. print(emp.columns())
b. print(emp.column())
c. print(emp.column)
d. print(emp.columns)

Consider the following DataFrame df and answer any four questions from (i)- (v)
EmpNo Name Quarter1 Quarter2 Quarter3 Quarter4

0 1 Prem 2000 5800 20000 1400

1 2 Prakash 4000 2500 16000 3700

2 3 Meena 5000 5400 7000 1700

3 4 Ram 4400 3000 3600 2000

4 5 Raj 10000 2900 8200 6000


137. Write down the command that will give the following output.

EmpNo 5

Name Ram
Quarter1 10000

Quarter2 5800

Quarter3 20000

Quarter4 6000

dtype:object

a. print(df.max)
b. print(df.max())
c. print(df.max(axis=1))
d. print(df.max, axis=1)

138. The Employer needs to know the Quarterly Revenue by Employee with Emp No -4. Help Employer
to identify the correct set of statement/s from the given options :
a. df1=df[df[‘EmpNo’]==4]
print(df1)
b. df1=df[EmpNo ==4]
print(df1)
c. df1=df[df. EmpNo =4]
print(df1)
d. df1=df[df. EmpNo =4]
print(df1)

139. Which of the following statement(s) will give the exact number of values in each column of the
dataframe?
i. print(df.count()) ii. print(df.count(0))
iii. print(df.count) iv. print(df.count(axis=’index’))
Choose the correct option:
a. both (i) and (ii)
b. only (ii)
c. (i), (ii) and (iii)
d. (i), (ii) and (iv)

140. Which of the following command will display the column labels of the DataFrame?
a. print(df.columns())
b. print(df.column())
c. print(df.column)

d. print(df.columns)
141. HR wants to add a new column, the scores of APR Grade with the values, ‘ A’, ‘B’, ‘A’, ‘A’, ‘B’ ,to
the DataFrame. Help HR to choose the command to do so:
a. df.column=*’A’,’B’,’A’,’A’,’B’,’A’+
b. df [‘Grade’]=[’A’,’B’,’A’,’A’,’B’,’A’]
c. df.loc*‘Grade’+= *’A’,’B’,’A’,’A’,’B’,’A’+
d. Both (b) and (c) are correct

Consider the table FLIGHT given below:

142. Choose the command that will give the output as :

a. select FLCODE,START,DESTINATION,NO_FLIGHTS from FLIGHT order by NO_FLIGHTS desc;


b. select FLCODE,START,DESTINATION,NO_FLIGHTS from FLIGHT order by NO_FLIGHTS
c. select FLCODE,START,DESTINATION,NO_FLIGHTS from FLIGHT group by NO_FLIGHTS desc;
d. select FLCODE,START,DESTINATION,NO_FLIGHTS from FLIGHT;
143. What will be the output of the following command?
select FLCODE,No_FLIGHTS from FLIGHT where NO_STOPS=0;

a. b.

c. d.

144. Ram has given the following command to obtain the unique (list of destinations) destination from
Flight table .
Select count(DESTINATION) from FLIGHT ; but he is not getting the desired result. Help him by writing
the correct command.
a. Select DESTINATION from FLIGHT ;
b. Select MAX(DESTINATION) from FLIGHT ;
c. Select distinct(DESTINATION) from FLIGHT ;

d. Select SUM(DESTINATION) from FLIGHT ;

145. State the command to Count and display number of flights reaching at each destination.
a. select FLCODE ,DESTINATION,NO_FLIGHTS from FLIGHT order by DESTINATION;
b. select count(FLCODE),DESTINATION,NO_FLIGHTS from FLIGHT
c. select count(FLCODE),DESTINATION,NO_FLIGHTS from FLIGHT group by NO_FLIGHTS;

d. select count(FLCODE),DESTINATION,NO_FLIGHTS from FLIGHT group by DESTINATION;

146. Help Ram to write the command to display the maximum no of stops from FLIGHT table.

a. select max(NO_STOPS) from FLIGHT;

b. select count(NO_STOPS) from FLIGHT;

c. select NO_STOPS from FLIGHT;


Ans:
142- (a.)
143. (b.)
144. (c.)
145.(c.)
146.(a.)
147. Name the command/clause which is used to display the records in ascending or descending
order.
Ans. order by clauseQ2. Correct the error in the following query:
148. Select * from book where author_name = NULL;
Ans. Select * from book where author_name is NULL;
149. Give example of any two aggregate functions in MySQL.
Ans. avg( ) and count( )
150. Give example of any two DML commands.
Ans. Insert , Delete
151. Give examples of any two DDL commands.
Ans. Create, Drop
152. What is the purpose of SQL?
Ans. SQL is structured query language. It is a standard language of all the RDBMS
153. What is the difference between primary key and unique constraint.
Ans. In primary key, we can not enter the null values while in unique keys one null value can be
entered.
154. Which keyword is used to return only different values from table?
Ans. Distinct
155. Which command is used to display list of all databases.
Ans. show databases;
156. What is primary key?
Ans. A field which is unique for each and every record in table is called primary key.
157. Consider the following dataframe df as shown below:
name eng ip geo total
T1 kushagra 52 98 85 235
T2 naresh 48 85 88 221
T3 prakhar 69 94 78 241
T4 trapti 70 81 91 242
(i) Write the code to create above dataframe in Python(Panda scode). 1
Import pandas as pd
ind=['T1','T2','T3','T4']
d={'name':['kushagra','naresh','prakhar','trapti'],
'eng':[52,48,69,70],
'ip':[98,85,94,81],
'geo':[85,88,78,91],
'total':[235,221,241,242]
}
df=pd.DataFrame(d,index=ind)
print(df)
(ii) What will be the output produced by following statements?
>>>print(df.at['T3','total'],df.at['T1','ip'])
(i) 235 94
(ii) 241 98
(iii) 241 94
(iv) 235 98
Ans. (ii)241 98
(iii) What will be the output produced by following statements?
>>>print(df.loc['T2':'T3','ip':'geo'])
(i) ip geo
T2 85 88
T3 94 78
(ii) ip
T2 85
(iii) ip geo
T2 85 88
(iv) ip
T2 85
T3 94
Ans.
(i) ip geo
T2 85 88
T3 94 78
(iv) What will be the output produced by following statements?
>>>print(df.iat[2,1],df.iat[1,2])
(i) prakhar 69
(ii) T2 naresh
(iii) kushagra 52
(iv) 69 85

(iv)69 85
(v) What will be the output produced by following statements?
>>>print(df.iloc[::2,0::4])
(i) name total
T1 kushagra 235
T2 naresh 221
(ii) name total
T2 naresh 221
T4 trapti 242
(iii) name total
T1 kushagra 235
T3 prakhar 241
(iii) name total
T3 prakhar 241
T4 trapti 242
(iii) name total
T1 kushagra 235
T3 prakhar 241
158. Consider the table “ITEM” created in MySQL and given below:

Ino Name Rate Qty Model


9 EARPHONE 750 5 JBL
10 EARPHONE 399 4 Mi
11 HEADPHONE 700 5 JBL
12 EARPHONE 1499 7 samsung
13 COLLERMIC 288 5 Mi
14 MOBILESTAND 499 5 lenovo
15 earphone 399 5 BoAT
16 earphone 699 50 samsung
17 headphone 1099 8 BoAt
(i) State the command that will give the output:
Name Model
EARPHONE Mi
COLLERMIC Mi
a) select name,model from item where model='Mi';
b) select name,model from item where mode llike'Mi';
c) select name, model from item where ino in(10,13);
d) select name,model from item where Qty=4 or Qty=5
Choose the correct option:
(i) Both(a)and(c)
(ii) Anyoftheoption(a),(b),and(c)
(iii) Both(c)and(d)
(iv) Both(a)and(b)

Ans. (ii) Any of the option(a),(b),and(c)

(ii) What will be the output of the following command:


select* from item where qty=5 order by model desc;
(i)
12 EARPHONE 1499 7 samsung
16 EARPHONE 699 50 samsung
10 EARPHONE 399 4 Mi
13 COLLERMIC 288 5 Mi
14 MOBILESTAND 499 5 lenovo
9 EARPHONE 750 5 JBL
11 HEADPHONE 700 5 JBL
15 EARPHONE 399 5 BoAT
17 HEADPHONE 1099 8 BoAt
(ii)
15 EARPHONE 399 5 BoAT
9 EARPHONE 750 5 JBL
11 HEADPHONE 700 5 JBL
14 MOBILESTAND 499 5 lenovo
13 COLLERMIC 288 5 Mi
(iii)
17 HEADPHONE 1099 8 BoAt
10 EARPHONE 399 4 Mi
12 EARPHONE 1499 7 Samsung
16 EARPHONE 699 50 Samsung
(iv)
13 COLLERMIC 288 5 Mi
14 MOBILESTAND 499 5 lenovo
9 EARPHONE 750 5 JBL
11 HEADPHONE 700 5 JBL
15 EARPHONE 399 5 BoAT

(ii)
15 EARPHONE 399 5 BoAT
9 EARPHONE 750 5 JBL
11 HEADPHONE 700 5 JBL
14 MOBILESTAND 499 5 Lenovo
13 COLLERMIC 288 5 Mi
(iii) Nishuhasgiventhefollowingcommandtoobtainthehighestrateofeveryitem.
Select max(rate)from item where group by name;
But she is not getting the desired result. Help her by writing the correct command.
(i)select name, max(rate)from item where group by name;
(ii)select name, max(rate)from item group by name;
(iii)select max(rate)from item group by model;
(iv)select name, max(rate)from item order by name;
Ans. (ii)select name, max(rate)from item group by name;

(iv) State the command to display the model and the total quantity of every model
Whose total quantity is greater than10is:
a)select name, sum(qty)from item group by model having sum(qty)>10
b)select model, sum(qty)from item group by name havings um(qty)>10
c)select model ,sum(qty)from item group by model having sum(qty)>10
d)select model, sum(qty)from item where qty>10group by model
Choose the correct option:
(i) Both(b)and(c)
(ii) Any of the option(a),(b),and(d)
(iii) Only(c)
(iv) Both(a)and(d)
Ans: (iii)
(v) Help Alankar to write the command to display the name of the headphone of JBL
company:
(i) select*from item where name='%phone' and model='JBL';
(ii) select*from item where name='headphone' and model='JBL';
(iii) select*from item where name like' headphone';
(iv) select*from item where name like '%phone' and model='JBL';
Ans (ii)
159.

(i) Complete the following command to display first five rows of the above Dataframe.
print(happy_df.iloc[_____ : _____]

(ii) Write the command to display number of rows and columns of the above Dataframe.
(a) print(happy_df.row,happy_df.columns)
(b) print(happy_df.shape())
(c) print(happy_df.shape)

(iii) Which command(s) of the following would display only Region column of the above
Dataframe.
(a) print(happy_df.Region)
(b) print(happy_df.iloc*,’Region’+
(c) print(happy_df.iloc* : ,’Region’+
(d) print(happy_df.iloc[:,1])
(iv) What will be the output of the following command?
print(happy_df.loc[4:6,'Country'])
(v) Which of the following commands would display maximum value of every column?
(a) print(happy_df.max)
(b) print(happy_df.max())
(c) print(happy_df.max(axis=1))
(d) print(happy_df.max, axis=1)
Ans: (i) print(happy_df.iloc[0 : 5 ]
(ii) print(df.shape)
(iii) (a) print(happy_df.Region) and (d) print(happy_df.iloc[:,1])
(iv) 4 Canada
5 Finland
6 Netherlands
Name: Country, dtype: object
(v) (b) print(happy_df.max())

160.

(i) Which of the following command will give the latest date for which data is available in
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?
(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?


SELECT ROUND(PM25,1) FROM cityair WHERE Odate = ‘2019-03-01’

(iv) What will be the output of the following query?


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.

Ans: (i) (a) SELECT MAX(ODate) FROM cityair;


(ii) (b) SELECT MONTHNAME(ODate) FROM cityair;
(iii) 114.6
(iv) 7
(v) DELETE FROM cityair WHERE Odate = “2019-03-01”;
13.

2 marks questions

161. Write a program to create a Series having 10 random numbers in the range of 10 and
20.

162. What is importance of primary key in a table? How many primary keys can be there for a
table?

163. Explain working of TRIM( ) function with proper examples.

164. Consider the following ‘Student’ table.


(i) What will be the most suitable datatype for the grade column and why?
(ii) Write a command to insert Suman’s record with the data as shown in the table.

165. Consider the following Series ‘s’


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.

166. Explain the working of ORDER BY clause of SELECT query with proper example.
167. Consider a string “AS YOU know MORE”
Write the queries for the following tasks.
(i) Write a command to display “know”.
(ii) Write a command to display number of characters in the string.
168. Consider a string “You Grow more” stored in a column str.
What will be the output of the following queries?
(i) SELECT UPPER(str);
(ii) SELECT substr(str,-9,4);

169. Given here is a Dataframe of Sales data of four months stored with name sales_df.

(i) Write a Python code to find total sales of July month.


(ii) Write a Python code to add the sales of August month with [70,94,80,93] data.
170. Give any two advantages of star topology.
171. Write any four net netiquettes you should follow while working with Internet. 2
172. What is cyber bullying? What are the two actions you would take if you feel that you are
a victim of cyber bullying?
Ans. 161
import pandas as pd
import numpy as np
arr= np.random.randint(10,20,(10,))
s = pd.Series(arr)
Ans. 162.
Primary Key : A column of collection of columns to identify a tuple in a relation. It is
used to search / locate row in a relation. There can be only one primary key in a table.

Ans 163.
TRIM () function is used to remove leading and trailing spaces from a string a table. It
can TRIM () function is used to remove leading and trailing spaces from a string a table. It
can be used as
TRIM(String)
For example;
SELECT TRIM(' bar ');be used as
TRIM(String)
For example;
SELECT TRIM(' bar ');

Ans 164.
(i) Gender column datatype char(1) as all the possible values can be accommodated and
it will be space efficient.
(ii) INSERT INTO Student (Rollno, Sname, Subject, Marks) VALUES (“003”,
”SUMAN”, “IP”, 75);

Ans. 165
(i) s1 = s + 1
print(s1)
(ii) s.add(1,fill_value=0)
print(s)

Ans. 166
The ORDER BY keyword is used to sort the result-set in ascending or descending order.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in
descending order, use the DESC keyword.

Ans. 167
(i) select mid(“AS YOU know MORE”,8,4);
(ii) select length(“AS YOU know MORE”);

Ans. 168
(i) YOU GROW MORE
(ii) Grow

Ans. 169.
(i) print(sales_df.sum().loc*‘July’+)
(ii) sales_df.insert(4,column="August",value=[70,94,80,93] )

Ans. 170
Advantages of Star Topology
 Easy to install and wire.
 No disruptions to the network when connecting or removing devices.
 Requires more cable length than a linear bus topology.
 If the connecting network device (network switch) fails, nodes attached are disabled and cannot
participate in computer network communication.
Ans. 171
 Use Respectful Language
 Share With Discretion.
 Don't Exclude Others.
 Choose Friends Wisely.
 Don't Email Large Files.
 Respect People's Privacy.
 Fact Check Before Reposting.
Ans. 172
Cyberbullying is bullying with the use of digital technologies. It can take place on social media,
messaging platforms, gaming platforms and mobile phones. It is repeated behaviour, aimed at scaring,
angering or shaming those who are targeted.

Qus 173

Ans. 173.
Import pandas as pd
S1=pd.Series(*5000,6000,8000,5500+,index=*'UP','MP’,'Gujarat','Delhi'+)

Q. 174
State any two differences between single row functions and multiple row functions.
Ans. Differences between single row functions and multiple row functions.
(i)Single row functions work on one row only where as multiple row functions group rows
(ii)Single row functions return one output per row where as multiple row
Functions return only one output for a specified group of rows.

Q 175. What is the difference between the order by and group by clause? Explain with an example.
Ans.
Group by statement is used to group the rows that have the same value. Whereas Order by
statement sort the result-set either in ascending or in descending order.

Q176. Consider the decimal number x with value7459.3654.Write commands in SQL


to:
i) round it off to a whole number
ii) round it to2places before the decimal.

Ans. (i)select round(7459.3654,0)


(ii) select round(7459.3654,-2)
Q 177.

Ans 177
i. print(S[S>250])
ii. S.name='Item'

Q 178.
Shailly writes the following commands with respect to a table Employee Having fields,empno,
Name ,department, commission.
Command1:SELECT COUNT(*) FROM EMPLOYEE;
Command2:SELECT COUNT(COMMISSION) FROM EMPLOYEE;
She gets the output as7 for the first command but gets an output 5 for the second command.
Explain the output with justification.
Ans; This is because the column commission contains a NULL value and the Aggregate
functions do not take into account NULL values. Thus Command1 Returns the total number
of records in the table where as Command2 returns The total number of non NULL values
in the column commission.

Q179. What will be the output of the following commands in Mysql:


i (i) SELECT MID(‘INFORMATICS PRACTICES’, 3, 7);
ii (ii) SELECT REVERSE(‘STRING FUNCTION’);

Ans: (i) FORMATI


(ii) NOITCNUF GNIRTS

Q180. Priyansha writes the following commands with respect to a table ‘CABs’ having fields:
Cabno, CabName, Color, Capacity, Charges.
Command1: SELECT COUNT(COLOR) FROM CABS;
Command2: SELECT COUNT(DISTINCT COLOR) FROM CABS;
She gets the output as 4 for the first command but gets an output 3 for the second command.
Explain the output with justification.

Ans: The reason to get the different outputs in both the commands is that the column ‘COLOR’
in the table ‘CABS’ has a duplicate value.

Q181. Consider the following SQL string : ‘Examination’


Write commands to display:
a. ‘min’
b. ‘nation’

Ans:(a) SELECT MID(‘EXAMINATION’,4,3);


(b) SELECT MID(‘EXAMINATION’,6,6);
Q182. Consider the same string ‘Examination’
Write SQL commands to display:
a. The position of the substring ‘min’ in the string ‘Examination’
b. The last 5 letters of the string

Ans:(a) SELECT INSTR(‘EXAMINATION’,’MIN’);


(b) SELECT RIGHT(‘EXAMINATION’,5);

Q183. Expand the following terms related to Computer Networks:


a. ARPANET b. ISP c. TCP/IP d. URL
Ans.
(a) Advanced Research Project Agency Network
(b) Internet Service Provider
(c) Transmission Control Protocol / Internet Protocol
(d) Uniform Resource Locator
Q184. Ankita received an SMS, from her bank querying a recent transaction asking her pin
number. Answer the following questions as what she should do upon receiving the SMS:
a. Should she SMS her pin number to the given contact number?
b. Should she call the bank helpline number to recheck the validity of the SMS
received?
Ans: a. No because there is an absolute chance of hacking her bank account, which can
result a huge
financial loss to her.
b. She should definitely call bank helpline number to recheck the validity of the SMS
received.
Q185.

Q186.
Consider a given Series , Subject:

INDEX MARKS

ENGLISH 75

HINDI 78

MATHS 82

SCIENCE 86
Write a program in Python Pandas to create this series.

Ans. import pandas as pd


subject=pd.Series(*75,78,82,86+,index=*'ENGLISH','HINDI','MATHS',’SCIENCE’+

Q187. What is the difference between the where and having clause when used
along with the select statement? Explain with an example.

Ans.
WHERE Clause:
WHERE Clause is used to filter the records from the table or used while joining more than one
table.Only those records will be extracted who are satisfying the specified condition in WHERE
clause. It can be used with SELECT, UPDATE, DELETE statements

SELECT S_Name, Age FROM Student WHERE Age >=18;


HAVING Clause:
HAVING Clause is used to filter the records from the groups based on the given condition in the
HAVING Clause. Those groups who will satisfy the given condition will appear in the final result.
HAVING Clause can only be used
with SELECT statement.
SELECT Age, COUNT(Roll_No) AS No_of_Students FROM Student GROUP BY Age HAVING
COUNT(Roll_No) > 1
Q188. State any two differences between CHAR and VARCHAR.

Ans. CHAR is fixed length and VARCHAR is variable length. CHAR always uses the same
amount of storage space per entry, while VARCHAR only uses the amount necessary to
store the actual text. The char is a fixed-length character data type, the varchar is a variable-
length character data type.

Q189. Consider the decimal number x with value 3875.4897. Write commands in SQL to:

i. Round it off 3 places after the decimal


ii. Round it to 3 places before the decimal.

Ans. i. select round(3875.4897,3);


ii.select round(3875.4897,-3);

Q190. Consider the following Series object, “company” and its profit in Crores.

TCS 300
RELIANCE 200
L&T 800
WIPRO 150
i. Write the command which will display the name of the company having profit>250.
ii. Write the command to name the series as Profit.
Ans. i. print(company[company>250])
ii company.name= 'Profit'

Q191. Mr. Sharma writes the following commands with respect to a table department having
fields, deptno, dept_name, head_of_department, manager.
Command1 : Select count(*) from department;
Command2: Select count(manager) from department;
He gets the output as 8 for the first command but gets an output 6 for the second command.
Explain the output with justification

Ans. This is because the column manager contains a NULL value and the aggregate functions do
not take into account NULL values. Thus Command1 returns the total number of records in the
table whereas Command2 returns the total number of non NULL values in the column manager.

Q192. Consider the following SQL string: “Informatics Practices” Write commands to display
a. “Practices”
b. “matics

Ans. a. select substr("Informatics-Practices", 13); or


select substring("Informatics-Practices",13); or
select mid("Informatics-Practices",13); or
select right("Informatics-Practices", 9);

b. select substr("Informatics-Practices" ,6,6); or


select substring("Informatics-Practices", 6,6); or
select mid(("Informatics-Practices" ,6,6);
OR
select instr('Computer' ,'ter);
select left('Computer',4);

Q193. Expand the following terms related to Computer Networks


a. PPP
b. HTTPS
c. VoIP
d. PAN

Ans.
a. PPP: Point to Point Protocol
b. HTTPs: Hyper Text Transfer Protocol secured
c. VoIP: Voice over Internet Protocol
d. PAN: Personal Area Network

Q194. Mr. Amit Mishra is using his internet connection for checking the online account of
company’s admin without his knowledge. What do we call this type of activity? What are the ways
by which we can avoid such type of activities?

Ans. We call this type of activity as Eavesdropping Precautions we can take in this :
a. Alert employees
b. Round the clock control over physical access by outsiders to the area to be protected
c. Continuous supervision/observation of all service personnel allowed into the area for repairs or
to make alterations
d. Thorough inspection by a qualified technical counter measures specialist of all new furnishings,
decorations, or equipment brought into the area.
Q195. Find out the error in the following SQL command and correct the same.
Select * from employee group by dept where sum(salary) > 2000000
Ans. instead of where having clause.

Q196. There is a table student having total number of rows /records is 50. The following command
giving 48 as output. What is the reason behind this? Explain
Select count(commission) from employee
Ans. Total record is 50. But commission field is having 48 values. Two values are NULL values.
Hence result is showing 48.

Q 197. Consider the following Series object, s


IP 95
Physics 89
Chemistry 92
Math 95

i. Write the Python syntax which will display only IP.


ii Write the Python syntax to increase marks of all subjects by 10.

Ans. i) print(s['IP'])
ii) s=s+10
print(s)

Q198. Jeet has to prepare a project on “Swachh Bharat Abhiyan”. He decides to gather
information from the internet He downloads three Web pages (Webpage1, Webpage2,
Webpage3) containing information on Swachh Bharat Mission. Answer the following
questions in relation to this
A. What kind of Cyber Crime can it be considered?
B. Which step should Jeet have avoided doing to avoid committing a Cyber Crime?

Ans. a. Plagiarism
b Either he should not have copied as it is or he could have given reference of the specific
webpages from where he copied.

Q199. Rakesh went to an ATM Machine to withdraw some cash. He noticed a suspicious person
standing right behind him. Answer the following questions in relation to this.

a. What would you suggest Rakesh to do in such a situation?


b. Is the security of the account of Rakesh compromised in this situation?

Ans. a. Rakesh should ask the person to stand away


b. Yes

Q200. Consider the string STR with value as “KENDRIYA VIDYALAYA”. Write command in
SQL to:
a. Print the last 4 characters of the string STR.
b. Display the count of characters in the string STR

Ans. a. SELECT RIGHT(STR,4) or


b. SELECT LENGTH(STR)

OR
a. . SELECT LCASE(STR) or SELECT LOWER(STR)
b. SELECT INSTR(STR,’RIYA’);

Q201 Consider the string STR with value as “KENDRIYA VIDYALAYA”. Write command in
SQL to:
a. Convert the complete string into lower case.
b. Find the Position of the word “RIYA” in the string.

Ans. a. SELECT SUBSTRING(STR,-4)


b. SELECT LOWER(STR)

3 MARKS QUESTIONS

Q202. Consider the following graph. Write a program in python to draw it along with proper
labeling of X-axis, Y-axis and Title for the line Chart of your choice

Ans.
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(-2, 2,50)
y=x*x
plt.plot( x,y)
plt.title(“Y = x * x”)
plt.xlabel(“X-Axis”)
plt.ylabel(“Y-Axis”)
plt.show()
Q203. Consider the following graph. Write a program in python to draw it. (Height of Bars are
10,1,0,33,6,8)
Ans. import numpy as np
import matplotlib.pyplot at plt
plt.hist([0,10,20,30,40,50],bins=[0,10,20,30,40,50,60],
weights=*10,1,0,33,6,8+,color=;red’, edgecolor=’yellow’)
plt.title(“Histogram of Student Data’)
plt.xlabel(“value”)
plt.ylabel(“Frequency”)
plt.show()

Q 204. Consider a Series object ‘ABC’, created using following statement:


ABC=pd.Series([11,23,31,61,87,93], index=*‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’+)
Based on the Series object, Answer the following
a. Retrieve and print the last two elements
b. What will be the output of the command : print(ABC**‘b’, ‘d’, ‘f’++)
c. Print the series in reverse order.

Ans. a. Print(ABC[-2 : ])
b.
b 23
d 61
f 93
c. print(ABC[-1: :-1])

Q205. Sudhir once opened an unknown website and entered his personal details such as Email
ID, Password, Bank Account Number etc. Now he has noticed his Email Inbox being flooded
with useless mails from that Site. In relation to this, answer the following questions:
a. What kind of Cyber Threat is this?
b. Give justification to your answer in part-1.

Ans. a. Spamming
b. It is because, the spammers where he entered his personal email IDs and credentials are
now flooding his mail box with useless or spam files.

Q206. Mandeep has received a phone call from a company, named XYZ Ltd. claiming that
Mandeep has won Rs. 10 lakhs in a lottery. The other person is seeking some security
questions from Mandeep for his verification, like his name, date of birth, account number,
IFSC Code, Phone number, OTP etc. In relation to this, kindly answer the following

questions:
a. Should Mandeep give his details being asked?
b. Give reasons for your answer in part-1

Ans. a. No
b. The other person is trying to ask credential information like OTP etc, which should never be
shared with anyone.
Q207.

Ans. a. SELECT BRAND, SUM(PRICE) FROM APPLIANCES GROUP BY BRAND; b.SELECT


SUM(QUANTITY) FROM APPLIANCES WHERE APPLIANCE_NAME=’TELEVISION’;
c. SELECT BRAND, APPLIANCE_NAME, MAX(DISCOUNT) FROM APPLIANCES;

Q208. What do you mean by Plagiarism? Explain with the help of an example?

Ans. Plagiarism is the representation of another author's language, thoughts, ideas, or


expressions as one's own original work.

Q209. Consider two objects a and b


a is a list whereas b is a Series. Both have values 10,20,25,50. What will be the output of the
following two statements considering that the above objects have been created already
a. print(a*2)
b. print(b*2)
Justify your answer.
Ans. a. will give the output as:
[10,20,25,50,10,20,25,50]
b. will give the output as
0 20
1 40
2 50
3 100
Justification:
In the first statement a represents a list so when a list is multiplied by a number, it is replicated
that many number of times.
The second b represents a series. When a series is multiplied by a value, then each element of
the series is multiplied by that number.

Q210. What do you mean by Phishing? Explain with the help of an example.

Ans. Phishing is a type of social engineering attack often used to steal user data, including
login credentials and credit card numbers.
Example:
URGENT REQUEST (Email Impersonation)
These are targeted and simple forms of phishing emails designed to get victims to purchase
gift cards, or to give up personal email or phone numbers. The "email compromise" gets its
name because the attacker mimics the email of a known sender.

Q211. List any two health hazards related to excessive use of Technology.
Ans. The continuous use of devices like smartphones, computer desktop, laptops, head
phones etc cause a lot of health hazards if not addressed. These are:
i. Impact on bones and joints: wrong posture or long hours of sitting in an uncomfortable
position can cause muscle or bone injury.
ii. Impact on hearing: using headphones or earphones for a prolonged time and on high
volume can cause hearing problems and in severe cases hearing impairments.
iii. Impact on eyes: This is the most common form of health hazard as prolonged hours of
screen time can lead to extreme strain in the eyes.
iv. Sleep problem: Bright light from computer devices block a hormone called melatonin which
helps us sleep. Thus we can experience sleep disorders leading to short sleep cycles

Q212. Consider the following graph. Write the code to plot it.

Ans. import matplotlib.pyplot as plt


a = [0,1,2,3,4,5]
b = [10,31,26,24,20]
plt.plot(a,b)
plt.show()

Q213. Write code to draw the following bar graph representing the number of
students in each class.

Ans. import matplotlib.pyplot as plt


Classes = ['VII','VIII','IX','X']
Students = [40,45,35,44]
plt.barh(classes, students)
plt.show()
Q. 214

Ans.
a. select company, avg(Price) from toys group by company having Qty>15;
b. select Company, count(distinct name) from toys group by Company;
c. Select name, sum(Price* Qty) from toys;

Q 215. Predict the output of the following code.


data = {'one':'a','two':'b','three':'c'}
s=pd.Series(data)
print(s)
print(s.size)
Ans. one a
two b
three c
dtype:
object 3

Q216.
Ans. x = emp_df['Name']
y = emp_df['Age']
pl.plot(x,y)
pl.xlabel("Name")
pl.ylabel("Age")
pl.title("Name vs Age")
pl.show()
Qus 217. Write a Python code to display a bar graph with names on x-axis and salary on y-axis.
Give appropriate names for axis and title for the graph.
Ans. 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()

Qus 218.

Ans. (i) SELECT MAX(PROD_QTY) FROM product;


(ii) SELECT PROD_PRICE*PROD_QTY AS ‘Value’ FROM product;
(iii) SELECT AVG(PROD_PRICE) FROM product;
Qus 219.

Ans.
Q 220. Consider the commands below:
>>> import pandas as pd
>>> lst=[10,20]
>>> ds=pd.Series([10,20])
Here lst is a list and ds is a series. Both have same values 10 and 20. What will be the output of
the following commands. Justify your answer.
a. print ( lst * 2 )
b. print ( ds * 2 )

Ans. a. [10,20,10,20] – Replication


b. [20,40] - Multiplication

Q 221.
What do you mean by Digital property Rights? How can digital property rights be threatened.
Ans. Digital property rights represent the next generation of intellectual property rights,
which puts them on the same playing field as patents, copyrights and trademark brands.
... Digital property rights disputes arise when some form of counterfeiting or piracy occurs
between companies.

Q222. What is Online fraud? Give some measures to stop online frauds.
Ans.
internet fraud or online fraud is a type of cybercrime fraud or deception which makes use of
the Internet and could involve hiding of information or providing incorrect information
 Do not open unsolicited attachments, they can be phishing emails.
 Keep pass-phrases instead of passwords. ...
 Do have an eye on headers of the email to see if the email is coming from any non-genuine
domain.

Q223. Write a code to plot the Monthly Attendance of students in class as shown in the
figure given below:

Ans.
import matplotlib.pyplot as plt
months = *‘jan’,’feb’,’mar’,’apr’,’may’,’jun’+
attd=[30,50,50,30,30,60]
plt.plot(attd,months)
plt.title(‘Monthly Attendance’)
plt.show()
Q 224.
Draw a bar chart as below representing the number of students in each class.
Student Strength

Ans. import matplotlib.pyplot as plt


Classes = ['VII','VIII','IX','X']
Students = [40,45,35,44]
plt.bar(classes, students)
plt.title(‘Student Strength’)
plt.show()

5 MARKS QUESTIONS

Qus 225.
Consider the following two series:
ser1=pd.Series([2,5,7,9,6], index=['A','B','C','D','E'])
ser2=pd.Series([8,2,6,3,9], index=['A','K','D','M','E'])

Write Python statements to perform the following operations.


a .Add ser1 to ser2
b. Add ser2 to ser1 filling missing indexes with value 10.
c. Subtract ser1 from ser2
d. Subtract ser2 from ser1 filling missing indexes with value 5.
e. Multiply ser1 with ser2
f. Multiply ser2 with ser1 filling missing index values with 0
g. Divide ser1 by ser2
h. Divide ser2 by ser1 filling missing index values with 5.

Ans. import pandas as pd


ser1=pd.Series([2,5,7,9,6], index=['A','B','C','D','E'])
ser2=pd.Series([8,2,6,3,9], index=['A','K','D','M','E'])
a. Print(ser1+ser2)
b. print(ser2.add(ser1,fill_value=10))
c. print(ser2-ser1)
d. print(ser2.sub(ser1,fill_value=5)
e. print(ser1*ser2)
f. print(ser2.mul(ser1,fill_value=0)
g. print(ser1/ser2)
h. print(ser2.div(ser1,fill_value=5)
Q226 Write a program in Python Pandas to create the following DataFrame
toppers from a Dictionary

T_NO Name PB1 PB2


1 Pavan 90 80
2 Sugandha 85 75
3 Pulkita 70 72
4 Sahil 69 71
Perform the following operations on the DataFrame :
1. Add both the marks from PB1 and PB2 of a student and assign to column “Final”
2. Display the highest marks in both PB1 and PB2 of the DataFrame.
3. Display the DataFrame.

Ans. import pandas as pd


d1={'T_NO':[1,2,3,4], 'Name':["Pavan","Pulkita","Sugandha","Sahil"],'PB1':[90,85,
70,69], 'PB2':[80,75,72,71]}
toppers=pd.DataFrame(d1)
print(toppers)
toppers['Final'] = toppers['PB1']+ toppers ['PB2']
print("Maximum scores are : " , max(toppers['PB1']), max(toppers['PB2']))

Q227. Write the SQL functions which will perform the following operations
i) To display the name of the day of the current date.
ii) To remove spaces from the beginning of a string, “ Python”.
iii) To display the name of the month eg, January or February from your date of birth.
iv)To display the starting position of word “Information” from
v)To compute the power of two numbers a and b

Ans.
i) dayname(date(curdate()))
ii) ltrim(“ Python“)
iii) monthname(date(dob))
iv) instr(“Information
Technology”,”information”)
v) pow(a,b)

Q228.
Ans. i) Select ename, round(bonus,0) from employee;
ii) Select instr(ename, “ee”) from employee;
iii)Select mid(ename,2,4) from employee;
or
iii) Select Substring(ename,2,4) from employee;
iv) Select dayname(DateofJoin) from employee;
v) Select monthname(DateofJoin) from employee;

Qus. 229. company in Cyntel Enterprises has 4 departments of buildings as shown in the
diagram :

Research
Research

Corporate Developer Unit


Office

Center to center distances between various Buildings:


Research to Back Office - 50m
Back Office to Developer Unit - 60m
Developer Unit to Corporate Office - 25m
Corporate Office to Research - 170m
Research to Developer Unit - 125m
Back Office to w4 - 90m

Number of computers in each of the department:


Back Office - 150
Developer Unit - 15
Research -15
Corporate Office – 25

Computers in each department are networked but departments are not networked
The company has now decided to connect the departments also.

i. Suggest a most suitable cable layout for the above connections.


ii. Suggest the most appropriate topology of the connection between the
departments.
iii. The company wants internet accessibility in all the departments. Suggest a
suitable technology.
iv. Suggest the placement of the following devices with justification if the
company wants minimized network traffic
a) Repeater
b) Hub /switch
v. 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.
Ans. (i) Most suitable layout according to distance is :

(ii) Star Topology


(iii) Broadband.
(iv). a. Not required. Repeaters may be skipped as per above
layout (because distance is less than 100 m)
b. In every win
(v) Radio Waves

Q230.
Write a program in Python Pandas to create the following DataFrame Stationary from
Series:

P_ID PROD_NAME PROD_PRICE PROD_QTY


P01 Notebook 85 500
P02 Pencil Box 76 200
P03 Water Bottle 129 50
P04 School Bag 739 70

Perform the following operations on the DataFrame :


a. Transfer the Dataframe to a csv file named “final.csv”.
b. Add a column discount with value of 5% for all items in the DataFrame at the
Position 1.
c. Display the final Dataframe updated.

Ans. import pandas as pd


data=, ‘P_ID’:*‘P01’, ‘P02’, ‘P03’, ‘P04’+, ‘PROD_NAME’: *‘Notebook’, ‘Pencil Box’,’Water
Bottle’, ‘School Bag’+, ‘PROD_PRICE’ : *85,76,129,739+,’PROD_QTY’: *500,200,50,70+ -
df=pd.DataFrame(data, columns=*‘P_ID’, ‘PROD_NAME’, ‘PROD_PRICE’,’PROD_QTY’+)
print(df)
a. df.to_csv (r'final.csv', index = False, header=True)
b. df.insert(0, ’DISCOUNT’, 5)
or
x=[5,5,5,5]
df*‘DISCOUNT’+=x
print(df)
Qus 231

Write the SQL functions which will perform the following operations:
Display the string “chest” from the string “ Manchester United”
Display the word “hello” from the string “$$$$$$$hello$$$$$$$$”.
To display the name of the month eg, January or February from the current
date.
Write the Output that will be generated by the SQL commands:
SELECT SYSDATE();
SELECT INSTR(“HELLO WORLD”, “he”)
Ans.
i. SELECT SUBSTRING(“ Manchester United”, 4,5) or any other valid syntax
ii. SELECT TRIM (BOTH ‘$’ FROM “$$$$$$$hello$$$$$$$$”)
iii. SELECT MONTHNAME(NOW()) or any other valid syntax
iv. Todays Data and Time in ‘YYYY-MM-DD HH:MM:SS’ format
v. 1
Q 232.

Ans.
a) SELECT PNAME, PRICE FROM CLOTHING WHERE BRAND=”RAYMOND”;
b) SELECT SUM(QUANTITY) FROM CLOTHING WHERE PNAME=’REGULAR SHIRT’;
c) SELECT MAX(PRICE), MIN(PRICE) FROM CLOTHING;
d) SELECT COUNT(*) FROM CLOTHING GROUP BY BRAND HAVNING COUNT(*)>10;
e) SELECT * FROM CLOTHING ORDER BY PRICE DSC;
Q233.

Ans.

i. If star then keeping IT Block as Hub and if LAN then ADM->IT->HR->ACCTS or any
other feasible and economical
ii. IT Block as it has maximum number of computer
iii. a) Repeater : In between all blocks which have distance over 100 Meter
b) Hub / switch : In all blocks as to connect all systems to the main line of network
iv. Firewall
v. Radio waves can be used in hilly regions as they can travel through obstacles.

Q234.
Ans.
import pandas as pd
d1={'DeptId':[10,20,30,40],'DeptName':['Sales','Purchase','Personnel','Research'],
'Income':[85660,86780,87600,89990],'Location':['New Delhi','Kolkata','Haryana','Begaluru']}
DEPT=pd.DataFrame(d1)
print('Highest salary ',max(DEPT.Income))
DEPT['Commission']=DEPT.Income * 0.15
print(DEPT)

Qus 235.

Ans.
a. SELECT * FROM STORE ORDER BY LASTBUY;
b. SELECT ITEMNO, ITEMNAME FROM STORE WHERE RATE > 15;
c. SELECT * FROM STORE WHERE SCODE=22 OR QTY > 110;
d. SELECT SCODE, MIN(RATE) FROM STORE GROUP BY SCODE;
e. UPDATE STORE SET RATE=RATE+10;
Qus 236.

i. What type of network will be formed if all blocks are connected?


ii. Suggest the most suitable place (i.e. Block) to house the server of this organization with a
suitable reason.
iii. Suggest the placement of the following devices with justification. (a) Repeater (b) Hub /
Switch
iv. The organization is planning to link its front office situated in the city in a hilly region where
cable connection is not feasible, suggest an economic way to connect way to connect it with
reasonably high speed.
v. Which type of network will it form

Ans. a. Can be any suitable suggestion


b. Main Buiding
c. Switch/Hub: In all the buildings
Repeater: Not required
d. Optical Fibre
e. WAN

Qus 237. Write the name of the SQL functions which will perform the following operations :-
i. To display the current system Date.
ii. To display the year of a given date.
iii. To extract the substring from a given string.
iv. To calculate the power of a number
v. To combine two strings
Ans.
i. Select now();
ii. Select date of year(date);
iii. Select mid or substr(“string”);
iv. Select pow();
v. Select concat(“string”)

Qus 238.

Ans. a. Select * from store order by LastBuy;


b.Select ItemNo,Item from store where Rate>15;
c. Select item from store where scode =22 or Qty >110;
d. Select min(rate) from store group by Scode;
e. Select Qty*Rate from store as”Stock Values”;

Qus 239.

As a network expert, provide the best possible answer for the following queries:
i Suggest a cable layout of connections between the buildings.
ii Suggest the most suitable place (i.e. buildings) to house the server of this organization.
iii) Suggest the placement of the following device with justification:
a) Repeater b) Hub/Switch
iv) Suggest a system (hardware/software) to prevent unauthorized access to or from the
network.
v) The company is planning to link its head office situated in Delhi with the offices in hilly
areas. Suggest a way to connect it economically.
Ans.
i.) Any best layout
ii.) Research Lab
iii.) a. Not required b. Reasearch Lab
iv.) Firewall
v.) WAN/ Satellite

Qus 240. Consider the following table automobile and answer the follwing

Ans. a. Select company, round(wheel-base,1) from automobile ;


b. Select instr(body-style,”dan”) from automobile;
c. Select mid(company,2,3) from automobile;
d. Select year(Dateofmanufacture) from automobile;
e. Select dayname( Dateofmanufacture) from manufacture;

Qus 241. Write the SQL functions which will perform the following operations

Ans. (i)select month(current_date());


(ii)select trim(“KVSangathan “);
(iii)select dayname(dob)from student;
(iv)select round(sqrt(2),2);
(v)select n1%n2;
Qus 242.

Ans. i. Select * from KV where StationCode Between 300 and 500;


ii. Select * from KV where KVName like ‘%AFS”;
iii. Select * from KV where Region=”Jaipur”;
iv. Select Zone, count(KVName) from KV group by Zone;
v. Region Count(KVName)
Jaipur 3
Ahemdabad 2

Q243. Consider the following table BOOKS and ISSUED and answers the following.
Ans. (i) Select Book_Name from Books where Type = “Text”;
(ii) Select Book_Name, Price from Books order by Price;
(iii) Update Books set price = price+50 where publishers = “EPB”;
(iv) Select Book_Name, Book_ID, Quantity Issued from Books, Issued where
Books.Book_ID=
Issued.Book_ID;
(v) Insert into issued values(“F0003”,1);

Qus 245.

Ans. (i) SELECT LEFT(DESCRIPTION,3) FROM CLOTH;


(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;
Qus 246.

Ans.
Ans. import pandas as pd
housing_df = pd.read_csv("housing.csv")
print(housing_df)
print(housing_df[housing_df.loc[:,'bath']==2])
print(housing_df.loc[:,'price']*100000)
print(housing_df.head(3))

Q 248.
Write a program in Python Pandas to create the following DataFrame batsman from a
Dictionary:
B_NO Name Scorel Score2
I Sunil Pillai 90 8O
2 Gaurav Sharma 65 45
3 Piyush Goel 70 90
4 Kartik Thakur 80 76
Perform the following operations of the DataFrame:
(a) Add both the scores of a batsman and assign to column "Total".
(b) Display the highest score in both Scorel and Score2 of the DataFrame.
(c) Display the DataFrame.

Ans. import pandas as pd


D1=(‘B_No’:*‘Name’:*“SunilPillai”,”GauravSharma”,”PiyushGoel”,”Kartik
Thakur”+,’Score1’:*90,65,70,80+,’Score2’:*80,45,95,76+-
df =pd.DataFrame(D1)
print(df)
a. df*‘Total’+=df*‘Score1’++df*‘Score2’+ or df*‘Total’+=sum(df*‘Score1’+,df*‘Score2’+)
b. print(‘Maximum scores are”,max(df*‘Score1’+),max(df*‘Score2’+))
c. print(df)
Q249.
Write the SQL functions which will perform the following operations:
(a) To display the name of the month of the current date.
(b) To remove spaces from the beginning and end of a string, " Panorama ".
(c) To display the name of the day eg, Friday or Sunday from your date of birth dob. (
(d) To display the starting position of your firstname (fname) from your wholename (name).
(e) To compute the remainder of division between two numbers, n1 and n2.

Ans.(a.) Select monthname(date(now()));


(b.) Select trim(“ panorama ”);
(c.) Select dayname(date(dob));
(d.) Select instr(name,fname);
(e.) Select mod(n1,n2);

Q250. Give the SQL functions which will perform the following operations:
(a) To display the year of the current date.
(b) To display the ASCII value of "DELHI".
(c) To display the middle name from your full name (NAME). For example: ("ANIL KUMAR
SINGH". "KUMAR").
(d) To display the position of your last name(LNAME) from your whole name (name).
(e) To display the average marks which are up to 2 decimal places as a whole number.
(average marks can be of any value)

Ans. a.) Select year(curdate());


b.) Select ASCII(“DELHI”);
c.) Select substr(Name,6,5);
d.) Select instr(name,”KUMAR”);
e.) Select round(average_marks);

MR PAWAN KAPOR
PGT & HOD COMPUTER
VARDHMAN ACADEMY
RAILWAY ROAD MEERUT

You might also like