0% found this document useful (0 votes)
96 views26 pages

Practice Questions Ip 12

Here are the answers to the fill in the blanks questions: 22. row-major 23. ndarray 24. Series 25. 1 26. NumPy 27. plot True /False Questions 1. NumPy supports vector and matrix operations. 2. NumPy arrays have fixed size once created. 3. NumPy is a scientific computing library. 4. Pandas is used for data analysis and manipulation. 5. Matplotlib is used for data visualization. True/False Answers 1. True 2. False 3. True 4. True 5. True VERY SHORT ANSWER QUESTIONS 1. What is NumPy? NumPy is a

Uploaded by

allyourneeds8682
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)
96 views26 pages

Practice Questions Ip 12

Here are the answers to the fill in the blanks questions: 22. row-major 23. ndarray 24. Series 25. 1 26. NumPy 27. plot True /False Questions 1. NumPy supports vector and matrix operations. 2. NumPy arrays have fixed size once created. 3. NumPy is a scientific computing library. 4. Pandas is used for data analysis and manipulation. 5. Matplotlib is used for data visualization. True/False Answers 1. True 2. False 3. True 4. True 5. True VERY SHORT ANSWER QUESTIONS 1. What is NumPy? NumPy is a

Uploaded by

allyourneeds8682
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/ 26

Table of Contents

Unit-I : Data Handling ...................................................................................... 3


Chapter 1 :Working with Numpy .................................................................................... 3
TYPE A : OBJECTIVE TYPE QUESTIONS : [ 1 MARK] .............................................................................................. 3
Multiple Choice Questions .................................................................................................................................... 3
Answers to Multiple Choice Questions .............................................................................................. 4
Fill in the blanks ................................................................................................................................. 5
Answers to Fill in Blanks ..................................................................................................................... 5
True /False Questions ....................................................................................................................... 5
True/False Answers ............................................................................................................................ 5
VERY SHORT ANSWER QUESTIONS .................................................................................................... 5
SHORT ANSWER QUESTIONS [2,3 Marks] ..................................................................................... 7
Chapter 2 : Python Pandas ........................................................................................... 13
Multiple Choice Questions ................................................................................................................................. 13
Short Answer Questions ..................................................................................................................................... 13

Chapter : 3 Plotting with Pyplot I & II ........................................................................... 15


Multiple Choice Questions ................................................................................................................................. 15
Short Answer Questions ..................................................................................................................................... 15

UNIT-2 : DBMS ................................................................................................ 17


Chapater 4 : Database Query Using SQL........................................................................ 17
Multiple Choice Questions ................................................................................................................................. 17
Short Answer Type Questions ............................................................................................................................ 18
Questions based on Application: ........................................................................................................................ 19

Unit 3: Networking Concepts .......................................................................... 23


Chapter 5 : Networking Concepts ................................................................................. 23
Expand the following abbreviations: .................................................................................................................. 23
FILL IN THE BLANKS:............................................................................................................................................ 23
Very Short Answer Question .............................................................................................................................. 25

UNIT 4 -SOCIETAL IMPACTS ............................................................................ 26


Chapter 6 : Societal Impacts .......................................................................................... 26
Very Short Answer(VSA) (1 mark)....................................................................................................................... 26
Short Answer-I(SA-I) (2 marks) ........................................................................................................................... 27

2
Unit-I : Data Handling
Sh. Rajesh Kushwaha, PGT-CS, KV Jayant
Chapter 1 :Working with Numpy
TYPE A : OBJECTIVE TYPE QUESTIONS : [ 1 MARK]

Multiple Choice Questions

1. A Python package which stands for ‘Numerical Python ‘ is named and used as …………….. in Python
programs :
a) SciPy b) Pandas c) NumPy d) pyplot

2. A NumPy array’s dimensions are known as …………………….


a) ndimension b)dimensions c) axes d) array

3. To create an ndarray from a Python List , which of the following functions would you use ?
a) NumPy.reshape() b) numPy.reshape() c) NumPy.array() d) numpy.array()

4. Which of the following can store different types of element in them ?


a) List b) ndarray c) tuple d) dataframe

5. Which of the given types support vectorized operations ?


a) list b) ndarray c) string d) tuple

6. To generate a NumPy array from given limits and number of elements required, . . . . . . method.
a) numpy.array() b) numpy.linspace() c) numpy.arange() d) numpy.ndarray()

7. ……….. is a process of extracting a subset of elements from an existing ndarray and returning the
result as another ndarray
a) Array cutting b)Array slicing c) Subset extraction d) None of these

Note Given an ndarray Ar as array([2,4,6,8,10,12,14,16]),questions 8 to 10 are based on :

8. array ([8,10,12,14]) is the result of array slice ……………………..


a) Ar[3:7] b)Ar[:5] c)Ar[:7] d)Ar[:-3]

9. array([10,12,14,16]) is the result of array slice ………….


a) Art[: 5] b) Ar[4:7] c) Ar[4 : ] d)Ar[4:8]

10. Ar[ : -3] will produce the result as…………………..


a)array([2,4,6,8]) b)array([2,46,8,10])
c) array([2,4,6,8,10,12]) d) array([2,6,10,14])

NOTE : Given a 2D ndarray Ary as


array([2,4,6,8,10],
3
[12,14,16,18,20],
[22,24,26,28,30]
[32,34,36,38,40]
Questions 11 and 12 are based on this array .

11. Ary[1:3, 3:5] will produce the result as …………….


a) array([[18,20], [28,30]]) b)array([[18,10], [18,20]])
b) c) array([[18,20], [38,40]]) d) array([[28,30], [38,40]])

12. array ([8,18,28,38]) is the result of array slice ………..


a) Ary[3, ] b) Ary[ :, 3] c) Ary[ 2, ] d) Ary[: , -2]

13. To vertically combine multiple ndarrays , which of the following functions may be used ?
a) hstack() b)vstack() c)concatenate() d)combine()

14. To get non-contiguous subsets from an ndarray based on a condition, which function(s) may be
used ?
a) hsplit() b)vsplit() c)split() d)extract()

15. From an ndarray numpy.arange(9.0), how many different shaped arrays can be created using
reshape()?
a)1 b)2 c)3 d)4

16. To obtain correlation coefficient ,which of the following functions may be used ?
a)corrcoef b)cov() c) covariance() d) All of these

17. To exact row/column from a dataframe,…………… function may be used .


a) row () b)column() c) ndim d)shape

18. Which of the below given Pandas functions can be used for pivoting ?
a) pivot() b)pivoting() c)pivot_table() d)pivot_report()

19. Which of the following plotting functions does not plot multiple data series ?
a)plot() b)bar() c)pie() d)barh()

20. A……….. is a summarisation tool for discrete or continuous data


a) quartile b)histogram c)mean d)median

21. A visual representation of the statistical five number summary of a given dataset is known as ……..
a) histogram b)frequency distribution c)boxplot d)frequency polygon

22. Which of the following returns an array of ones with the same shape and type as a given array ?
(a) all_like (b) ones_like (c) one_alike (d) all of the mentioned

23. If data is an ndarray , index must be the same length as data


(a) True (b) False

Answers to Multiple Choice Questions


1. (c) 2. (c) 3. (d ) 4. ( a),(c),(d) 5. (b ) 6. (b ) 7. (b)
8. (a) 9. (c),(d) 10. (b) 11. (a) 12. (b),(d) 13. (b),(c)
4
14. (d ) 15. (c) 16. (a) 7. (c) 18. (a ) 19. (c)
20. (b ) 21. (c )

Fill in the blanks


22. When a 2D array’s elements are stored row-wise linearly ,it is called ……….. format
23. The range() function returns an iterator/sequence ,while arrange() function returns a(n)…….
24. A ……… is a Pandas data structure that represents a 1D array like object
25. To calculate statistical values for each row, the axis argument should be ……..
26. Python interface is a collection of methods within ………….. library of Python
27. Pyplot’s …………… function is used to create scatter charts
28. Pyplot’s ………… function is used to create histogram

Answers to Fill in Blanks


22. row-major 23. ndarray or NumPy array 24. Series
25. 0 26. Matplotlib 27. Scatter() 28. hist()

True /False Questions


29. Two dimensional arrays are internally stored in linearized fashion in memory
30. Functions range() and arrange() are essentially the same
31. A Dataframe object is value mutable
32. The pivot() function can perform pivoting even with duplicate entries
33. PyPlot is a sub-library of matplotlib library
34. A line chart can be plotted using pyplot library’s plot() function
35. A standard marker of representing a non number data in Python libraries is NaN.

True/False Answers
29. T 30. F 31. T 32. F 33. T 34. T 35. T

VERY SHORT ANSWER QUESTIONS


36. What will be the resultant array as per the statement given below ?
>>>np.arange(2,29,5)
Ans : array( [ 2, 7, 12, 17, 22, 27)

37. What is the relationship between the rank of an array and the shape of the array ?
Ans: The number of dimensions(axes) in an ndarray is known as its rank . A shape is a tuple that stores
the number of elements in each dimension of the ndarray. Thus the length (len()) of shape tuple
is same as that of rank of the ndarray.

38. What functions can you use for joining two or more ndarrays ?
Ans: hstack() , vstack() , concatenate()

39. Create a 4x4 ndarray having values ranging from 0 to 15 (both inclusive)
Ans. import numpy as np
Z=np.arange(16).reshape(4,4)
print(Z)

40. What will be the output produced by the following statement ?


>>>np.array{[2,7,12,17,22,27]).shape
5
Ans : (6,)

41. Find the output of the following program .


import numpy as np
d=np.array([10,20,30,40,50,60,70])
print( d[ -4: ] )
Ans : [ 40, 50, 60, 70]

42. Predict the output of the following code fragment :


x= [ 1, 2, 3,99,99,3,2,1)
x1,x2,x3=np.split(x ,[3,5])
print(x1,x2,x3)
Ans : [1 2 3] [99 99 ] [3 2 1]

43. What will be the output of the following code :


Cars ={ ‘Brand ‘ : [‘Kia Seltos’, ‘MG Hector’, ‘ Toyota fortuner’, ‘Mahindra XUV500’ ], ‘Price ‘:
[1000000,1200000,2700000,1400000] }
df1.=pd.DataFrame(Cars,columns =[ ‘ Brand’, ‘ Price’ ]}
print(df1)
Ans : Brand Price
0 Kia Seltos 1000000
1 MG Hector 1200000
2 Toyota Fortuner 2700000
3 Mahindra XUV500 1400000

44. Write a small python code to drop a row from dataframe labeled as 0
Ans : df=df.drop(0)
Print(df)

45. Create a histogram using dataframe ndf


Ans: ndf.hist()

46. What is the use of boxplot ?


Ans : Boxplots are a standardized way of displaying the distribution of data based on a five number
summary (“minimum”, first quartile(Q1),median , third quartile(Q3), and “ maximum”)

47. Define : i) axis ii) rank iii)shape iv) itemsize


48. What are array slices ?
49. Create an ndarray with values ranging from 10 to 49 each spaced with a difference of 3.
50. Consider the following ndarray Ary1:
array ([ [ 1,2,3],
[4,5,6]
[7,8,9]])
Write code to extract the subset from the ndarray Ary1, containing elements whose square is
fully divisible by 4

51. Write a Numpy program to computer sum of all elements ,sum of each column and sum of each
row of a given array

6
52. Write a NumPy program to create a 5x5 zero matrix with elements on the main diagonal equal to
1,2,3,4,5

53. Write a NumPy program to find common values between two arrays. Expected Output :
Array1: [0 10 20 40 60 ]
Array2: [ 10 , 30 , 40 ]
Common values between two arrays
[10,40]

54. Write a NumPy program to test if any of the elements of a given array is non-zero.
55. Write a NumPy program to extract all odd numbers from an array.
56. Write the difference between Covariance & Correlation .
57. Predict the output of the following code fragment :
x=[1, 2, 3, 99, 99, 3, 2, 1]
x1,x2,x3=np.split(x,[3,5])
print(x1, x2, x3)

58. Write code to create a 1D ndarray of size 10 with all elements as zero ,but the fifth element is 10
59. Given a list L= [3,4,5] and an ndarray N having elements 3,4,5. What will be the result produced
by:
a) L*3 ? b)N*3 c) L+L d) N+N

SHORT ANSWER QUESTIONS [2,3 Marks]

60. What will be the output of the following code :


import numpy as np
A=np.array([[11,12,13],[21,22,23],[31,32,33]])
B=np.ones((3,3))
print(“ Adding to arrays:”)
print (A+B)
print (“\nmultiplying two arrays :”)
print(A*(B+1))
Ans: Adding to arrays :
[ [12. 13. 14. ]
[22. 23. 24.]
[32. 33. 34.]]
Multiplying two arrays :
[ [22. 24. 26. ]
[42. 44. 46. ]
[62. 64. 66.] ]

61. What will be the output of the following code :


grid =np.arange(16).reshape((4,4))
upper,lower =np.vsplit(grid,[2])
print (1:”)
print (upper)
print(“2”)
print(lower)
Ans:
1:
[ [ 0 1 2 3]
7
[ 4 5 6 7]]

2:
[ [ 8 9 10 11]
[12 13 14 15]]

62. Consider the following ndarray Ary1:


Array ([ 1,2,3],
[4, 5, 6],
[7, 8, 9]])
Write code to extract the subset from the ndarray Ary1, containing elements whose square is
fully divisible by 4
Ans. import numpy as np
con = (Ary1**2)%4==0
np.extract(con,Ary1)

63. Predict the output of the following code fragments . Note library Numpy has been imported as
np.
a) x= np.array([1, 2, 3]) b) x=np.array( [1,2,3] )
y=np.array([3,2,1]) g=np.array( [ [9,8,7],
z=np.concatenate([x,y]) [6,5,4] ] )
print(z) R=np.vstack( [x,g] )
print (R)

Ans : a) [1 2 3 3 2] b) [ [ 1 2 3 ]
[9 8 7 ]
[6 5 4 ]

64. Write a Numpy program to create a 3x3 identity matrix, i.e , diagonal elements are 1 , the rest
are 0 . Replace all 0 to random number from 10 to 20.
Ans . import numpy as np
array1=np.identity(3)
print (array1)
x=np.where(array1==0)
for i in x :
array1[x] = np.random.randint(low=10,high=20)
print (array1)

65. Write a small python code to create dataframe with headings ( a and b) from the list given
below : [ [1,2],[3,4],[5,6],[7,8] ]
Ans : import pandas as pd
df = pd.DataFrame( [ [1,2], [3,4] ], columns = [‘a’ , ‘b’])
df2 = pd.DataFrame( [ [5,6], [7,8] ], columns = [‘a’ , ‘b’])
df= df.append(df2)

66. What is the difference between pivot() and pivot_table() functions ?

8
Ans . The pivot() and pivot_table() both perform data pivoting on the data set. But with pivot(), if there
are multiple entries for a columns value for the same values for index(row), it leads to error. The
pivot_table() pivots the data by aggregating it, thus it can work with duplicate entries.

67. What is the significance of data visualization ?


Ans : Data Visualization basically refers to the graphical or visual representation of information and data
using visual elements like charts ,graphs and maps etc. Data visualization is immensely useful in
decision making.

68. What is the use of matplotlib and pyplot ?


Ans : The matplotlib is a Python library that provides many interfaces and functionality for 2D -graphics
similar to MATLAB’s in various forms.
PyPlot is a collection of methods within matplotlib which allows user to construct 2D plots easily
and interactively . PyPlot essentially reproduces plotting functions and behavior of MATLAB.

69. Given a dataframe df1 as shown below :


1990 2000 2010
a 52 340 890
b 64 480 560
c 78 688 1102
d 94 766 889
Write the code to create :
a) A scatter chart from the 1990 and 2010 columns of dataframe df1
b) A line chart from the 1990 and 2000 columns of dataframe df1
c) Create a bar chart plotting the three columns of dataframe df1

Ans : a) plt.scatter(df1[1990], df1[2010])


b) plt.plot.(df1[1990], df1[2000])
c) x1 =np.arange(1,5)
plt.bar( x1, df1[1990], color=’r’, width=0.3 )
plt.bar( x1+0.3, df1[2000], color=’b’, width=0.3 )
plt.bar( x1+0.6, df1[2010], color=’g’, width=0.3 )

70. Consider the data given below: App Name App Price in Rs Total Downloads
Using the Above data, plot the
Angry Bird 75 197000
following:
Teen Titan 120 209000
a) A line chart depicting the
Marvel Comics 190 414000
prices of the apps
ColorMe 245 196000
b) A bar chart depicting the
Fun Run 550 272000
download of the apps
Crazy Taxi 55 311000
c) Converting the Est
Igram Pro 175 213000
downloads sequence that Wapp Pro 75 455000
has each download value Maths Formulas 140 278000
divided by 1000. Now
create a bar chart that plots multiple bars for prices as well as downloads.
Note: The chart should have proper titles for the charts, axes, legends etc.

Ans (a) import matplotlib.pyplot as plt


9
import numpy as np
AppName = ('Angry Bird', 'Teen Titan', 'Marvel Comics', 'ColorMe', 'Fun Run', 'Crazy Taxi',
'Igram Pro', 'Wapp Pro', 'Maths Formulas')
AppPrice = [75, 120, 190, 245, 550, 55, 175, 75, 140]
df2 = {'App Name':AppName, 'App Price':AppPrice}
plt.figure(figsize=(15,7))
plt.plot(df2['App Price'])
plt.title('App Price')
plt.xticks(np.arange(9),df2['App Name'])
plt.xlabel('App Names')
plt.ylabel('App Prices')
plt.show()

Ans (b) import matplotlib.pyplot as plt


import numpy as np
AppName = ('Angry Bird', 'Teen Titan', 'Marvel Comics', 'ColorMe', 'Fun Run', 'Crazy Taxi',
'Igram Pro', 'Wapp Pro', 'Maths Formulas')
TDownloads = [197000, 209000, 414000, 196000, 272000, 311000, 213000, 455000,
278000]
df2 = {'App Name':AppName, 'Total Downloads':TDownloads}
plt.figure(figsize=(15,7))
plt.bar(df2['App Name'],df2['Total Downloads'])
plt.title('Totla Downloads')
plt.xticks(np.arange(9),df2['App Name'])
plt.xlabel('App Names')
plt.ylabel('Downloads')
plt.show()

10
(c) import matplotlib.pyplot as plt
import numpy as np
AppName = ('Angry Bird', 'Teen Titan', 'Marvel Comics', 'ColorMe', 'Fun Run', 'Crazy Taxi', 'Igram
Pro', 'Wapp Pro', 'Maths Formulas')
TDownloads = [197000, 209000, 414000, 196000, 272000, 311000, 213000, 455000, 278000]
AppPrice = [75, 120, 190, 245, 550, 55, 175, 75, 140]
df2 = {'App Name':AppName, 'Total Downloads':TDownloads, 'App Price': AppPrice}
s = len(TDownloads)
est=[]
for i in range(s):
est.append(TDownloads[i]/1000)
x1 =np.arange(9)
x2 = x1 + 0.2
plt.figure(figsize = (15,7))
plt.bar(x1,df2['App Price'], width =0.2)
plt.bar(x2, est, color='r', width=0.2)
plt.title('Price vs Est')
plt.xticks(np.arange(9), df2['App Name'])
plt.xlabel('App Names')
plt.ylabel('Price,Est')
plt.show()

71. Write a code to plot the speed of a passenger train as shown in the figure given below :
11
Ans : import matplotlib.pyplot as plt
import numpy as np
x =np.arange(1,5)
plt.plot(x,x*1.5,label='Normal',linestyle ='dotted',color='b')
plt.plot(x,x*3,label='Fast',color='b')
plt.plot(x,x/3.0,label='Slow',linestyle ='dashed',color='b')
plt.legend()
plt.show()

12
Chapter 2 : Python Pandas
Multiple Choice Questions

1. Which of the following input can be accepted by DataFrame ?


(a) Structured ndarray (b) Series (c) Data Frame

2. What attribute is used to obtain the rows and columns count of a pandas dataframe?
(a) Shape (b) Dimension (c) Size (d) Count

Short Answer Questions

3. Write command to applymap() function np.sqrt on the dataframe wdf.


4. Write down the output of the following code :
import pandas as pd
data = { ‘Name’:[‘Tom’,’Jack’,’Steve’,’Ricky’], ’Age’ :[28,34,29,42]}
df=pd.DataFrame(data)
print df
5. How is series data structure different from a dtaframe datastructure ?
6. How is reindexing and relabelling useful indataframes ?
7. Write Python code to create a dataframe for employeedata(empno,ename,salary) and sort the
dataframe first by salary in descending order then by empno.
8. Write a python code to count the number of rows and columns of a dataframe for
studentdata(Stno,Sname,Age,class)
9. How does dataframe object specify indexes to its data rows ?
10. What is quartile? How is it related to quantile ? How do you generate it in the pandas ?
11. How useful is sorting and grouping ?
12. Devanshi wants to display the first 3 rows of the dataframe KVS. Which function she has to use ?
13. How are reindex() and reindex-like() similar and different ?
14. What is the difference between pivot() and pivot_table() functions ?
15. What are various types of histograms that can be created through hist() function ?
16. Write a python code to create a dataframe with appropriate heading from the list given below:
[ ‘S101’, ‘Army’,70], [‘S102’, ‘Bandhi’, 69 ], [ ‘S104’, ‘Cathy’, 75],
[‘S105’,’Gundaho’, 82]
17. How are apply() and applymap() functions similar and different ?

18. How are agg() and transform() similar and different ?

19. How do we write Dataframe to CSV files in Pandas

20. Write command to pipe functions sqrt(),power( ,3), multiply(……., 10) on dataframe wdf

21. 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 dislayed . Identify the error and rewrite the correct code so that last 4
rows get displayed .

22. When should pipe() be preferred over sandwiching of function call ?


13
23. Given a data frame df1 as shown below :

City Maxtemp Mintemp Rainfall


Delhi 40 32 24.1
Bengaluru 31 25 36.2
Chennai 35 27 40.8
Mumbai 29 21 35.2
Kolkata 39 23 41.8

i) Write command to compute sum of every column of the dataframe


ii) Write command to compute mean of column Rainfall
iii) Write command to compute average maxTemp, Rainfall for first 5 rows

24. Find the output of the following code:


import pandas as pd
V= [{'a': 10, 'b': 20},{'a': 6, 'b': 32, 'c': 22}]
#with two column indices, values same as dictionary keys
df1 = pd.DataFrame(V, index=['first', 'second'], columns=['a', 'b'])
#With two column indices with one index with other name
df2 = pd.DataFrame(V, index=['first', 'second'], columns=['a', 'b1'])
print(df1)
print(df2)
.
25. Write a small python code to create a dataframe with headings (‘EmpNo.’ and ‘EName’) using
the list given below :
[[5,’Isha’],[8,’Kartik’],[30,’Ria’],[40,’Nagesh’]]

26. Correct and find the output :


import pandas as pd
R=pd.Series([2,4,6,8,10])
P=pd.Series(K)
print(D)

27. Write the command using Insert() function to add a new column in the last place(3rd place)
named "Salary” from the list Pay=[5000,7000,4000] in an existing dataframe named EMP already
having 2 columns.

14
Chapter : 3 Plotting with Pyplot I & II
( Bar Graph ,Scatter Plots, Histograms, Frequency Distribution & Boxplots )

Multiple Choice Questions

1. Which of the following plots are used to check if a data det or time series is randon ?
(a) Lag (b) Random (c) Lead (d) None of the above

2. Andrews curves allow one to plot multi variate data


(a) True (b) False

Short Answer Questions

3. How does Python support data visualization?


4. What is the use of matplotlib and pyplot ?
5. What is the role of legends in a graph/chart ?
6. Write a python program to display a bar chart of the popularity of programming languages.
Sample Data:
Programming Languages : Java, Python, PHP , JavaScript , C# , C++
Popularity : 22.2 , 17.6, 8.8, 8 , 7.7 , 6.7

7. Write a Python program to draw a scatter plot using random distributions to generate balls of
different sizes.
8. What is the use of loc argument in a legend() function
9. Compare bar() and barh() functions
10. What is marker ? How can you change the marker type and color in a plot
11. Write the code to draw the boxplot from the following data :
25, 42, 63, 45, 59, 56, 87, 68, 95
12. Name the functions you will use to create a i)line chart , ii) bar chart , iii) scatter chart
13. How are apply () and applymap() functions similar and different ?
14. What is scatter chart ? How is it different from line chart ?
15. What is frequency polygon ? How do you create it ?
16. Questions given below are based on the following data.
Weight measurements for 16 small orders of French fries (in grams)
78 72 69 81 63 67 65 75
79 74 71 83 71 79 80 69
Given the following set of data :
a) Create a simple histogram from above data
b) Create a horizontal histogram from the above data
c) Create a step type of histogram from above data
d) Create a cumulative histogram from above data
17. From the following ordered set of data :
63, 65, 67, 69, 69, 71, 71, 72, 74, 75, 78, 79, 79, 80, 81, 83
a) Create a horizontal boxplot
b) Create a vertical boxplot
c) Show means in the boxplot
d) Create boxplot without the box
15
18. What is cumulative histogram ? How do you create it using pyplot ?
19. What is Boxplot? How do you create it in Pyplot ?
20. Create a histogram that plots two ndarrays x and y with 48 bins , in stacked horizontal
histogram.
21. Name the various types of histograms plots that you can create using pyplot.
22. Ms Sangeeta wants to plot a Line Chart for the given set of values of months on x and
number of participants who attended workshop in particular month on y-axis. Complete
the code to perform the following :
(i) To plot the Line Chart in statement 1
(ii) To add Title as “Workshop Status” in graph in statement 2

import matplotlib.pyplot as plt


x=['JAN', 'MAR', 'MAY’, 'JUL', ’SEP’, ’NOV']
y=[15, 12, 20, 40, 60, 80]
_____________________ Statement 1
_____________________ Statement 2

23. What are the ticks in a chart? Explain how we can define ticks in a chart with example.
24. Write a python program to plot a line chart for three students scoring in 5 subjects. The maximum
marks in each subject is 100. Chart should display 3 lines in 3 colors with x and y axis labels and
chart title.
26. Write a Python program to display a bar chart of the temparature in city, data given below
City: Rewa, Ooty, Prayag, Leh, Kullu, Bhuj
Temp: 20.2, 28.6, 30.8, 8.5, 23.6, 26.7 (respectively)

27. What file formats are allowed to save a chart? Explain how can we save a chart in a file? Explain
with suitable example

16
UNIT-2 : DBMS
Sh. Mitra Bhushan, PGT-CS, KV Sidhi

Chapater 4 : Database Query Using SQL


Multiple Choice Questions

1. What is the full form of SQL ?


(a) Structured Query List (b) Structured Query Language
(c) Simple Query Language (d) None of these

2. In inner join, result is produced by matching rows in one table with rows in another table.
(a) True (b) False

3. The join where all possible row combinations are produced is called _________
(a) Inner Join (b) Outer (c) Natural (d) Cartesian

4. The clause that filters JOIN results is called _________


(a) Where (b) Sort (c) Group (d) Group by

5. The left and right joins are also known as __________


(a) Inner Join (b) Natural Join (c) Outer Join (d) Cartesian Join

6. In which join all the rows from the left table appear in the output irrespective of the content of
the other table?
(a) Right Join (b) Left Join (c) Inner Join (d) Outer Join

7. What is the meaning of “GROUP BY” clause in Mysql?


(a) Group data by column values (b) Group data by row values
(c) Group data by column and row values (d) None of the mentioned

8. Which clause is similar to “HAVING” clause in Mysql?


(a) Select (b) Where (c) From (d) None of the
mentioned

9. “COUNT” keyword belongs to which categories in Mysql?


(a) Aggregate functions (b) Operators (c) Clauses (d) All of the mentioned

10. Which of the following belongs to an “aggregate function”?


(a) Count (b) SUM/AVG (c) MIN/MAX (d) All of the mentioned

11. Which clause is used with an “aggregate functions”?


(a) Group by (b) Select (c) Where (d) Both GROUP BY and WHERE

12. What is the meaning of “ORDER BY” clause in Mysql?


(a) Sorting your result set using column data (b) Aggregation of fields
(c) Sorting your result set using row data (d) None of the mentioned

17
13. If emp_id contain the following set {9, 7, 6, 4, 3, 1, 2}, what will be the output on execution of
the following MySQL statement?
SELECT emp_id
FROM person
ORDER BY emp_id;
(a) {1, 2, 3, 4, 6, 7, 9} (b) {2, 1, 4, 3, 7, 9, 6}
(c) {9, 7, 6, 4, 3, 1, 2} (d) None of the mentioned

14. Keyword “ASC” and “DESC” cannot be used without which clause in Mysql?
(a) Order by (b) Group by (c) Select (d) Having

15. The string function that returns the index of the first occurrence of substring is _____________
(a) insert() (b) instr() (c) instring() (d) infstr()

16. Which of the following is not the aggregate function?


(a) Avg (b) Sum (c) With (d) Min

17. Which operator tests column for the absence of data (i.e., NULL value)?
(a) EXISTS operator (b) NOT operator
(c) IS operator (d) None of these

18. Which of the following queries contain an error?


(a) Select * from emp where empid = 1003;
(b) Select empid from emp where empid = 1006;
(c) Select empid from emp;
(d) Select empid where empdid = 1009 and lastname=’GUPTA’;

19. An attribute in a relation is a foreign key if it is the _________ key in any other relation.
(a) Candidate (b) Primary (c) Super (d) Sub

20. The operation whose result contains all pairs of tuples from the two relations, regardless of
whether their attribute values match.
(a) Join (b) Cartesian Product (c) Intersection (d) Set difference

Short Answer Type Questions

1. How many command categories are there in SQL?


2. Explain difference between DML & DDL?
3. What is the purpose of TCL commands?
4. What is the difference between CHAR and VARCHAR data type?
5. Which command is used in SQL to discard the changes done in the database recently?
6. What are scalar functions?
7. What is the significance of Group by Clause in SQL?
8. What is Equi Join?
9. While creating the table Book, Ms. Manasvi forgot to include two fields author and publisher
help her to write the suitable command(s) to do so.
10. Explain referential integrity?
18
11. What do you mean by constraints?
12. What is the difference between Column constraints and Table constraints?
13. How is PRIMARY KEY constraint different from UNIQUE constraint?
14. What is DEFAULT and NOT NULL constraint?
15. Explain the Primary Key, Candidate Key and Alternate key through an Example.
16. Explain the Concept of Primary key and Foreign Key using suitable example
17. What is the difference between DISTINCT and ALL?
18. Write a SQL statement to display the current date and time.
19. What is the use of CURDATE() and SYSDATE()?
20. What is the difference between
• DROP and DELETE command?
• UPDATE and ALTER commands
• COUNT (<column name>) and COUNT (* )
• GROUP BY and ORDER BY
21. Differentiate the following
• EQUI and NATURAL JOIN
• EQUI and NON EQUI join
• CARTESIAN PRODUCT and CROSS JOIN
22. What is the Difference between WHERE and HAVING clause?
23. What are the types of SQL functions?
24. Define the following functions with examples:
POWER(), ROUND(), MOD(), MAX(), MIN(), SUM(), COUNT(), COUNT(*)
25. Differentiate between CHAR and VARCHAR data types.

Questions based on Application:

1. Consider the table FLIGHT given below. Write commands in SQL for (i) to (iv) and output for (v) to
(vi).

Table : FLIGHT
FLCODE START DESTINATION NO_STOPS NO_FLIGHTS
IC101 DELHI AGARTALA 1 5
IC102 MUMBAI SIMMIM 1 3
IC103 DELHI JAIPUR 0 7
IC105 KANPUR CHENNAI 2 2
IC107 MUMBAI KANPUR 0 4
IC431 INDORE CHENNAI 3 2
IC121 DELHI AHMEDABAD 2 6

(i) Display details of all flights starting from Delhi.


(ii) Display details of flights that have more than 4 number of flights operating.
(iii) Display flight codes, starting place, destination, number of flights in descending order
of number of flights.
(iv) Add on column “Remarks” in given table FLIGHT .
(v) SELECT MAX(NO_FLIGHTS) FROM FLIGHT;
(vi) SELECT START, COUNT(*) FROM FLIGHT GROUP BY Start;

19
2. Write SQL commands and output for the following queries:

StudentNo Class Name Game1 Grade1 Game2 Grade


10 7 Sameer Cricket B Swimming 2
A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Veena Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C

(i) Display the names of the students who have grade ‘A’ in either Game1 or Game2 or both.
(ii) Display the games taken by the students whose name starts with ‘A’.
Give the output of the following SQL Statements
(a) SELECT COUNT(*) FROM SPORTS;
(b) SELECT DISTINCT Class FROM SPORTS;
(c) SELECT MAX(Class) FROM STUDENT;
(d) SELECT COUNT(*) FROM SPORTS GROUP BY Game1;

3. Consider the table TEACHER given below. Write commands in SQL for (i) to (iii) and output for
(iv) to (v) . Note: Hiredate is in mm/dd/yyyy format

ID Name Department Hiredate Category Gender Salary


1 Taniya Social Studies 03/17/1994 TGT F 25000
2 Abhishek Art 02/12/1990 PRT M 20000
3 Sanjana English 05/16/1980 PGT F 30000
4 Vishwajeet English 10/16/1989 TGT M 25000
5 Aman Hindi 08/1/1990 PRT F 22000
6 Pritam Math 03/17/1980 PRT F 21000
7 RajKumar Science 09/2/1994 TGT M 27000
8 Sital Math 11/17/1980 TGT F 24500

(i). To display all information about teachers of Female PGT Teachers.


(ii). To list names, departments and date of hiring of all the teachers in descending order of
date of joining.
(iii). To count the number of teachers and sum of their salary department wise.
(iv). SELECT MAX(Hiredate) ,Gender FROM Teacher group by Gender;
(v). SELECT COUNT(DISTINCT(Department)) FROM Teacher;

4. Write output of the following queries on the given table “HOTEL”.

Table : Hotel
EMPID CATEGORY SALARY
E101 Manager 60000
E102 Executive 65000
E103 Clerk 40000
E104 Manager 62000
E105 Executive 50000
E106 Clerk 35000

20
(i) SELECT * FROM HOTEL ORDER BY SALARY DESC;
(II) SELECT CATEGORY.AVG(SALARY) FROM HOTEL GROUP BY CATEGORY;
(III) SELECT SUM(SALARY) FROM HOTEL GROUP BY CATEGORY;

5. Consider the table given below and answer the following questions:

Table : Event
EventId EventName Date Organizer
101 Wedding 26/10/2019 1004
102 Birthday Bash 05/11/2019 1002
103 Engagement 13/11/2019 1004
104 Wedding 01/12/2019 1003
105 Farewell 25/11/2019 1001

Table : Organizer
Organizerid Name Phone
1001 Peter 9745684122
1002 Henry 9468731216
1003 Smith 9357861542
1004 Fred 9168734567

(i) What will be the cardinality of Cartesian Product of the above two tables?
(ii) Write SQL query to display Even and its date.
(iii) Write SQL Query to change the Phone number to 9229229229 for the organizer ‘Fred’
(iv) Write a query to display Event name and Phone for all the events organized by Fred
before 01/11/2019

6(a). Write output for SQL queries from i to iii based on the following table:
Table: SPORTS
Rno Class Name Game1 Grade1 Game2 Grade2
10 7 Sammer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Venna Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C

i. SELECT COUNT(*) FROM SPORTS WHERE NAME LIKE ‘%a%’;


ii. SELECT MAX(Class) FROM SPORTS WHERE Grade1=Grade2;
iii. SELECT COUNT(*) FROM SPORTS GROUP BY Game1;

6(b). Write SQL queries for (i) to (iv), which are based on the table SPORTS given in the question.
(i) Display the names of the students who have grade ‘A’ in either Game1 or Game2 or both.
(ii) Display the number of students opted for the game ‘Cricket’
(iii) Display the names of students who have same game for both Game1 and Game2.
(v) Display the games taken by the students whose name starts with ‘A’.
21
7(a). Write a output for SQL queries (i) to (iii), which are based on the table: ACTIVITY given below:

Table: ACTIVITY

ACode ActivityName ParticipantsNum PrizeMoney ScheduleDate


1001 Relay 100x4 16 10000 23-Jan-2004
1002 High jump 10 12000 12-Dec-2003
1003 Shot Put 12 8000 14-Feb-2004
1005 Long Jump 12 9000 01-Jan-2004
1008 Discuss Throw 10 15000 19-Mar-2004
(i) select count(distinct participantsnum) from activity;
(ii) select max(scheduledate),min(scheduledate) from activity;
(iii) select sum(prizemoney) from activity;

7(b). Write SQL queries for (i) to (iv), which are based on the table : ACTIVITY given in the question.
(i) To display the name of all activities with their Acodes in descending order.
(ii) To display sum of PrizeMoney for each of the Number of participants groupings (as
shown in column ParticipantsNum 10,12,16).
(iii) To display the Schedule Date and Participants Number for the activity Relay 100x4
(iv) To increase PrizeMoney by 500 for High jump activity.

8(a). Write the SQL command for the following on the basis of given table.

Table : SPORTS
StudentNo Class Name Game1 Grade1 Game2 Grade2
10 7 Sammer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Venna Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C

(i) Display the names of the students who have grade ‘A’ in either Game 1 or Game 2 or both.
(iii) Display the number of students having the GRADE1 as ‘A’ in Game1.
(iv) Display the names of students who have same game for both Game1 and Game2.
(v) Display the games taken by the students whose name starts with ‘A’.

8(b) Give the output of the following SQL statements as per table given above.
(i) SELECT COUNT(*) FROM SPORTS.
(ii) SELECT DISTINCT Class FROM SPORTS.
(iii) SELECT MAX(Class) FROM STUDENT;
(iv) SELECT COUNT(*) FROM SPORTS GROUP BY Game1;

22
Unit 3: Networking Concepts
Sh. Sunil Kumar Gupta, PGT(CS), K.V. No.1 Sagar Cantt.

Chapter 5 : Networking Concepts

Expand the following abbreviations:


LAN : Local Area Network
MAN : Metropolitan Area Network
WAN : Wide Area Network
PAN : Personal Area Network
MODEM : Modulation Demodulation
bps : bits per second
GPRS : General Packets Radio Service
SMS : Short Messaging Services
SIM : Subscribers Identification Module
GSM : Global System for Mobile
WLL : Wireless in Local Loop
LTE : Long Term Evolution
SMTP : Simple Mail Transfer Protocol
FTP : File Transfer Protocol
TCP/IP : Transmission Control Protocol/ Internet Protocol
PPP : Point to Point Protocol
POP : Post Office Protocol
VoIP : Voice over Internet Protocol
http : Hypertext Transfer Protocol
WWW : World Wide Web
URL : Uniform Resource Locator
VPN : Virtual Private Network

FILL IN THE BLANKS:

1. PPP stands for -------------.


2. A conversation on walkie-talkie is a ------------- data flow.
3. In data communication, the interface between the source and the medium is called -------.
4. You can host Internet and Intranet websites on a Linux server by -------------.
5. The connection between the modem and terminal/computer is a-------------.
6. A computer network that spans a relatively large geographical area is called ------.
7. WAN stands for ----------.

23
8. ISP denotes -------------.
9. A modem is a ------------- device.
10. ------------- is used to access and operate a remote computer on a network.
11. The language used to develop web pages is called -------------.
12. A network of networks is known as ----------.
13. In a network a machine is identified by unique address called _____________
14. The site which stores web pages is called -------------.
15. The unique address of web page on the web is called -------------.
16. ------------- was the predecessor to the internet.
17. The -------------_ is the method used to make hyper text document readable on the WWW.
18. The collection of information for communication is known as -------------.
19. A -------------_ is the whole data displayed on the screen at a time.
20. The software which helps to view the websites is called -------------.
21. The port number of E mail is -------------.
22. -------------_ is a high level protocol that manages the data.
23. The computer is identified by -------------.
24. The -------------_ describes the machines location in a name space from right to left.
25. A ------------- is a computer that performs actions for another computer.
26. ------------- is the most common technology for searching and browsing files developed in past five
years.
27. A ------------- is the computer that asks for the action.
28. VPN stands for -------------.
29. ------------- is a very popular LAN.
30. All computers connected to the internet and wanting to use it for sending/receiving data must
follow a common set of rules for communication called -------------.
31. E mail denotes -------------.
32. ------------- Protocol tells each system how to form mail messages and transfer them between
computers.
33. Internet began in ------
34. Network speed is measured as -------------.
35. The domain name for educational institutions is -------------.
36. DNS denotes -------------.
37. The DNS for commercial businesses is -------------.
38. The domain name for miscellaneous organizations is -------------.
39. A device used to connect dissimilar networks is called..............
40. ...............................is responsible for handling the address of the destination computer so that
each packet is delivered to its proper destination.
24
Very Short Answer Question

1. What is bridge?
2. What is a repeater?
3. Define router
4. What is a switch?
5. What is mean by Ethernet?
6. Define Bluetooth.
7. What are the basic functions of email?
8. Define WWW?
9. What is the web browser?
10. What is URL?
11. What do you mean by TELNET?
12. Differentiate between a router, a hub, and a switch.
13. What is a link?
14. What do you mean by a Node?
15. What does a backbone network mean?
16. What do you mean by network topology?
17. Explain what is LAN?
18. Define the following terms:
(a) RJ-45 (b) Ethernet. (c) Ethernet card. (d) Hub (e) Switch
19. What is HTML? Where is it used?
20. Define GSM, CDMA and WLL.
21. What is circuit switching?
22. How are Trojan horses different from Worms? Mention any one difference.
23. What is a communication channel? Name the basic types of communication channels available.
24. What is a worm? How is it removed?
25. What is TCP/IP?
26. How is FTP different from HTTP?
27. Define Mobile Communication and Wireless Communication.
28. What is Mobile Processor?
29. Name any four popular mobile processors in the market.
30. What are the advantages of e-commerce applications?
31. Define web browser and webserver.
32. Differentiate between XML and is HTML.
33. What is web hosting?
34. What is hacking?
35. What are cookies?
36. Differentiate between cracking and hacking.
37. What is web scripting?
38. Name some web scripting languages.
39. What is Cyber Crime?
40. Give one advantage of bus topology of network. Also state how four computers can be connected
with each other using star topology of network.

25
UNIT 4 -SOCIETAL IMPACTS
Sh. Satish Mishra, PGT-CS, KV No.2 Rewa

Chapter 6 : Societal Impacts


Very Short Answer(VSA) (1 mark)

1 What is Plagiarism?

2 How can we can manage E-waste? (two points)

3 Explain phishing?

4 What is Identity Theft?

5 What is computer forensics?

6 What do you understand by ‘Intellectual Property Rights’?

7 What is Spam?

8 What is spoofing?

9 Alex has stolen a credit card. He used that credit card to purchase a laptop. What type of
offence has she committed?

10 Name the primary law in India dealing with cybercrime and electronic commerce.

11 What is cause and effect of cyberbullying?

12 What is Cyber trolling?

13 Explain Cyberstalking?

14 What do you understand by Digital Footprint?

15 What do we mean by Eavesdropping?

16 Leaking your company data to the outside network without prior permission of senior authority
is a crime true or false. (i) True (ii) False

17 What types of data are stolen by cyber-criminals in most of the cases?

(i) Data that will pay once sold


(ii) Data that has no value
(iii) Data like username and passwords only
(iv) Data that is old

18 Mr. Alex is confused between Shareware and Open Source. Mention at least one points of
differences to help him understand the same.

19 What is the meaning of free and open source software?

20 Is all free software open source?

26
Short Answer-I(SA-I) (2 marks)
1 Give two examples of online fraud. What measures can you take to curb online frauds?

2 Alex has recently shifted to new city and new College .he does not many people in his new city and
school. But all of a sudden, someone is posting negative, demeaning comments on his social
networking profile, college site’s forum etc.

He is also getting repeated mails from unknown people. Every time he goes online, he finds
someone chasing him online.

(a) What is this happening to Alex?

(b) What action should be taken to stop them?

3 Write two advantages of Online Campaigning?

4 What is digital property? Give some examples?

5 How can you avoid plagiarism while referring to someone else’s creation?

6 What is the role of computer forensics?

7 What do you understand by e-waste management? Explain

8 Explain Digital Rights Management. How can we protect our content?

9 Alex received an email from his bank stating that there is a problem with his account. The
email provides instructions and a link, by clicking on which he can logon to his account and
fix the problem. Help Alex by telling him the precautions he should take when he receives
these type of emails.

10 Explain any two ways in which technology can help students with disabilities.

11 What is meant by ethical hacking?

12 What are intellectual property rights? Why should intellectual property rights be protected?

13 Is licensing the same as copyright?

14 How technology is affecting our health?

15 What are the 3 types of hackers?

16 What is the purpose of a software Licence?

27

You might also like