Practice Questions Ip 12
Practice Questions Ip 12
2
Unit-I : Data Handling
Sh. Rajesh Kushwaha, PGT-CS, KV Jayant
Chapter 1 :Working with Numpy
TYPE A : OBJECTIVE TYPE QUESTIONS : [ 1 MARK]
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
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()
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
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
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()
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
True/False Answers
29. T 30. F 31. T 32. F 33. T 34. T 35. T
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)
44. Write a small python code to drop a row from dataframe labeled as 0
Ans : df=df.drop(0)
Print(df)
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
2:
[ [ 8 9 10 11]
[12 13 14 15]]
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)
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.
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.
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
2. What attribute is used to obtain the rows and columns count of a pandas dataframe?
(a) Shape (b) Dimension (c) Size (d) Count
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 .
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 )
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
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
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
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
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
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()
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
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
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
19
2. Write SQL commands and output for the following queries:
(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
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
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
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.
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
1 What is Plagiarism?
3 Explain phishing?
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.
13 Explain Cyberstalking?
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
18 Mr. Alex is confused between Shareware and Open Source. Mention at least one points of
differences to help him understand the same.
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.
5 How can you avoid plagiarism while referring to someone else’s creation?
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.
12 What are intellectual property rights? Why should intellectual property rights be protected?
27