Page 2 :
as, ha, n, , Strictly according to the Latest Reduced & bifurcated Syllabus and the Latest Sample Question, Paper released by the Central Board of Secondary Education, New Delhi,, for the Term I Examination to be held in November-December 2021., , QUESTION BANK and, CBSE Sample Paper with, , Pr, ak, , Model Test Papers in, , Informatics Practices, , ot, , he, , rs, , [Subject Code : 065], , For CLASS, , 12, , Term-I, EXAMINATION, , By, , Gurmeet Singh, , Br, , MCA, MSC (IT), , As per the latest Reduced &, November- December 2021., , l, , Chapterwise Multiple Choice Questions., , l, , Chapterwise Case Study Based Multiple Choice Questions., The latest CBSE Sample Question Paper for Term I Examination to be held in November-December 2021., , oy, , l, , bifurcated Syllabus for Term I Examination to be held in, , al, , l, , 5 Model Test Papers based on the latest CBSE Sample Question Paper for Term I Examination., , G, , l, , GOYAL BROTHERS PRAKASHAN
Page 3 : GOYAL BROTHERS PRAKASHAN, EDUCATIONAL, , PUBLISHERS, , Administrative Office :, D-231, Sector 63, Noida-201301 (U.P.), Phone : 0120-4655555, , as, ha, n, , Sales & Registered Office :, 11/1903, Chuna Mandi, Paharganj, New Delhi - 110055, Post Box : 5720, Phones : 43551877 & 43561877, E-mail :
[email protected], Website : www.goyal-books.com, , Showrooms :, Ahmedabad : Y-10, Dev Castle Complex Opp. Radhekrishan Villa, Jaymala-Govindwadi Road, Isanpur, Ahmedabad–382443 (Gujarat) Tel : 09925004030, , Pr, ak, , : No. 50/39 Ground Floor, Five Furlong Road Guindy, Chennai–600 032, Chennai, (Tamil Nadu) Tel : 044-22552776, Fax : 044-22552767, , Guwahati : Plot No. 1179, KRB Road, Bharalumukh, near Post Office, Railway Gate No.8, Guwahati – 781001 (Assam), Phone : 0361-2735337, Hyderabad : F-7/8/41, First Floor, Agarwal Chambers, 5-9-1121, King Kothi Road,, Hyderabad - 500001 Tele-fax : 23211332, Kochi, : Fair Heavens, H.No. 52-2783/A, Shine Road, Vytilla, Emakulam - 682019 (Kerala) Phone : 0484-2305288, , rs, , Kolkata, : No. 203, 2nd Floor, Fomra Towers, 84-A, Acharya Jagdish Chandra Bose Road,, Kolkata - 700014 Phone : 033-22262683, , he, , Bengaluru : 1681/5/4, Ground Floor, 3rd Main Ramamohanapuram,, Bengaluru - 560 021, Phone : 080-23320655, , ot, , Bhopal, : Plot No. 203, Zone-II, M.P. Nagar, Bhopal-462 011 (M.P.),, , Tele-fax : 0755-4271371, Lucknow, : B-318, Sector-B, Mahanagar, Opposite P.A.C Main Gate,, , Br, , Lucknow - 226 006, Phone : 0522-2320841, Patna, : Ravi Kiran Apartment, Flat No. 2-A, Second floor,, Near Water Pumping Station, Pani Tanki Lane, Pirmohani, Patna – 800003, Nagpur, : Thakkar Villa, House No. 436 Joshiwadi, Sibuldi, Nagpur – 440012, , Phone : 9823655077, , G, , oy, , al, , To buy our books and e-books online log on to www.goyal-books.com, © Reserved, Edition : 2021, Price : `199, , Disclaimer, • All the brand, product names and logo referred to in this book are hereby acknowledged to be the trademarks of, their respective organisations. We are not associated with any product or vendor mentioned in this book., • Due care and diligence has been taken while writing, editing and printing the book. Neither the, author nor the publishers of the book hold any responsibility for any mistakes that may have inadvertently crept in., , Published & Printed by, Roshan Lal Goyal for Goyal Brothers Prakashan, New Delhi
Page 4 :
PREFACE, , as, ha, n, , We are pleased to present our book SCORE PLUS Question Bank and CBSE Sample Paper with, Model Test Papers in Informatics Practices for Class XII (Subject Code 065) in strict accordance, with the Latest Reduced of bifurcated Syllabus and the Latest Sample Question Paper released, by the Central Board of Secondary Education, New Delhi, for Term I Examination to be held in, November-December 2021., This book contains the brief introduction of each topic with solved examples. In each chapter,, topicwise questions have been set. “Easy to difficult” level of questions is maintained. We have, tried to clear all the concepts in easy language and with solved examples. Most of the questions, are taken from the last year CBSE paper or based on CBSE pattern., , Some specific features of this book are:, , Pr, ak, , In the next part of book, sample question paper of Computer Science released by CBSE with, its solution is published. After sample paper, there are 5 model test papers with their solutions, prepared keeping in mind the blueprint of the CBSE sample question paper., , Strictly as per the latest Reduced and bifurcated syllabus and the latest CBSE Sample, Question Paper released by the CBSE for Term I Examination to be held in November, December 2021., , l, , Chapterwise Question Bank provides topicwise comprehensive range of solved and, unsolved questions including questions from past years’ papers to provide thorough, understanding of the chapter., , l, , The latest CBSE Sample Question Paper for Term I Examination to be held in NovemberDecember 2021., , l, , 5 Model Test Papers based on the latest CBSE Sample Question Paper for Term I, Examination., , ot, , he, , rs, , l, , G, , oy, , al, , Br, , We hope this book provides enough practice materials and would help students in scoring high, during this academic year along with the final board examination., Author
Page 5 :
Syllabus, Code No. 065, Session 2021-2022, , 1. Prerequisite: Informatics Practices – Class XII, 2. Learning Outcomes, , as, ha, n, , INFORMATICS PRACTICES CLASS XII, , Periods, Theory, , 1., , Data Handling using Pandas and Data Visualization, , 25, , 25, , 25, , 50, , 2., , Database Query using SQL, , Pr, ak, , At the end of this course, students will be able to:, Create Series, Data frames and apply various operations., Visualize data using relevant graphs., Design SQL queries using aggregate functions., Learn terminology related to networking and the internet., Identify internet security issues and configure browser settings, Understand the impact of technology on society including gender and disability issues., , 25, , 20, , 17, , 37, , 3., , Introduction to Computer Networks, , 10, , 12, , 0, , 12, , 4., , Societal Impacts, , 10, , 14, , –, , 14, , –, , –, , 7, , 7, , 30, , –, , –, , –, , 100, , 71, , 49, , 120, , 3. Distribution of Marks and Periods, Unit, No, , he, , Project, Practical, , ot, , Total, , Marks, , Periods, Theory, , Total, Period, , rs, , Units Name, , Term – I, , Br, , Distribution of Theory Marks, Unit No, , Units Name, , Marks, , Data Handling using Pandas and Data Visualization, , 25, , 4., , Societal Impacts, , 10, , Total, , 35, , oy, , al, , 1., , G, , Unit 1: Data Handling using Pandas and Data Visualization, Data Handling using Pandas -I, Introduction to Python libraries - Pandas, Matplotlib., Data structures in Pandas - Series and data frames. Series: Creation of series from dictionary, scalar value;, mathematical operations; series attributes, head and tail functions; selection, indexing and slicing., Data Frames: creation of data frames from dictionary of series, list of dictionaries, text/CSV files, display,, iteration. Operations on rows and columns: add (insert/append), select, delete (drop column and row),, rename, Head and Tail functions, indexing using labels, Boolean indexing.
Page 6 :
Data Visualization, Data Visualization : Purpose of plotting, drawing and saving of plots using Matplotlib (line plot, bar graph,, histogram). Customizing plots: adding label, title, and legend in plots., , as, ha, n, , Unit 4: Societal Impacts, Digital footprint, net and communication etiquettes,, Data protection, intellectual property rights (IPR), plagiarism, licensing and copyright,, Free and open source software (FOSS),, Cybercrime and cyber laws, hacking, phishing, cyber bullying, overview of Indian IT Act., E-waste: hazards and management. Awareness about health concerns related to the usage of technology., Distribution of Practical Marks, Topic, , Marks, 8, , Practical File- 15 python Programs, , 3, , Project Synopsis, , Pr, ak, , Pandas program (pen and paper or Collab or any online idle or, pyroid screen for mobile), , 2, , Viva, , 2, , Total, , 15, , ot, , he, , rs, , Suggested Practical List, Programming in Python, 1. Create a panda’s series from a dictionary of values and a ndarray, 2. Given a Series, print all the elements that are above the 75th percentile., 3. Create a Data Frame quarterly sales where each row contains the item category, item name, and, expenditure. Group the rows by the category and print the total expenditure per category., 4. Create a data frame for examination result and display row labels, column labels data types of each column, and the dimensions, 5. Filter out rows based on different criteria such as duplicate rows., 6. Importing and exporting data between pandas and CSV file, , Br, , 5.2 Visualization, 1. Given the school result data, analyses the performance of the students on different parameters, e.g subject, wise or class wise., 2. For the Data frames created above, analyze, and plot appropriate charts with title and legend., 3. Take data of your interest from an open source (e.g. data.gov.in), aggregate and summarize it., Then plot it using different plotting functions of the Matplotlib library., , G, , oy, , al, , Project Synopsis, The synopsis should cover the brief description about the project along with reasons for selection of the dataset., The learner should write the source of the dataset whether created or taken from any reliable source. The learner, should write what analytics can be done on the project.
Page 7 :
as, ha, n, , CONTENTS, , SECTION A: CHAPTERWISE QUESTION BANK, , 1. Series, 2. DataFrame, , 1 – 30, , ... ... ..., , 31 – 75, , ... ... ..., , 76 – 85, , ... ... ..., , 86 – 96, , Pr, ak, , 3. Visualization, , ... ... ..., , 4. Societal Impacts, , SECTION B: CBSE SAMPLE QUESTION PAPER, , CBSE Sample Question Paper, , ... ... ..., , 97 – 105, , he, , , , rs, , [Released by CBSE in September 2021, for the Term I Examination to be held in November-December 2021], , SECTION C: MODEL TEST PAPERS, , ot, , [Based on the latest CBSE Sample Question Paper, for the Term I Examination to be held in November-December 2021], , Model Test Paper – 1, , ... ... ..., , 106 – 113, , , , Model Test Paper – 2, , ... ... ..., , 114 – 121, , , , Model Test Paper – 3, , ... ... ..., , 122 – 129, , ... ... ..., , 130 – 137, , ... ... ..., , 138 – 145, , al, , Br, , , , Model Test Paper – 4, , G, , oy, , , , , Model Test Paper – 5
Page 8 :
SECTION : A, , Series is a one-dimensional array like structure with homogeneous, data. For example, the following series is a collection of integers 10,, 23, 56, …, , Python Pandas, , Pandas is a software library written for the Python, programming language for data manipulation and, analysis. Pandas is defined as an open-source, library that provides high-performance data, manipulation in Python. The name of Pandas, is derived from the word Panel Data, which, means an Econometrics from Multidimensional, data. It is used for data analysis in Python and, developed by Wes McKinney in 2008., , Pr, ak, , Pandas Series is a one-dimensional labeled array capable of holding, any data type (integer values, string values, double value and more). A, Series represents a single column in memory. Series can only contain, single list with index, whereas dataframes can be made of more than, one series or we can say that a dataframes is a collection of series., , as, ha, n, , 1, , Series, , Sr. No, , rs, , Key Points of Series, ● Homogeneous data, ● Size Immutable, ● Values of Data Mutable, A pandas Series can be created using the following constructor − pandas. Series(data, index, dtype, copy), Parameter, , Description, , data, , data takes various forms like ndarray, list, constants, , 2., , index, , Index values must be unique and hashable, same length as data. Default np.arrange(n), if no index is passed., , 3., , dtype, , dtype is for data type. If None, data type will be inferred, , 4., , copy, , ot, , he, , 1., , Copy data. Default False, , Br, , CREATION OF SERIES, ● Dictionary, , al, , A series can be created using various inputs like:, ● List, ● Tuple, ● Array, ● Scalar value or constant, , Create an Empty Series, , oy, , A basic series, which can be created is an Empty Series., 1. Write a program to create an empty series, #import the pandas library and aliasing as pd, Ans. import pandas as pd, , G, , s =pd.Series(), print (s), , Its output is as follows :, Series([], dtype: float64), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 1
Page 9 :
Create a Series from List, , c=[‘red’,’green’,’blue’], p=pd.Series(c), print (p), , OR, , import pandas as pd, p=pd.Series([‘red’,’green’,’blue’]), print (p), , Output:, 0, 1, 2, , red, green, blue, , OR, , Pr, ak, , import pandas as pd, c=[‘red’,’green’,’blue’], p=pd.Series(data=c), print (p), , as, ha, n, , 2. Write a program to create a series by given list, [‘red’,’green’,’blue’]., Ans. import pandas as pd, , We did not pass any index, so by default, it assigned the indexes ranging from 0 to len(data)-1, i.e., 0 to 2., 3. Modify the above program and change the index values to r,g,b., Ans. import pandas as pd, , rs, , c=[‘red’,’green’,’blue’], p=pd.Series(c,index=[‘r’,’g’,’b’]), print (p), , he, , OR, , ot, , import pandas as pd, p=pd.Series([‘red’,’green’,’blue’],index=[r,g,b]), print (p), , Br, , import pandas as pd, c=[‘red’,’green’,’blue’], p=pd.Series(c,[r,g,b]), print (p), , OR, , OR, , al, , import pandas as pd, c=[‘red’,’green’,’blue’], p=pd.Series(data=c,index=[r,g,b]), print (p), , G, , oy, , Output:, r red, g, green, b, blue, , Create a Series from Tuple, 4. Write a program to create a series from a given Tuple data, data=(‘1’,’Aman’,86.3,’A’)., Ans. import pandas as pd, , 2, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 10 :
data=(‘1’,’Aman’,86.3,’A’), p=pd.Series(data), print (p), , as, ha, n, , output, 0 1, 1, Aman, 2 86.3, 3 A, , Create a Series from Dictionary, , A dictionary can be passed as input and if no index is specified, then keys of the dictionary are used to represent the, index of the Series., 5. A dictionary data ={‘a’:0.,’b’:1.,’c’:2} is given. Write a program to create series from dictionary data., Ans. import pandas as pd, , Pr, ak, , data ={‘a’:0.,’b’:1.,’c’:2.}, s =pd.Series(data), print(s), , rs, , Its output is as follows −, a 0.0, b 1.0, c 2.0, dtype: float64, , If index is passed, the values will be displayed in the same sequence as index values are passed., import pandas as pd, , he, , data ={‘a’:0.,’b’:1.,’c’:2.}, , s =pd.Series(data,index=[‘b’,’c’,’a’]), print(s), , Br, , ot, , Its output is as follows −, b 1.0, c 2.0, a 0.0, , You can also show the specified values by giving their keys as index values., 6. Modify the above program and display values of ‘a’ and ‘c’ only., Ans. import pandas as pd, , al, , data ={‘a’:0.,’b’:1.,’c’:2.}, , s =pd.Series(data,index=[‘a’,’c’]), , oy, , print(s), , G, , Its output is as follows −, a 0.0, c 2.0, If index value is passed other than keys value then NaN (Not a Number) as value will be displayed., 7. Give the output:, Ans. import pandas as pd, , data ={‘a’:0,’b’:1.,’c’:2.}, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 3
Page 11 :
s =pd.Series(data,index=[‘b’,’c’,’d’,’a’]), print(s), , Create a Series from Scalar/Constant value, , as, ha, n, , Its output is as follows −, b 1.0, c 2.0, d NaN, a 0.0, dtype: float64, Observe − Index order is persisted and the missing element is filled with NaN (Not a Number)., , If data is a scalar value, an index must be provided. The value will be repeated to match the length of index., , s =pd.Series(5, index=[0,1,2,3]), print(s), , Pr, ak, , 8. Write a program to create a series to print scalar value “5” four times., Ans. import pandas as pd, , Create a Series from ndarray, , rs, , Its output is as follows −, 0 5, 1 5, 2 5, 3 5, As you can see the “5” is printed 4 times because the length of index is 4., , import numpy as np, , he, , 9. Write a program to create a series from ndarray with elements ‘a’,’b’,’c’,’d’, Ans. import pandas as pd, data =np.array([‘a’,’b’,’c’,’d’]), print(s), , ot, , s =pd.Series(data), , Br, , Its output is as follows −, 0 a, 1 b, 2 c, 3 d, dtype: object, , al, , 10. Give the output:, , import pandas as pd, import numpy as np, , oy, , data =np.arange(10,15), s =pd.Series(data), print(s), , G, , Ans. 0 10, 1, 11, 2, 12, 3, 13, 4, 14, , 4, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 12 :
REINDEXING, , , import pandas as pd, name=[‘Raj’,’Ankur’,’Harsh’], p=pd.Series(name,index=[2,5,6]), print(p), # Reindex the series and create a new series variable, p1=p.reindex([6,2,5]), print (p1), , p1=p.reindex([2,5]), print (p1), , rs, , , import pandas as pd, name=[‘Raj’,’Ankur’,’Harsh’], p=pd.Series(name,index=[2,5,6]), print(p), , Pr, ak, , Ans. 2 Raj, 5 Ankur, 6 Harsh, 6 Harsh, 2 Raj, 5 Ankur, 12. Give the output:, , as, ha, n, , Reindex means to conform the data to match a given set of labels along a particular axis. Reorder the existing data, to match a new set of labels. Reindexing does not mean providing new index values; in fact, it is used to reorder the, existing data or print specified data., 11. Give the output:, , Br, , ot, , he, , Ans. 2 Raj, 5 Ankur, 6 Harsh, dtype: object, 2 Raj, 5 Ankur, dtype: object, if other than existing index value is provided to reindex then NaN will be displayed., 13. Give the output:, , al, , import pandas as pd, name=[‘Raj’,’Ankur’,’Harsh’], p=pd.Series(name,index=[2,5,6]), print(p), p1=p.reindex([2,4,5]), , oy, , print (p1), , G, , Ans. 2 Raj, 5 Ankur, 6, Harsh, dtype: object, 2 Raj, 4 NaN, 5, Ankur, dtype: object, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 5
Page 13 :
ALTER INDEX VALUES, The Series index function does not only allow you to display the index items, but you can also alter it as well. This, example changes the actual index items and places the integer values as the index., import pandas as pd, , as, ha, n, , 14. Give the output:, S = pd.Series([10,20,30,40,50], index = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’]), print(S), , # Assigning New Index Values, S.index = [1, 2, 3, 4, 5], , print(“Series after new index values”), print(S), , Ans. a 10, , Pr, ak, , e 20, i 30, o 40, u 50, dtype: int64, Series after new index values, 1 10, , rs, , 2 20, 3 30, 4 40, , he, , 5 50, dtype: int64, , ot, , ‘NAME’ ATTRIBUTE, , Br, , The Series Object has an important attribute called name. You can use this attribute to assign a name for both the data, and the indexes., 15. Give the output:, , , import pandas as pd, , D={‘r’:’red’,’g’:’green’,’b’:’blue’}, , al, , S=pd.Series(D,index=[‘r’,’b’,’g’]), S.name=”colourname”, , oy, , S.index.name=”code”, print(S), , Ans. code, , G, , r red, b blue, g green, Name: colourname, dtype: object, , 6, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 14 :
SIZE ATTRIBUTE, , import pandas as pd, L=[10,20,30], S=pd.Series(L), print(S.size), , Ans. 3, , PRACTICE QUESTIONS I, , as, ha, n, , All pandas data structures are value-mutable (the values they contain can be altered). All pandas data structures are size, mutable except Series. The length of a Series cannot be changed, i.e. number of columns and rows can’t be altered, once defined. Series is size immutable., 16. What is Series Size?, Ans. Size attribute returns the number of elements in the underlying data for the given series objects., 17. Give the output:, , Pr, ak, , 1. What is series? Explain with the help of an example., [SP 2019-20], Ans. Pandas Series is a one-dimensional labeled array capable of holding data of any type (integer, string, float, python, objects, etc.). The axis labels are collectively called index., Example:, import pandas as pd, # simple array, , data =pd.Series([1,2,3,4,5]), print(data), , rs, , 2. Write a suitable Python code to create an empty series., Ans. import pandas as pd, s=pd.Series(), , he, , print (s), , 3. Write single line Pandas statement to declare a Pandas series named Packets having dataset as:, [125, 92, 104, 92, 85, 116, 87, 90], [Comptt 2020], Ans. Packets = pd.Series([125, 92, 104, 92, 85, 116, 87, 90]), , Br, , ot, , 4. Write single line Pandas statement to declare a Pandas series named S having dataset as:, (44,65,35,77,87,90), Ans. S=pd.Series((44,65,35,77,87,90)), 5. Write single line Pandas statement to declare a Pandas series named SR having dataset as:, {1:’one’,2:’two’,3:’three’}, Ans. SR=pd.Series({1:’one’,2:’two’,3:’three’}), , al, , 6. Write python code to create the following Series Stock (using list), Ans. import pandas as pd, , oy, , L=[“PEN”,”PENCIL”,”ERASER”], Stock=pd.Series(L,index=[1,2,3]), Stock.index.name=”Sno”, print(Stock), , G, , 7. Write python code to create the Series EMP with following data (using Dictionary), Ans. import pandas as pd, d={“E1”:”Sanya”,”E2”:”Krish”,”E3”:Rishav”,”E4”:”Deepak”}, EMP=pd.Series(d), EMP.index.name=”code”, print(EMP), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , Sno, 1, , PEN, , 2, , PENCIL, , 3, , ERASER, , Code, E1, E2, E3, E4, , Sanya, Krish, Rishav, Deepak, 7
Page 15 :
import numpy as np, , data=np.array([10,20,30,40,50]), #or data =np.arange(10,51,10), , s =pd.Series(data,index=[‘A’,’B’,’C’,’D’,’E’]), print(s), , as, ha, n, , 8. Write python code to create series S with the following data by using numpy., A 10, B 20, C 30, D, 40, E, 50, Ans. import pandas as pd, , Pr, ak, , 9. Jasmeet has created the series School but forget to give the index values [‘S1’,’S2’,’S3’,’S4’]. Write single line, command to set the index values to series School., Ans. School.index=[‘S1’,’S2’,’S3’,’S4’], 10. Write python series to print scalar value “100” 5 times with index values(1,2,3,4,5), Ans. import pandas as pd, s = pd.Series(100, index=[1, 2, 3, 4,5]), , OR, , s = pd.Series(100, [1, 2, 3, 4,5]), print (s), , ot, , he, , rs, , 11. Write python code to create the following series:, 101, Harsh, 102, Arun, 103, Ankur, 104, Harpahul, 105, Divya, 106, Jeet, (i) using list, (ii) using tuple, Ans. (i) import pandas as pd, , (iii) using Dictionary, , (iv), , using numpy, , G, , oy, , al, , Br, , L=[“Harsh”,”Arun”,”Ankur”,”Harpahul”,”Divya”,”Jeet”], s=pd.Series(L,index=[101,102,103,104,105,106]), print(s), (ii) import pandas as pd, L=(“Harsh”,”Arun”,”Ankur”,”Harpahul”,”Divya”,”Jeet”), s=pd.Series(L,index=[101,102,103,104,105,106]), print(s), (iii) import pandas as pd, D={101:“Harsh”,102:”Arun”, 103:”Ankur”,104:”Harpahul”,105:”Divya”,106:”Jeet”}, s=pd.Series(D), print(s), (iv) import pandas as pd, import numpy as np, L=np.array([“Harsh”,”Arun”,”Ankur”,”Harpahul”,”Divya”,”Jeet”]), s=pd.Series(L,index=[101,102,103,104,105,106]), print(s), , 8, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 16 :
import numpy as np, data =np.array([‘a’,’b’,’c’,’d’]), s =pd.Series(data,index=[100,101,102,103]), print(s), , Its output is as follows −, 100 a, 101 b, 102 c, 103 d, dtype: object, , , import pandas as pd, s =pd.Series(10, index=[5,6,7,9]), print(s), , Ans. 5 10, 6, 10, 7, 10, 9, 10, , 14. Give the output:, , import pandas as pd, , Pr, ak, , 13. Give the output:, , as, ha, n, , 12. Write a program to create a series by using given an array [‘a’,’b’,’c’,’d’] and assign index values 100,101....., Ans. import pandas as pd, , rs, , s =pd.Series(“ABC”, index=[0,1,2]), print(s), , he, , Ans. 0 ABC, 1, ABC, 2, ABC, , 15. Give the output:, , Br, , ot, , import pandas as pd, name=[‘Pahul’,’Aman’,’Karan’], p=pd.Series(name,index=[0,1,2]), p1=p.reindex([2,1,0]), print(p), print (p1), , oy, , al, , Ans. 0 Pahul, 1 Aman, 2 Karan, 2 Karan, 1 Aman, 0 Pahul, , 16. Give the output:, , G, , import pandas as pd, name=[‘Pahul’,’Aman’,’Karan’], p=pd.Series(name,index=[0,1,2]), p1=p.reindex([1,2,3]), print(p), print (p1), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 9
Page 17 :
17. Give the output:, import pandas as pd, , S=pd.Series([10,20,30,40],index=[‘a’,’b’,’c’,’d’]), print(S), , S.index=[‘d’,’c’,’b’,’a’], , rs, , he, , Ans. a, 10, b, 20, c, 30, d, 40, dtype: int64, d, 10, c, 20, b, 30, a, 40, import pandas as pd, C=[‘red’,’green’,’blue’], p=pd.Series(C,index=[‘r’,’g’,’b’]), print (p), , Pr, ak, , print(S), , as, ha, n, , Ans. 0 Pahul, 1, Aman, 2, Karan, 1, Aman, 2, Karan, 3, NaN, , ACCESSING DATA, , Accessing using head(), , ot, , By default Series.head() function display top 5 rows. To print n no of top rows, pass n as parameter i.e. Series. head(n), , Br, , 18. Write a code to create a series from empno list and show the first five rows, empno = [101,102,103,104,105,106,107], Ans. import pandas as pd, p=pd.Series(empno), print (p.head()), , oy, , al, , output:, 0 101, 1, 102, 2, 103, 3, 104, 4, 105, , G, , 19. Using the above series write a single line statement to show the first 3 rows using head(), Ans. print(p.head(3)), output:, 0, 101, 1, 102, 2, 103, , 10, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 18 :
Accessing using tail(), , as, ha, n, , By default Series.tail() function display last 5 rows. To print n no of last rows, pass n as parameter i.e. Series. tail(n), 20. Write a code to create a series from empno list and show the last five rows, empno=[101,102,103,104,105,106,107], Ans. import pandas as pd, p=pd.Series(empno), print (p.tail()), output:, , 2 103, 3, 104, 4, 105, 5, 106, 6, 107, , Pr, ak, , 21. Fill the missing statements, , import pandas as pd, , L=[101,102,103,104,105,106,107], _=pd.Series(L) #statement 1, , print (p.___(3)) #statement 2, , rs, , output:, 4 105, 5, 106, 6, 107, Ans. p=pd.Series(L) #statement 1, print (p.tail(3)) #statement 2, , 22. Give the output:, , ot, , (i) loc: is label based indexing., (a) A single label, , he, , Indexing, Pandas now supports three types of indexing., , import pandas as pd, , Br, , s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]), print(s.loc[‘a’]), print(s.loc[0]), , al, , Ans. 10, 40, # in loc[0], 0 is interpreted as a label of the index. This is not an integer position along the index., (b) A list of labels, , oy, , 23. Give the output:, , G, , import pandas as pd, s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]), print(s.loc[[‘b’,’c’,1]]), , Ans. b 20, c 30, 1 50, (c) A slice object with labels, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 11
Page 19 :
A slice is a subset of series elements., my_series[start:stop:step], where start is the index of the first element to include, stop is the index of the item to stop and step sets the, interval, import pandas as pd, s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]), print(s.loc[‘a’:’c’]), , as, ha, n, , 24. Give the output:, , Pr, ak, , Ans. a, 10, b, 20, c, 30, , Note: Both the start and the stop are included, when present in the label index., (ii) iloc: integer position based. This series can also be indexed by position (using integers) even though it has string, index entries! The first item is at key 0, and the last item is at key -1, , (a) input an integer, 25. Give the output:, , import pandas as pd, s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]), print(s.iloc[0]), , Ans. 10, (b) input a listof integers, , rs, , 26. Write a program to print the values of 0,2,4 positions from Series s[10,20,30,40,50] using .iloc., Ans. import pandas as pd, s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]), print(s.iloc[[0,2,4]]), , Br, , ot, , he, , output, a, 10, c, 30, 1, 50, , (c) input a slice object with ints, A slice is a subset of series elements., my_series[start:stop:step], where start is the index of the first element to include, stop is the index of the item to stop without including, the stop value and step sets the interval., 27. Show the first 3 values from Series using iloc., Ans. import pandas as pd, , al, , s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]), print(s.iloc[0:3]), , G, , oy, , a 10, b, 20, c, 30, (iii) with [ ]: Accessing Data from Series with Position and Using Label (index). By using [] you can take advantage, of both .loc and .iloc., You can access the records using [] directly. If index value is not defined you can pass default index value 0,1,2..., to access the elements., If string index values are defined then elements can be accessed by both ways : passing default index values(0,1,2...), or passing defined string index values., , 12, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 20 :
If integer index values are defined, [] will work only as .loc i.e. elements can be accessed by passing defined, index values only., 28. Give the output:, import pandas as pd, , as, ha, n, , M=[15,-10,56,39,-90,15], p=pd.Series(M), print(p[0]), , print(p[[0,3,4]]), , Ans. 15, 0, 3, 4, , 15, 39, -90, , 29. Give the output of the following program:, , Pr, ak, , import pandas as pd, , s=pd.Series([10,20,30,40,50],index=[‘a’,’b’,’c’,’d’,’e’]), print(s[0]), , print(s[‘a’:’c’]), print(s[2]), , #or print(s.iloc[0]), , #or print(s.loc[‘a’:’c’]), , #or print(s.iloc[s[2]), #or print(s.loc[‘a’]), , he, , Its output is as follows −, Ans. 10, , a 10, b, 20, c, 30, 30, 10, , rs, , print(s[‘a’]), , 30. Give the output of the following program:, , ot, , import pandas as pd, , s =pd.Series([10,20,30,40,50,60,70,80],index =[‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’]), print(s[2:5]), , Br, , print(s[1:7:2]), , print(s[‘b’:’f’:2]), , G, , oy, , al, , Ans. c 30, d 40, e 50, dtype: int64, b 20, d 40, f 60, dtype: int64, b 20, , d 40, , f 60, dtype: int64, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 13
Page 21 :
import pandas as pd, M=[15,-10,56,39,-90,15], p=pd.Series(M,index=[10,20,30,40,50,60]), print(p[10]), print(p[[10,30,50]]), print(p[0]), # will raise an error message, , Ans. 15, 10 15, 30, 56, 50 -90, error message, , Using a Boolean Indexing for Extraction, , as, ha, n, , 31. Give the output:, , Pr, ak, , Series elements can also be extracted using a predicate function (a function returning True or False) as shown in this, example., 32. Write code to show rows those empno are greater than 103., Ans. import pandas as pd, empno=[101,102,103,104,105,106,107], p=pd.Series(empno), print (p[p>103]), , rs, , Output, 3, 104, 4, 105, 5, 106, 6, 107, , he, , 33. Fill the missing statement to show row whose rollno is 11., Ans. import pandas as pd, rollno=[10,11,12,13,14], , Br, , _____________, Output, 1, 11, print (p[p==11]), , ot, , p=pd.Series(rollno), , PRACTICE QUESTIONS II, , 1. Fill the mising statement to print top 5 rows., , al, , import pandas as pd, empno=[101,102,103,104,105,106,107], p=pd.Series(empno), , G, , oy, , ________________, output:, 0, 101, 1, 102, 2, 103, 3, 104, 4, 105, Ans. print (p.head()), , 14, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 22 :
2. Fill the missing statements to get the given output:, import pandas as pd, empno=[101,102,103,104,105,106,107], p=pd.Series(_____) #statement 1, print (p.______(3))#statement 2, , as, ha, n, , output, 0 101, 1, 102, 2, 103, Ans. statement 1, p=pd.Series(empno), statement 2, print(p.head(3)), , Pr, ak, , 3. Write single line python code to display last three rows using tail() from series P., Ans. print(P.tail(3)), 4. Fill the missing statement to retrieve the first three elements in the Series., import pandas as pd, , s =pd.Series([1,2,3,4,5],index =[‘a’,’b’,’c’,’d’,’e’]), print(s[ _ ]), , he, , rs, , Its output is as follows −, a 1, b 2, c 3, Ans. print(s[:3]) or print(s[0:3]) or print(s[[0,1,2]]), or print(s[[‘a’,’b’,’c’]]) ot print(s[‘a’:’c’]), , 5. Fill the missing statement to print value of first element using index label value., import pandas as pd, , s =pd.Series([1,2,3,4,5],index =[‘a’,’b’,’c’,’d’,’e’]), , ot, , #retrieve a single element, , al, , Br, , _______________, Its output is as follows, 1, Ans. print(s[‘a’]) or, print(s.loc[‘a’]) or, print(s.iloc[0]) or, print(s.head(1)), 6. Give the output:, , oy, , import pandas as pd, , s =pd.Series([1,2,3,4,5],index =[‘a’,’b’,’c’,’d’,’e’]), print(s[[‘a’,’c’,’d’]]), , G, , Ans. Its output is as follows −, a 1, c 3, d 4, dtype: int64, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 15
Page 23 :
7. Fill the missing values to get the desired output., , print (‘name of empno 101 is’,p[____]), , Output, name of empno 101 is Harsh, Ans. import pandas as pd, , name=[‘Harsh’,’Arun’,’Ankur’,’Harpahul’,’Divya’,’Jeet’], empno=[101,102,103,104,105,106], p=pd.Series(name,index=empno), print (‘name of empno 101 is’,p[101]), import pandas as pd, , Pr, ak, , 8. Give the output:, , as, ha, n, , import pandas as pd, name=[‘Harsh’,’Arun’,’Ankur’,’Harpahul’,’Divya’,’Jeet’], empno=[101,102,103,104,105,106], p=pd.Series(______,index=________), , name=[‘Harsh’,’Arun’,’Ankur’,’Harpahul’,’Divya’,’Jeet’], empno=[101,102,103,104,105,106], p=pd.Series(name,index=empno), , print (‘Sales persons are \n’,p[[101,105,106]]), , rs, , Ans. Sales persons are, 101, Harsh, , 105 Divya, , 106 Jeet, , 4 , , oy, , al, , Br, , ot, , he, , 9. (i) Write python code to create the following series, 101 Harsh, 102 Arun, 103 Ankur, 104 Harpahul, 105 Divya, 106 Jeet, , (ii) Show details of 1st 3 employees using head function, , (iii) Show details of last 3 employees using tail function, , (iv) Show details of 1st 3 employees without using head function, , (v) Show details of last 3 employee without using tail function, , (vi) Show value of index no 102, (vii) Show 2nd to 4th records, (viii) Show values of index no=101,103,105, , (ix) Show details of “Arun”, Ans. (i) import pandas as pd, , name=[‘Harsh’,’Arun’,’Ankur’,’Harpahul’,’Divya’,’Jeet’], p=pd.Series(name,index=[101,102,103,104,105,106]), print (p), , G, , (ii) print (p.head(3)), (iii) print (p.tail(3)), (iv) print(p[:3]) or pirnt(p.loc[101:103]) or print(p,iloc[0:3]) or print(p[[101,102,103]]), (v) print (p[-3:]) or print(p[3:]) or print(p[[104,105,106]]), , 16, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 24 :
(vi), (vii), (viii), (ix), , print(p[102]) or print(p.loc[102]), print(p[1:4]), print(p[[101,103,105]]), print(p[p= =’Arun’]), , 10. Give the output:, , import pandas as pd, , , s = pd.Series([1,2,3,4,5],index = [‘a’,’b’,’c’,’d’,’e’]), print (s[0]), , print(s[‘a’]), , Ans. 1, 1, , 11. Give the output:, , import pandas as pd, , Pr, ak, , c=[‘red’,’green’,’blue’,’pink’,’black’,’white’], , as, ha, n, , , , , , , p=pd.Series(c,index=[‘r’,’g’,’b’,’p’,’k’,’w’]), print (p[2]), , #1, , , print(p[2:]), , #3, , , print(p[:2]), , #2, , , print(p[2:5]), , #4, , , print(p[1:5:2]), , #5, #6, , , print(p[-1]), , #7, , , print(p[::-1]), , print(p[-1:-4:-1]), , Ans. blue , , b blue, p pink, k black, w white, , #3, , b blue, p pink, k black, , #4, , g green, p pink, , #5, , r red, b blue, k black, , #6, , white , , #7, , w white, k, black, p, pink, , #8, , G, , oy, , al, , Br, , #2, , #10, , ot, , #1, , r red, g green, , #9, , he, , print(p[-1:-5:], , #8, , rs, , , print(p[: : 2], , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 17
Page 25 :
#9, , #10, , 12. Fill the missing statements to get the given output:, import pandas as pd, rollno=[1,2,3,4,5,6,7], __=pd.Series(____) #statement 1, , output, 0 1, 1, 2, 2, 3, Ans. statement 1, p=pd.Series(rollno), statement 2, print(p.head(3)), , Pr, ak, , print (p.head(_))#statement 2, , as, ha, n, , b blue, g green, r red, w white, k black, p pink, No output, , 13. Fill the missing statements to get the desired output:, , rs, , import pandas as pd, L=[101,102,103,104,105,106,107], _=pd.Series(L) #statement 1, print (p.___(3)) #statement 2, , 14. Give the output:, , ot, , he, , output:, 4, 105, 5, 106, 6, 107, Ans. p=pd.Series(L) #statement 1, print (p.tail(3)) #statement 2, , Br, , import pandas as pd, name=[‘Pahul’,’Aman’,’Karan’], p=pd.Series(name,index=[0,1,2]), p1=p.reindex([2,1,0]), , al, , print(p), , G, , oy, , print (p1), Ans. 0 Pahul, 1, Aman, 2, Karan, 2, Karan, 1, Aman, 0, Pahul, , 15. Give the output:, , , import pandas as pd, s=pd.Series([10,20,30,40,50],index =[1,2,3,4,5]), , 18, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 26 :
print(s.loc[2]), print(s.iloc[2]), , Ans. 20, 30, 20, , as, ha, n, , print(s[2]), , 16. Poonam wants to display first 3 elements from series S. She wrote the following program:, import pandas as pd, , S=pd.Series([10,20,30,40,50],index =[1,2,3,4,5]), print(S.iloc[1:3]), , But she did not get the desired result. Rewrite the above program with necessary changes to help her get the, desired output., Ans. import pandas as pd, , Pr, ak, , s=pd.Series([10,20,30,40,50],index =[1,2,3,4,5]), print(s.loc[1:3]), , OR, , , import pandas as pd, s=pd.Series([10,20,30,40,50],index =[1,2,3,4,5]), print(s[0:3]), , OR, , , import pandas as pd, s=pd.Series([10,20,30,40,50],index =[1,2,3,4,5]), print(s.iloc[0:3]), , rs, , 17. Write a program to create a series from list marks and taking index values from list rollno. Show all elements, that are above 75 marks., Ans. import pandas as pd, , he, , rollno=[1,2,3,4,5,6], marks=[23,86,74,11,98,75], s=pd.Series(marks,index =rollno), , Br, , Output:, 2 86, 5, 98, , ot, , print(s[s>75]), , G, , oy, , al, , 18. Consider the following Series Object,Student, (i) Write the command which will display the names of students having, stream=”Arts”, (ii) Write the command to name the series as Subject., Ans. (i) print(student[student==”ARTS”]), (ii) student.name=”Subject”, , Mishra, Gupta, Khan, Chaddha, Yadav, , Commerce, Arts, Science, Commerce, Arts, , MATHEMATICAL OPERATIONS, , sum(), , Returns sum of all values in the series, , mean(), , Returns mean of all values in series. Equals to sum()/count(), , std(), , Returns standard deviation of all values, , min(), , Return minimum value from series, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 19
Page 27 :
Return maximum value from series, , idxmin(), , Returns index of min value in series, , idxmax(), , Returns index of max value in series, , median(), , Returns median of all value, , mode(), , Returns mode of the series, , value_counts(), , Returns series with frequency of each value, , describe(), , Returns a series with information like mean, mode, quantile etc, , as, ha, n, , max(), , marks=[25,30,25,27,23,60], , Pr, ak, , 34. Write python code to create the series by given list marks and display the mean, median, mode and standard, deviation from the series, marks=[25,30,25,27,23,60], Ans. import pandas as pd, p=pd.Series(marks,index=[101,102,103,104,105,106]), print(p), , print(“Mean=”,p.mean()), , print(“Median=”,p.median()), print(“Mode=”,p.mode()), , print(“standard deviation”,p.std()), , Br, , ot, , he, , rs, , output:, 101, 25, 102, 30, 103, 25, 104, 27, 105, 23, 106, 60, Mean= 31.666666666666668, Median= 26.0, Mode= 0, 25, standard deviation 14.080719678577038, 35. Give the output:, , import pandas as pd, , marks=[25,30,25,27,23,60], , al, , p=pd.Series(marks,index=[101,102,103,104,105,106]), print(p), , G, , oy, , print(“Sum=”,p.sum()), print(“Minimum value=”,p.min()), print(“Maximum value=”,p.max()), print(“Index value of Min value=”,p.idxmin()), print(“index value of Max Value=”,p.idxmax()), print(“count each value\n” ,p.value_counts()), , Ans. Sum= 190, Minimum value= 23, Maximum value= 60, , 20, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 28 :
ARITHMETIC OPERATIONS, The pandas Series allows you to perform arithmetic operations on its data., 36. Give the output:, Ans. import pandas as pd, , Pr, ak, , S=pd.Series([10,20,30,40],index=[‘a’,’b’,’c’,’d’]), , as, ha, n, , Index value of Min value= 105, index value of Max Value= 106, count each value, 25 2, 23, 1, 30, 1, 60, 1, 27, 1, , print(“Add 2 to each item in a series”), print(S+2), , print(“Subtracting 3 from series items”), , Br, , ot, , he, , output:, Add 2 to each item in a series, a, 12, b, 22, c, 32, d, 42, dtype: int64, Subtracting 3 from series items, a, 7, b, 17, c, 27, d, 37, dtype: int64, , rs, , print(S-3), , oy, , al, , 37. Given the following Series S1, Give the output after execution of the following python statement print(S1+5), Ans. 1 15, 2, 25, 3, 35, 4, 45, 5, 55, 38. Write a program to create two series P1 and P2 with the following data and give, command to add P1 and P2., Ans. import pandas as pd, , G, , P1=pd.Series([10,20,30,40,50],index=[“A”,”B”,”C”,”D”,”E”]), , P2=pd.Series([100,200,300,400,500],index=[“A”,”B”,”C”,”D”,”E”]), print(P1+P2), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 1, , S1, 10, , 2, , 20, , 3, , 30, , 4, , 40, , 5, , 50, , P1, , P2, , A, , 10, , A, , 100, , B, , 20, , B, , 200, , C, , 30, , C, , 300, , D, , 40, , D, , 400, , E, , 50, , E, , 500, 21
Page 29 :
39. Given the following two series P1 and P2, Give the output of following command., print(P1+P2), Ans. A 110, B 220, C 330, D, 440, E, 550, , P1, , ‘IN’ OPERATOR, , 10, 20, 30, 40, 50, , A, B, C, D, E, , 100, 200, 300, 400, 500, , as, ha, n, , A, B, C, D, E, , P2, , In operator can check whether the index that we are looking for existed or not and returns True, if it exists otherwise,, False., 40. Give the output:, import pandas as pd, , Pr, ak, , S=pd.Series([10,20,30,40],index=[‘a’,’b’,’c’,’d’]), print(‘b’ in S), print(‘e’ in S), , Ans. True False, , DELETION, , Using drop function: By using drop(index value) function you can delete elements from Series. Drop function does, not remove elements in existing series instead this function return Series with specified index labels removed., , rs, , (a) single row deletion, , he, , 41. Write a program to delete a first element from series., Ans. import pandas as pd, lt=[‘a’,’b’,’c’,’d’,’e’], p=pd.Series(lt), print(p), , # or drop(0), , ot, , p=p.drop(p.index[0]), , al, , Br, , Output:, 1 b, 2 c, 3 d, 4 e, You can delete the records using drop function directly. If index value is not given it will take defalut index value, 0,1,2... if index defined then it will take new defned index value., 42. Modify the above program and delete the element whose index no is 1., Ans. import pandas as pd, , oy, , lt=[‘a’,’b’,’c’,’d’,’e’], p=pd.Series(lt), p=p.drop(1), , G, , print(p), , 0, 2, 3, 4, , 22, , , , , , , a, c, d, e, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 30 :
43. Give the output:, , as, ha, n, , import pandas as pd, lt=[‘a’,’b’,’c’,’d’,’e’], p=pd.Series(lt,index=[1,2,3,4,5]), p=p.drop(1), print(p), , Ans. 2 b, 3 c, 4 d, 5 e, 44. import pandas as pd, , lt=[‘a’,’b’,’c’,’d’,’e’], p=pd.Series(lt,index=[1,2,3,4,5]), p=p.drop(0), print(p), , Pr, ak, , Ans. KeyError: ‘[0] not found in axis, , (b) To remove several items, include a list of index positions:, 45. Give the output of the following program, , Ans. 1, 3, , rs, , import pandas as pd, lt=[‘a’,’b’,’c’,’d’,’e’], p=pd.Series(lt), p=p.drop(p.index[[0,2,4]]), print(p), , b, d, , he, , (c) Slicing also can be used to remove several items, , 46. Write the missing line to delete the index no from 1 to 3 using slicing., , ot, , import pandas as pd, empno=[101,102,103,104,105,106,107], p=pd.Series(empno), , oy, , al, , Br, , ____________________, print(p), output, 0, 101, 4, 105, 5, 106, 6, 107, Ans. p=p.drop(p.index[1:4]), , PRACTICE QUESTIONS III, , G, , 1. Given the following two series P1 and P2, Give the output of following command., print(P1+P2), Ans. A NaN, B, NaN, C, 500.0, D, 800.0, , P1, A, B, C, D, E, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 100, 200, 300, 400, 500, , P2, C, D, E, F, G, , 200, 400, 600, 800, 1000, 23
Page 31 :
E, F, G, , 1100.0, NaN, NaN, , 2. Given the following two series P1 and P2, Give the output of following command., print(P2-P1), Ans. A NaN, B NaN, C -100.0, D 0.0, E 100.0, F NaN, G NaN, , C, D, E, F, G, , P2, 200, 400, 600, 800, 1000, , as, ha, n, , A, B, C, D, E, , P1, 100, 200, 300, 400, 500, , ot, , he, , rs, , Pr, ak, , 3. Given the following Series S1, S1, Give the output after execution of the following python statement print(S1*2), 1, 10, Ans. 1, 20, 2, 15, 2, 30, 3, 30, 3, 60, 4, 35, 4, 70, 5, 50, 5 100, 4. Write single line Pandas statements for each of the following., (Assuming necessary modules have been imported):, (i) Declare a Pandas series named Packets having dataset as:, [125, 92, 104, 92, 85, 116, 87, 90], (ii) Display the median of the elements present in the dataset of Packets using the Pandas method for it., , [comptt 2020], Ans. (i) Packets = pd.Series([125, 92, 104, 92, 85, 116, 87, 90]), (ii) print(Packets.median()), 5. Give the output:, Ans. import pandas as pd, , Br, , M=[15,-10,56,39,-90,15], , p=pd.Series(M,index=[10,20,30,40,50,60]), print(‘Sum=’,p.sum()), , print(‘Minimum value=’,p.min()), , al, , print(‘Maximum value=’,p.max()), , print(‘Index value of Min value=’,p.idxmin()), print(‘index value of Max Value=’,p.idxmax()), , oy, , print(‘count each value\n’,p.value_counts()), , G, , Sum= 25, Minimum value= -90, Maximum value= 56, Index value of Min value= 50, index value of Max Value= 30, count each value, , 24, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 32 :
80, 20, 74, 90, S2, , 7. Consider a given Series , M1:, , 1[SP 21], 2[SP 21], , Term1, Term2, Term3, Term4, , Marks, 45, 65, 24, 89, , Pr, ak, , index, , as, ha, n, , 15 2, 56, 1, -10, 1, 39, 1, -90, 1, 6. Given the following Series S1 and S2:, , S1, S2, A , 10, A , B , 40, B, C , 34, C , D , 60, D , Write the command to find the sum of series S1 and, Ans. print(S1+S2), , Write a program in Python Pandas to create the series., Ans. import pandas as pd, , rs, , m1=pd.Series([45,65,24,89],index=[‘term1’,’term2’,’term3’,’term4’]), , 8. Consider the following Series object, S_amt, , ot, , Write the command which will display the name of the furniture having rent>250., Write the command to name the series as Furniture., print(S_amt[S_amt>250]), S_amt.name= ‘Furniture’, , 2[SP 21], , Br, , (i), (ii), Ans. (i), (ii), , 350, 200, 800, 150, , he, , Table, Chair, Sofa, Stool, , G, , oy, , al, , 9. Consider two objects x and y. x is a list whereas y is a Series. Both have values 20, 40, 90, 110. What will be, the output of the following two statements considering that the above objects have been created already, (i) print (x*2), (ii) print(y*2), Justify your answer, 3[SP 21], Ans. (i) will give the output as:, [20,40,90,110,20,40,90,110], (ii) will give the output as, 0 40, 1 80, 2 180, 3 220, , Justification: In the first statement x represents a list so when a list is multiplied by a number, it is replicated, that many number of times. The second y represents a series. When a series is multiplied by a value, then each, element of the series is multiplied by that number., Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 25
Page 33 :
MULTIPLE CHOICE QUESTIONS, (c) import pd as pandas, , 2. data ={‘a’:10.,’b’:11.,’c’:12.}, , s =pd.Series(data), , (d) import pd as panda, , as, ha, n, , 1. Select the correct statement, , (a) import panda as pd, (b) import pandas as pd, , index values of s is __________, , (a) 0,1,2, (b) 10,11,12, , (c) a,b,c, , 3. Pandas Series is a, , (a) one-dimensional labeled array, , (c) three-dimensional labeled array, , (b) two-dimensional labeled array, (d) multi-dimensional labeled array, , , , (a) 4, , (b) 5, , 5. Give the output:, , Pr, ak, , 4. s = pd.Series(20, index=[2, 3, 4, 5,6]), , print (s) will print 20 ______times, , (c) 6, , s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]), print(s.loc[1]), , , , (a) 10, , (b) 20, , (d) 10a,11b,12c, , (c) 40, , (d) 1, , (d) 50, , (d) 50, , 7. By default Series.tail() function display last ___ rows., , (a) 3, (b) 4, , (d) 6, , he, , rs, , 6. Give the output:, s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1])print(s.iloc[1]), , (a) 10, (b) 20, (c) 40, (c) 5, , 8. __________ function is used to delete an element from series., , (a) delete, (b) drop, (c) remove, , ot, , 9. ___________ method in Pandas can be used to change the index of, Dataframe, , (a) rename(), (b) reindex(), (c) reframe(), , (d) pop, rows and columns of a Series or, [SP 2019-20], (d) none of these, , Br, , 10. Given a Pandas series called “S”, the command which will display the last 4 rows is __________________., , (a) print(S.tail(4)), (b) print(S.Tail(4)), (c) print(S.tails(4)), (d) print(S.Tails(4)), , al, , 11. Given a Pandas series called “S”, the command which will delete the 1st row(index value 0) __________________., , (a) S.delete(0), (b) S.drop(0), (c) S.pop(0), (d) S.del(0), , oy, , 12. Given a Pandas series called Sequences, the command which will display the first 4 rows is _______. 1 [SP 21], , (a) print(Sequences.head(4)) , (b) print(Sequences.Head(4)), , (c) print(Sequences.heads(4) , (d) print(Sequences.Heads(4)), , , 13. Command to create empty Series is, (a) s=pd.emptySeires(), (b) s=pd.Series(empty), , (c) s=pd.Series(), , (d) s=pd.Series(NaN), , G, , 14. Gurjeet has created a Series S but forgot to give the index values. Choose the command that will be used to give, index values, , (a) S.newindex=[10,20,30,40,50], (b) S.index=[10,20,30,40,50], , (c) S.Series(index=[10,20,30,40,50]), (d) S.modifyindex=[10,20,30,40,50], , 26, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 34 :
15. Command to assign a name for the indexes, , (a) S.indexname, (b) S.name.index, , (c) S.index.name, , (d) S.nameindex, , 16. A Series represents ________ column(s) in memory., , (a) Single, (b) Double, , (c) Multiple, , (d) all of these, , 17. Pandas Series is capable of holding ______data type., (a) only integer, (b) only string, , as, ha, n, , , , (c) only integer and string (d) any, , 19. Write python series to print scalar value “10” 5 times, , (a) s = pd.Series(10, index=[5]) , , (c) s = pd.Series(10, index=[10*5]), , Pr, ak, , 18. Write single line Pandas statement to declare a Pandas series named Packets having tuple dataset as:, 125, 92, 104, 92, 85, 116, 87, 90, , (a) Packets = pd.Series((125, 92, 104, 92, 85, 116, 87, 90)), , (b) Packets = pd.Series([125, 92, 104, 92, 85, 116, 87, 90]), , (c) Packets = pd.Series({125, 92, 104, 92, 85, 116, 87, 90}), , (d) None of the above, , (b) s = pd.Series(10, index=[10,5]), (d) s = pd.Series(10, index=[11,12,13,14,15), , 20. Write a single line command to create a series by given list C and index values, C=[‘red’,’green’,’blue’] , index values=[‘r’,’g’,’b’], , (a) p=pd.Series(C,index=[‘r’,’g’,’b’]), (b) p=pd.Series(list=C,index=[‘r’,’g’,’b’]), , (c) p=pd.Series(C]) , (d) p=pd.Series(values=C,index=[‘r’,’g’,’b’]), , he, , rs, , 21. Aman wants to create the series with the following list and index values. He asked his friends for help and received, muliple answers from friends. But one of the answers is incorrect, you have to identify the incorrect answer., List=[‘Laptop’,’Pendrive’,’Harddisk’], index values=[‘L’,’P’,’H’], , (a) import pandas as pd, , oy, , al, , Br, , ot, , L=[‘Laptop’,’Pendrive’,’Harddisk’], p=pd.Series(list=L,index=[‘L’,’P’,’H’]), print (p), , (b) import pandas as pd, L=[‘Laptop’,’Pendrive’,’Harddisk’], p=pd.Series(data=L,index=[‘L’,’P’,’H’]), print (p), , (c) import pandas as pd, L=[‘Laptop’,’Pendrive’,’Harddisk’], p=pd.Series(L,index=[‘L’,’P’,’H’]), print (p), , (d) import pandas as pd, L=[‘Laptop’,’Pendrive’,’Harddisk’], p=pd.Series(L,[‘L’,’P’,’H’]), print (p), , 22. Two Seies M1 and M2 are given alongside., , G, , (i) Write code to display the sum of M1 and M2, (a) print (sum(M1,M2)), (b) print(M1+M2), (c) print(M1.add(M2)), (d) print(M1.sum(M2)), , M1, , M2, , 1, , 67, , 1, , 78, , 2, , 90, , 2, , 95, , 3, , 34, , 3, , 67, , 4, , 56, , 4, , 23, , 5, , 77, , 5, , 45, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 27
Page 35 :
(ii) Write code to print the mean of all elements of M1, (a) print(M1.mean()) (b) print(mean(M1), , (c) print(means(M1)), , (d) print(M1.means()), , , , (iii) Show rows where M1 greater than 75, (a) print(M1>75), (b) (print(M1[M1>75]), , (c) print(M1>’75’), , (d) print(M1(M1>75)), , , , , (iv) Set the series name “Marks1” of M1 series, (a) M1.seriesname=”Marks1”, (c) M1.newname=”Marks1”, , (b) M1.name=”Marks1”, (d) M1.setname=”Marks1”, , as, ha, n, , , , Pr, ak, , 23. A Series S is given below:, 101 Harsh, 102 Arun, 103 Ankur, 104 Harpahul, 105 Divya, 106 Jeet, With reference to the above question, write the answer., (i) Choose the command that will give the following output, , 102, Arun, , 103, Ankur, , 104, Harpahul, , (a) print(S.loc[2:4]) , (b) print(S.iloc[1:4]), , (c) print(S[1:3]) , (d) print(S[102,103,104]), , (ii) Delete the value against index 105. Help him to choose the suitable option to do so:, (a) S=S.delete(105) , (b) S=S.remove(105), (c) S=S.del(105) , (d) S=S.drop(105), , , , , (iii) Write the command which will display the rows having name=”Ankur”, (a) print(S==”Ankur”) , (b) print(S[S.”Ankur”]), (c) print(S[S==”Ankur”]) , (d) print(S=’Ankur”), , , , (iv) Choose the command that will not give the following output, 104, Harpahul, 105, Divya, 106, Jeet, (a) print(S.tail(3)), (b) print(S.loc[104:]), (c) print(S.iloc[3:6]), , , , , (v) Command to give the name “EMPCODE” to index values, (a) S.index.name=”EMPCODE”, (b) S.name.index=”EMPCODE”, (c) S.indexname=”EMPCODE”, (d) S.nameindex=”EMPCODE”, , Br, , ot, , he, , rs, , , , , al, , (vi) Change the index values to 1,2,3,4,5,6, (a) S.newindex=[1,2,3,4,5,6], (c) S.index=[1,2,3,4,5,6] , , , , , (d) print(S.iloc[-3:]), , (b) S.changeindex=[1,2,3,4,5,6], (d) S.indexvalues=[1,2,3,4,5,6], , G, , oy, , 24. Pushp, a student of class-XII, has been assigned a code to create a panda series S1, as shown below. [CBSE QB], a 100, b 200, c 300, d 400, e 500, dtype: int64, With reference to the above question, write the answer., , 28, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 36 :
(i) Choose the command that will give the following output, b, 00, c, 300, dtype: int64, (a) print(S1[:3]) , (c) print(S1[1:3]) , , (b) print(S1[0:3]), (d) print(S1[2:4]), , as, ha, n, , , , , , , , (ii) Help him to identify the correct statement that can be used to extract the value with the index ‘c’, (a) print(S1[c]), (b) print(S1(c)), (c) print(‘S1’ [‘c’]), (d) print(S1 [‘c’]), , , , (iii) Which of the following command will give the following output, b, , 200, , , , d, , 400, , , , , , dtype: int64, (a) print(S1.iloc[1:4]) , (c) print(S1.iloc(1:4)) , , (b) print(S1.iloc[2:4]), (d) print(S1.iloc[1:4:2]), , Pr, ak, , , , (iv) Which of the following command will display the series by adding 10 in each value., (a) print(S1 [+10]) , (b) print(S1+10), (c) print(S1)+10 , (d) print(S1)+print(10), , , , , (v) Pushp wants to delete the value against index ‘d’. Help him to choose the suitable option to do so:, (a) S1=S1.drop(d) , (b) S1=S1.drop(‘d’), (c) S1=drop(‘d’) , (d) S1=S1.drop[‘d’], , rs, , , , , 25. Answer the following program based on the series given below., list1=[1,2,3,4,5,6,7,8], , he, , import pandas as pd, , [CBSE QB], , list2=[‘swimming’,’tt’,’skating’,’kho kho’, ‘bb’, ‘chess’, ‘football’,”cricket”], school=pd.Series(list1,index=list2), , ot, , school.name=(“little”), print (school*2), , # statement 1, , print (school[“tt”]), , # statement 3, , # statement 2, , Br, , print (school.tail(3)), print (school[2:4]), , # statement 4, , (i) Choose the correct name of the series object given above., (a) list1, (b) list2, (c) school, , , , (d) little, , al, , (ii) Choose the correct output for the statement:, print (school.tail(3)) # statement 2, , G, , oy, , , (a) swimming 1 , (b) chess 6, tt 2, football 7, skating 3 cricket 8, , (iii) Choose the correct output for the statement:, print (school[“tt”]). # statement 3, , (a) 2, (b) 3, , (c) 4, , , (d), , , , , , (c) tt 2, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , kho kho 4, bb 5, chess 6, football 7, cricket 8, , (d) true, 29
Page 37 :
3. (a), 13. (c), (a), (d), (d), (b), , 4. (b), 14. (b), , (iii), (iii), (iii), (iii), , (b), (c), (d), (a), , ANSWERS, , 5. (d), 15. (c), (iv), (iv), (iv), (iv), , (b), (c), (b), (a), , , (d) swimming 1, tt 4, skating 9, kho kho 16, bb 25, chess 36, football 49, cricket 64, , 6. (b), 16. (a), , (v) (a), (v) (b), (v) (b), , 7. (c), 17. (d), , 8. (b), 18. (a), , 9. b, 19. (d), , 10. (a), 20. (a), , (vi) (c), , rs, , (b), 2. (c), (b) 12. (a), (a), (i) (b), (ii), (i) (b), (ii), (i) (c), (ii), (i) (d), (ii), , swimming False, tt False, skating True, kho kho True, bb True, chess True, football True, cricket True, , G, , oy, , al, , Br, , ot, , he, , 1., 11., 21., 22., 23., 24., 25., , , (c), , , , , , , , , , (d) skating 3, kho kho 4, bb 5, chess 6, football 7, cricket 8, , Pr, ak, , (v) The correct output of the statetment:, print (school*2) # statement 1 will be., , (a) swimming 3 , (b) swimming 2, tt 4, tt 4, skating 5, skating 6, kho kho 6, kho kho 8, bb 7, bb 10, chess 8, chess 12, football 9, football 14, cricket 10, cricket 16, , # statement 4., , (c) skating 3, kho kho 4, bb 5, , as, ha, n, , (iv) Identify the correct output for:print (school[2:4]), , (a) skating 3, , (b) tt 2, kho kho 4, skating 3, kho kho 4, , 30, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 38 :
2, , as, ha, n, , DataFrame, , The parameters of the constructor are as follows:, Parameter, , Description, , Data, , Data takes various forms like ndarray, series, map, lists, dict, constants and also another, DataFrame., , 2., , index, , For the row labels, the Index to be used for the resulting frame is Optional Default, np.arrange(n) if no index is passed., , 3., , columns, , For column labels, the optional default syntax is - np.arrange(n). This is only true if no, index is passed., , 4., , dtype, , Data type of each column, , 5., , copy, , he, , rs, , 1., , ot, , Sr.No, , Pr, ak, , A pandas DataFrame is a two (or more) dimensional data structure – basically a table with rows and columns. The, columns have names and the rows have indexes. For instance, the price can be the name of a column and 2,3 the price, values., Item Price, A picture of a Pandas DataFrame is shown alongside:, 0, A, 2, In general, you could say that the Pandas DataFrame consists of three main components: the data, the, 1, B, 3, index, and the columns. A pandas DataFrame can be created using the following constructor pandas., DataFrame (data, index, columns, dtype, copy)., , This command (or whatever it is) is used for copying data, if the default is False, , Br, , CREATE DATAFRAME, , A pandas DataFrame can be created using various inputs like:, ● Lists, ● Tuple, ● Dictionary, ● Series, ● Numpyndarrays, ● Another DataFrame, , al, , Create an Empty DataFrame, A basic DataFrame, which can be created is an Empty Dataframe., , oy, , 1. Write python program to create an empty dataframe., Ans. import pandas as pd, df=pd.DataFrame(), print (df), , G, , , OUTPUT:, Empty DataFrame, Columns: [ ], Index: [ ], Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 31
Page 39 :
Create a DataFrame from List, The DataFrame can be created using a single list or a list of lists., , as, ha, n, , 2. Create a dataframe df from the given list lst, lst=[‘red’,’green’,’blue’,’yellow’], Ans. import pandas as pd, , lst=[‘red’,’green’,’blue’,’yellow’], df=pd.DataFrame(lst), , print (df), , , 0, 0 red, 1, green, 2, blue, 3 yellow, , Pr, ak, , #Change index, , In the last example, we did not pass any index, so by default, it assigned the indexes ranging from 0 to len(data)-1,, i.e., 0 to 3. If you want to set new index values you can do it by using index attribue., 3. Modify the above program and set index value=r,g,b,y, Ans. import pandas as pd, , lst=[‘red’,’green’,’blue’,’yellow’], df=pd.DataFrame(lst,index=[‘r’,’g’,’b’,’y’]), print (df), , he, , rs, , 0, r red, g green, b blue, y yellow, , #With column name, , ot, , As you can see in the above question, by default 0 column name is displayed. You can change the column name by, using columns attribute., , Br, , 4. Modify the above program and set the column name as ‘Colors’, Ans. import pandas as pd, , lst=[‘red’,’green’,’blue’,’yellow’], df=pd.DataFrame(lst,index=[‘r’,’g’,’b’,’y’],columns=[“Colors”]), print (df), , oy, , al, , , Colors, r red, g green, b blue, y yellow, , #With list of lists, , G, , You can display more than one column in dataframe by using list of lists., 5. Karambir created a list(lst) of top 4 students in maths. He wants to show it in tabular form. Create a DataFrame, by using list 1st with headings name and marks., lst=[[‘Sanjay’,95],[‘Suman’,97],[‘Pahul’,88],[‘Divya’,72]], , 32, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 41 :
lst=[[‘Nidhi’,95],[‘Gurjeet’,97],[‘Pahul’,88],[‘Divya’,72]], , , 1, 2, 3, 4, , name, Nidhi, Gurjeet, Pahul, Divya, , marks, 95.0, 97.0, 88.0, 72.0, , Create a DataFrame from Tuple, , DataFrame can also be created by Tuple., 9. Create a dataframe df by using given tuple t(10,20,30)., Ans. import pandas as pd, df=pd.DataFrame(t), print (df), , output:, 0, 0 10, 1 20, 2 3, , Create a DataFrame from Dictionary, , Pr, ak, , t=(10,20,30), , as, ha, n, , df=pd.DataFrame(lst,columns=[‘name’,’marks’],index=[1,2,3,4],dtype=float), , print (df), , rs, , When dataframe is created by using Dictionary, keys of dictionary are set as columns of DataFrame. You can change, the order of columns and store specified columns. If you try to change the column name, NaN will be displayed., , he, , Note: Column name values must be same as dictionary keys., 10. Write python code to create a Dictionary Dic to store roll, name and marks of 3 students. Convert Dic into, dataframe df and display the dataframe df., Ans. import pandas as pd, , ot, , Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, df=pd.DataFrame(Dic), print (df), , roll, 1, 2, 3, , name, a, b, c, , marks, 24, 53, 66, , Br, , , 0, 1, 2, , al, , Change columns position, , oy, , You can change the positions of columns defined in dictionary by setting the order of columns with columns command., 11. Give the output, , import pandas as pd, Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, df=pd.DataFrame(Dic,columns=[‘roll’,’marks’,’name’]), print (df), , G, , Ans. , 0, 1, 2, , 34, , roll, 1, 2, 3, , marks, 24, 53, 66, , name, a, b, c, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 42 :
Take specific column(s), Instead of storing all columns, you can set specified column(s) to dataframe., 12. From the Dictionary Dic set only roll and mark with dataframe df., Ans. import pandas as pd, df=pd.DataFrame(Dic,columns=[‘roll’,’marks’]), print (df), , as, ha, n, , Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, , , roll marks, 0, 1 24, 1, 2 53, 2, 3 66, when column name is not same as keys values: if Dictionary keys name is not same the dataframe columns name, then it will display NaN values in dataframe column., , Pr, ak, , 13. Give the output, , import pandas as pd, , Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, df=pd.DataFrame(Dic,columns=[‘roll’,’eng_marks’]), , Ans. , 0, 1, 2, , roll, 1, 2, 3, , eng_marks, NaN, NaN, NaN, , Create a DataFrame from Series, , rs, , print (df), , he, , 14. Write a python code to create a dataframe from the given series S., Ans. import pandas as pd, , roll, 0 1, 1 2, 2 3, 3 4, , Br, , print (df), , ot, , L=[1,2,3,4], S=pd.Series(L), df=pd.DataFrame(S,columns=[‘roll’]), , al, , Create a DataFrame from Numpy ndarrays, 15. Give the output, , oy, , import pandas as pd, import numpy as np, data=np.array([‘mon’,’tue’,’wed’]), p=pd.DataFrame(data,columns=[‘Month’]), print (p), , G, , Ans. Month, 0 mon, 1 tue, 2 wed, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 35
Page 43 :
With columns name and changed index values, 16. Modify the above program set the column name ‘DayName’ and index values [1,2,3], Ans. import pandas as pd, data=np.array([‘mon’,’tue’,’wed’]), , p=pd.DataFrame(data,columns=[‘DayName’],index=[1,2,3]), print (p), , Day , 1, , 2, , 3, , , Name, mon, tue, wed, , as, ha, n, , import numpy as np, , ATTRIBUTES OF DATAFRAME, , Pr, ak, , We have learned what a DataFrame is and how to create one. Now we will study about “Attributes of DataFrame”,, which are useful to fetch information related to a particular DataFrame., SYNTAX, <DataFrameObject>. <attribute_name>, , (v) Size, , rs, , Some attributes are:, (i) Index, (ii) Columns, (iii) Axes, (iv) Dtypes, (vi) Shape, (vii) Ndim, (viii) Empty, (ix) T, We will explain all these attributes by using the dataframe given below import pandas as pd, d={‘Rollno’:(1,2,3,4),’Name’:(‘Aman’,’Preeti’,’Kartik’,’Lakshay’),’, , CGPA’:(8.7,8.9,9.2,9.4),’Stream’: (‘Science’,’Arts’,’Science’,’Commerce’)}, , he, , df=pd.DataFrame(d,index=[‘st1’,’st2’,’st3’,’st4’]), print(df), , OUTPUT:, , ot, , Rollno, , St2, St3, , CGPA, , Stream, , Aman, , 8.7, , Science, , 2, , Preeti, , 8.9, , Arts, , 3, , Kartik, , 9.2, , Science, , 4, , Lakshay, , 9.4, , Commerce, , al, , St4, , 1, , Br, , St1, , Name, , G, , oy, , (i) index : This attribute is used to fetch the index’s names, if index name is given then it would be the same, names given to dataframe as in our example, indexes are: st1,st2,st3,st4 otherwise as default index names, 0,1,2,3 and so on., print(df.index), OUTPUT:, Index([‘st1’, ‘st2’, ‘st3’, ‘st4’], dtype=’object’), (ii) Columns : This attribute is used to fetch the column’s names, as in this case it should give column name as:, Rollno,Name,CGPA,Stream., print(df.columns), , 36, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 44 :
as, ha, n, , , OUTPUT, Index([‘Rollno’, ‘Name’, ‘CGPA’, ‘Stream’], dtype=’object’), (iii) Axes: This attribute is used to fetch both index and column names., print(df.axes), OUTPUT:, [Index([‘st1’, ‘st2’, ‘st3’, ‘st4’], dtype=’object’), Index([‘Rollno’, ‘Name’, ‘CGPA’, ‘Stream’], dtype=’object’)], you can use axes[0] to fetch the index names as same output get by index attributes., print(df.axes[0]), OUTPUT:, index([‘st1’, ‘st2’, ‘st3’, ‘st4’], dtype=’object’), , axes[1] can be used to fetch column’s names same as by columns attributes., print(df.axes[1]), , G, , oy, , al, , Br, , ot, , he, , rs, , Pr, ak, , OUTPUT:, Index([‘Rollno’, ‘Name’, ‘CGPA’, ‘Stream’], dtype=’object’), (iv) dtypes: This attribute is used to fetch the data type values of the items in the DataFrame., print(df.dtypes), OUTPUT:, Rollno, int64, Name, object, CGPA, float64, Stream, object, dtype:, object, (v) size: This attribute is used to fetch the size of the DataFrame, which is the product of the number of rows and, columns.Here, in our example we have 4 rows and 4 columns, so 4*4 i.e. 16 is the size of our DataFrame., print(df.size), OUTPUT:, 16, (vi) shape: This attribute returns the number of rows and number of columns available in dataframe. In our case there, are 4 rows and 4 columns in dataframe so it will return (4,4), print(df.shape), OUTPUT:, (4,4), (vii) ndim: This attribute is used to fetch the dimension of the given DataFrame. Like if it is 1-D, 2-D, or 3-D. We, are working on 2-D Data Structure so it will return 2., print(df.ndim), OUTPUT:, 2, (viii) empty: This attribute gives you a Boolean output in the form of true or false, if dataframe is empty it will return, true otherwise false., print(df.empty), , OUTPUT, False, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 37
Page 45 :
OUTPUT:, , Rollno, Name, CGPA, , st1, 1, Aman, 8.7, , st2, 2, Preeti, 8.9, , st3, 3, Kartik, 9.2, , st4, 4, Lakshay, 9.4, , Stream, , Science, , Arts, , Science, , Commerce, , ACCESSING DATA, Accessing using head(), , as, ha, n, , (ix) T: This attribute is used to transpose the DataFrame; i.e., rows become columns and columns become rows, print(df.T), , By default head() function display top 5 rows. To print n no of top rows, pass n as parameter i.e. Dataframe. head(n), , Pr, ak, , 17. Give the output:, Ans. import pandas as pd, , Dic={‘empno’:(101,102,103,104,105,106),’grade’:(‘a’,’b’,’a’,’c’,’b’,’c’),’dept’:, (‘sales’,’pur’,’mar’,’sales’,’pur’,’mar’)}, print(df.head(3)), , , 0, 1, 2, , empno, 101, 102, 103, , grade, a, b, a, , he, , 18. Give the output, , dept, sales, pur, mar, , rs, , df=pd.DataFrame(Dic), , Ans. import pandas as pd, , , Dic={‘empno’:(101,102,103,104,105,106),’grade’:(‘a’,’b’,’a’,’c’,’b’,’c’),’dept’:, , ot, , (‘sales’,’pur’,’mar’,’sales’,’pur’,’mar’)}, df=pd.DataFrame(Dic), , , , Br, , print(df.head()[[‘empno’,’dept’]]), , empno, , dept, , 101, , sales, , 102, , pur, , 2, , 103, , mar, , 3, , 104, , sales, , 4, , 105, , pur, , 0, , oy, , al, , 1, , G, , This above code first selects the first 5 rows of our data set. And then it takes only the ‘empno’ and the ‘dept’, columns, when value of passed parameter in head function is larger than the no of rows available in dataframe., , 19. What will be displayed when you passed any ‘n’ value in head function to display top ‘n’ rows but no of rows, in dataframe is less than ‘n’ value?, , Ans. In this case it will display maximum rows(all rows). In the above example, if we write print(df.head(10)) then, all the rows(6 rows) will be displayed., , 38, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 46 :
Accessing using tail(), By tail() function display last 5 rows. To print n no of last rows, pass n as parameter i.e.DataFrame.tail(n), 20. Give the output, , empno, 102, 103, 104, 105, 106, , grade, b, a, c, b, c, , dept, pur, mar, sales, pur, mar, , Pr, ak, , Ans. , 1, 2, 3, 4, 5, , as, ha, n, , import pandas as pd, Dic={‘empno’:(101,102,103,104,105,106),’grade’:(‘a’,’b’,’a’,’c’,’b’,’c’),’dept’:, (‘sales’,’pur’,’mar’,’sales’,’pur’,’mar’)}, df=pd.DataFrame(Dic), print(df.tail()), , PRACTICE QUESTIONS I, 1. Write a suitable Python code to create an empty dataframe., Ans. import pandas as pd, df=pd.DataFrame(), print(df), , [SP 2019-20], , rs, , 2. Hitesh wants to display the last four rows of the dataframe df and has written the following code :, df.tail(), , he, , But last 5 rows are being displayed. Identify the error and rewrite the correct code so that last 4 rows get, displayed. , [sp 2019-20], Ans. df.tail(4), , ot, , 3. Write a python code to create a dataframe with appropriate headings from the list given below, , [SP 2019-20], , [‘S101’, ‘Amy’, 70], [‘S102’, ‘Bandhi’, 69], [‘S104’, ‘Cathy’, 75], [‘S105’,’Gundaho’, 82], Ans. import pandas as pd, , Br, , data = [[‘S101’, ‘Amy’, 70], [‘S102’, ‘Bandhi’, 69], [‘S104’,’Cathy’, 75], [‘S105’,, ‘Gundaho’, 82]], df = pd.DataFrame(data, columns = [‘ID’, ‘Name’, ‘Marks’]), print(df ), , OR, , oy, , al, , , import pandas as pd, , data, =, {‘ID’:[‘S101’,, ‘S102’,‘S104’,‘S105’],’Name’:[‘Amy’,, ‘Bandhi’,’Cathy’,‘Gundaho’],’Marks’:[70,69,75,82]}, df = pd.DataFrame(data), print(df ), , 4. Write a python code to create a dataframe from the list given below with “Marks” heading, , G, , L=[29,42,55,22,84,56], Ans. import pandas as pd, , L=[29,42,55,22,84,56], , df=pd.DataFrame(L,columns=”Marks”), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 39
Page 47 :
5. Write python code to create the data frame that looks like this:, Empno, sales, marketing, (ii) using List, , dic={‘empno’:(101,102),’Dept’:(‘sales’,’marketing’)}, df=pd.DataFrame(dic), print(df), , (ii) import pandas as pd, , L=[[101,’sales’],[102,’marketing’]], , df=pd.DataFrame(L,columns=[‘Empno’,’Dept’]), print(df), , 1, 20, , 2, 30, , rs, , 10, 20, 30, 40, 50, 0, 10, , 3, 40, , 4, 50, , ot, , Ans. (i) 0, 0, 1, 2, 3, 4, (ii) , 0, , he, , L=[10,20,30,40,50], df=pd.DataFrame(L), print(df), (ii) import pandas as pd, L=[[10,20,30,40,50]], df=pd.DataFrame(L), print(df), , Pr, ak, , 6. Give the output, (i) import pandas as pd, , as, ha, n, , 0, 101, 1, 102, (i) using Dictionary, Ans. (i) import pandas as pd, , Dept, , 101, 102, , Br, , 7. Write python code to create the dataframe emp using dictionary:, Name, , Salary, , Rohan, Aman, , 200000, 250000, , Ans. import pandas as pd, , al, , emp = pd.DataFrame({‘Name’:[‘Rohan’,’Aman’],’Salary’:[20000,25000]},index=[101,102]);, print(emp), , or, , oy, , import pandas as pd, Dic= {‘Name’:[‘Rohan’,’Aman’],’Salary’:[20000,25000]}, emp = pd.DataFrame(Dic,index=[101,102]);, print(emp), , G, , 8. Write python code to display top 3 records from DataFrame DF, Ans. DF.head(3), 9. Fill in the blank:, , import pandas as pd, 40, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 48 :
import numpy as np, , data=____.array([‘red’,’green’,’blue’]), print (p), Ans. import pandas as pd, import numpy as np, data=np.array([‘mon’,’tue’,’wed’]), p=pd.DataFrame(data), print (p), , 10. Find the errors and rewrite the corrected program, , import pd as pandas, , lst=[‘red’,’green’,’blue’,’yellow’], , as, ha, n, , ___=____.DataFrame(____), , df=pd.dataframe(lst,index=[‘r’,’g’,’b’,’y’],headings=[‘Colour’]), , Pr, ak, , print (df), Ans. import pandas as pd, lst=[‘red’,’green’,’blue’,’yellow’], df=pd.DataFrame(lst,index=[‘r’,’g’,’b’,’y’],columns=[‘Colour’]), print (df), , 11. Write a small python code to create a dataframe with headings (a and b) from the list given below:, [[1,2],[3,4],[5,6],[7,8]], [SP 2019-20], Ans. import pandas as pd, , rs, , L=[[1,2],[3,4],[5,6],[7,8]], df = pd.DataFrame(L,columns = [‘a’,’b’]), print(df), , ot, , he, , a b, 0 1 2, 1 3 4, 2 5 6, 3 7 8, , OR, , Br, , import pandas as pd, Dic={‘a’:[1,3,5,7],’b’:[2,4,6,8]}, df = pd.DataFrame(Dic), print(df), , 12. Find the output of the following code:, , [SP 2019-20], , oy, , al, , import pandas as pd, data = [{‘a’: 10, ‘b’: 20},{‘a’: 6, ‘b’: 32, ‘c’: 22}], df1 = pd.DataFrame(data, index=[‘first’, ‘second’], columns=[‘a’, ‘b’]), df2 = pd.DataFrame(data, index=[‘first’, ‘second’], columns=[‘a’, ‘b1’]), print(df1), print(df2), , G, , Ans. a b, first, 10, second 6, a, first, 10, second 6, , 20, 32, b1, NaN, NaN, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 41
Page 49 :
COLUMNS IN DATAFRAME, Column Selection, , as, ha, n, , 21. Sangeeta has created a dataframe with columns- name and marks but wants to display only name column. She, has written the code but getting some errors, help sangeeta and recifty the errors., import pandas as pd, , #statement 1, , lst=[[‘Nidhi’,95],[‘Gurjeet’,97],[‘Pahul’,88],[‘Divya’,72]] #statement 2, df=pd.DataFrame(lst,columns=[‘name’,’marks’]) #statement 3, print (name) #statement 4, , Pr, ak, , Ans. error in statement 4, print (df[‘name’]), , OUTPUT, 0 Nidhi, 1 Gurjeet, 2 Pahul, 3 Divya, , When column name does not exist: What would be the result if you try to access coulumn(s) which does not, exist in dataframe? In the above example if we try to access ‘rollno’ column, key error will be raised., , print(df[‘rollno’]), , OUTPUT:, KeyError: ‘rollno’, , rs, , Adding New Column, , he, , (i) Direct Method: You can add new column by simply passing the new column name to dataframe and assign new, values. This is the simplest method to add new column, but new column will be added only at the last position of the, dataframe, Syntax:, dataframe[new column name]=assign new values, , ot, , 22. import pandas as pd, , Br, , Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, df=pd.DataFrame(Dic), _________________ #statement 1, print(df), , al, , Fill the statement 1 to add new column age in dataframe df with some values, Ans. df[‘age’]=[18,20,19], , OUTPUT, , roll, name marks age, 1, , a, , 24, , 18, , 1, , 2, , b, , 53, , 20, , oy, , 0, , G, , 2, 3, c, 66, 19, If length of new column value is bigger/smaller than length of index then it’ll raise Value error : Length of, values does not match length of index., Consider the above example, if we assign four values to age column instead of three values:, df[‘age’]=[18,20,19,17] then ValueError will be raised., , OUTPUT:, ValueError: Length of values (4) does not match length of index (3), , 42, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 50 :
23. Write single line satetement to add new column ‘Sales’ in dataframe COMPANY with [50000,20000,45000,84000], values., Ans. COMPANY[‘Sales’]= [50000,20000,45000,84000], 24. Create the dataframe “EMP”, Basic, , Da, , Sanya, , 9500, , 3000, , Krish, , 7000, , 5000, , Rishav, , 9650, , 1500, , Deepak, , 7500, , 2000, , Kriti, , 9200, , 1800, , 2000, , 1900, , 2100, 2700, , 500, , Pr, ak, , Perform the following operations on the DataFrame :, 1. Calulate sum of Basic, Da and Hra and assign to column “Salary”, 2. Disply Dataframe, 3. Display the name of columns, 4. Count the no of columns., Ans. import pandas as pd, , Hra, , as, ha, n, , Names, , Da, Hra, Salary, 3000, 2000, 14500, 5000, 1900, 13900, 1500, 2100, 13250, 2000, 2700, 12200, 1800, 500, 11500, ‘Hra’, ‘Salary’], dtype=’object’), , Br, , ot, , he, , Output, , Names, Basic, 0, Sanya, 9500, 1, Krish, 7000, 2, Rishav, 9650, 3, Deepak, 7500, 4, Kriti, 9200, Index([‘Names’, ‘Basic’, ‘Da’,, no of columns 5, , rs, , EMP = pd.DataFrame({‘Names’:(‘Sanya’,’Krish’,’Rishav’,’Deepak’,’Kriti’),’Basic’:(9500,, 7000, 9650, 7500, 9200),’Da’ : (3000, 5000, 1500, 2000, 1800),’Hra’ : (2000, 1900,, 2100, 2700, 500)}), 1. EMP[‘Salary’]=EMP.Basic+EMP.Da+EMP.Hra, 2. print(EMP), 3. print(EMP.axes[1]), # or print(EMP.columns), 4. print(“no of columns”,len(EMP.axes[1])), , 25. Write a single line command to calculate 10% from ‘sale’ column from dataframe df and assign to new column, ‘Commission’, Ans. df[‘Commission’]=df.sale*10/100, , oy, , al, , (ii) Using insert function : By using insert function you can insert new column at any position in dataframe., 26. Write code to add new column age at 3rd location using insert function., Ans. import pandas as pd, a=[18,20,19], , Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, df=pd.DataFrame(Dic), , G, , print(df), , df.insert(3,’age’,a), # or df.insert(loc=3,column=’age’,value=a) or, df.insert(3.’age’,[18,20,19]), print(df), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 43
Page 51 :
name, a, b, c, name, a, b, c, , marks, 24, 53, 66, marks, 24, 53, 66, , age, 18, 20, 19, , 27. Write the code to add new column ‘age’ in dataframe df using .loc, Ans. import pandas as pd, , as, ha, n, , OUTPUT:, , roll, 0, 1, 1, 2, 2, 3, , roll, 0, 1, 1, 2, 2, 3, (iii) Using loc:, , Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, df=pd.DataFrame(Dic), df.loc[:,’age’]=[18,20,19], , Pr, ak, , print(df), , OUTPUT, , roll, name marks age, 0, 1, a, 24, 18, 1, 2, b, 53, 20, 2, 3, c, 66, 19, The colon indicates that we want to select all the rows. In the column part, we specify the labels of the columns, to be selected. Since the dataframe does not have column ‘age’, Pandas creates a new column., , rs, , Column Deletion, , he, , #using del function: del can be used to delete any column from dataframe., Syntax:, del dtaframe[columnname], del operates only on one at a time. del is an in-place operation only., , ot, , 28. Give the output, , import pandas as pd, , Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, , Br, , inx=[‘A1’,’A2’,’A3’,’A4’], , df=pd.DataFrame(Dic,index=inx), print(df), , del df[‘name’], print(df), , empno, 101, 102, 103, 104, empno, 101, 102, 103, 104, , name, a, b, c, d, salary, 3000, 5000, 8000, 9000, , G, , oy, , al, , Ans. , A1, A2, A3, A4, , A1, A2, A3, A4, , 44, , salary, 3000, 5000, 8000, 9000, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 52 :
# using drop(), , S.N., , as, ha, n, , Drop() function: It accepts a single Label Name or list of Labels and deletes the corresponding columns or rows (based, on axis) with that label. To drop column, we need to provide axis=1 as another argument to drop function. By default, it doesn’t modify the existing DataFrame, instead it returns a new dataframe. Set the value inplace=True if you need, to drop column in existing dataframe otherwise changes will not take effect in existing dataframe or you can simply, return the changes in new dataframe., 29. What is the difference between del and drop?, Ans. Difference between:, del, , drop, , (i), , del operates on column only., , drop operates on both columns and rows., , (ii), , del operates only on one at a time., , drop can operate on multiple items at a time., , (iii), , del is an in-place operation only., , drop can operate in-place or return a copy., , Pr, ak, , 30. Write program to delete the column name from dataframe df using drop function, changes should take effect in, existing dataframe., Ans. import pandas as pd, , salary, 3000, 5000, 8000, 9000, , he, , name, a, b, c, d, salary, 3000, 5000, 8000, 9000, , ot, , empno, 101, 102, 103, 104, empno, 101, 102, 103, 104, , Br, , , A1, A2, A3, A4, , A1, A2, A3, A4, , rs, , Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, inx=[‘A1’,’A2’,’A3’,’A4’], df=pd.DataFrame(Dic), df.index=inx, print(df), , df.drop(‘name’,1,inplace=True), #or df.drop(‘name’,axis=1,inplace=True) or df=df., drop(‘name’,1), print(df), , al, , 31. Write single line command to delete the column ‘name’ from dataframe df using drop function, changes should, take effect in new dataframe., Ans. df1=df.drop(‘name’,1), , oy, , # using drop (multiple columns), 32. Write program to delete name and salary column from dataframe df using drop function., Ans. import pandas as pd, , G, , Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, inx=[‘A1’,’A2’,’A3’,’A4’], , df=pd.DataFrame(Dic,index=inx), df=df.drop([‘name’,’empno’],1), print(df), , # df=df.drop([‘name’, ’empno’],axis=1), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 45
Page 54 :
36. Change the column name ‘b’ to ‘B’ using rename() function, Ans. import pandas as pd, , Pr, ak, , df = pd.DataFrame({‘a’: [1, 2, 3], ‘b’: [4, 5, 6]}), print(df), df.rename(columns={‘b’: ‘B’},inplace=True), print(df), , as, ha, n, , , a b, 0 1 4, 1 2 5, 2 3 6, A B, 0 1 4, 1 2 5, 2 3 6, #By rename() function: Rename() is used to rename specific column(s) or all columns., df.rename(columns={‘oldName1’: ‘newName1’, ‘oldName2’: ‘newName2’}, inplace=True), , he, , rs, , , a b, 0 1 4, 1 2 5, 2 3 6, a B, 0 1 4, 1 2 5, 2 3 6, Set the value inplace=True if you need to do changes in column name in existing dataframe otherwise changes, will not take effect in existing dataframe or you can simply return the changes in new dataframe as shown in the, example given below., , ot, , import pandas as pd, df = pd.DataFrame({‘a’: [1, 2, 3], ‘b’: [4, 5, 6]}), print(df), df1=df.rename(columns={‘b’: ‘B’}), print(df1), , Br, , Change all column names, , 37. Write python code to change all column names using rename function., Ans. import pandas as pd, , al, , df = pd.DataFrame({“a”: [1, 2, 3], “b”: [4, 5, 6]}), print(df), df.rename(columns={“a”: “A”, “b”: “B”}), print(df), , G, , oy, , , a b, 0 1 4, 1 2 5, 2 3 6, a b, 0 1 4, 1 2 5, 2 3 6, Not geting the desired output? Because inplace=True is not given, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 47
Page 55 :
import pandas as pd, df = pd.DataFrame({“a”: [1, 2, 3], “b”: [4, 5, 6]}), print(df), df.rename(columns={“a”:“A”, “b”: “B”}, inplace=True), print(df), , as, ha, n, , , Remember to specify inplace=True:, , 38. Give the output of the following program, , import pandas as pd, , Pr, ak, , , a b, 0 1 4, 1 2 5, 2 3 6, A B, 0 1 4, 1 2 5, 2 3 6, , #Other method: Another method can be used to raname the column name using rename() without columns option., Specify the axis=1 or axis=’columns’ with rename function., df.rename({‘oldName1’: ‘newName1’, ‘oldName2’: ‘newName2’}, axis=1,inplace=True), OR, df.rename({‘oldName1’: ‘newName1’, ‘oldName2’ : ‘newName2’}, axis= ’columns’,inplace=True), , , 0, 1, 2, , X, 1, 2, 3, , Y, 4, 5, 6, , he, , b, 4, 5, 6, , ot, , a, 1, 2, 3, , Br, , Ans. , 0, 1, 2, , rs, , df = pd.DataFrame({‘a’: [1, 2, 3], ‘b’: [4, 5, 6]}), print(df), df.rename({‘a’: ‘X’, ‘b’: ‘Y’}, axis=1, inplace=True), print(df), , Row Selection, , ROWS IN DATAFRAME, , #By using loc function : loc is used for indexing or selecting based on name, i.e. by row name and column name., , al, , Specified row, , oy, , 39. Write python code to display the 1st record of employee from dataframe df., Ans. import pandas as pd, , Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, df=pd.DataFrame(Dic,index=[‘A1’,’A2’,’A3’,’A4’]), print(df.loc[‘A1’]), , G, , , OUTPUT:, empno 101, name a, salary 3000, Name: A1, dtype: object, , 48, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 58 :
#Filtering the records, , as, ha, n, , 45. Display the information whose salary is greater than 5500., Ans. print(df[df.salary>5500]), #or print(df[df[‘salary’]>5500]), OUTPUT, , empno name salary, A3, 103, c, 8000, A4, 104, d, 9000, , 46. Write a single line statement to show all records from dataframe stud having marks>50., Ans. print(stud[stud[‘marks’]>50]), OR, print(stud[stud.marks>50]), , 47. Write code to add new row at the end of dataframe., Ans. import pandas as pd, , Pr, ak, , Adding new Rows, #By loc, , Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, df=pd.DataFrame(Dic,index=[1,2,3,4]), df.loc[5]=[105,’e’,6000], # or df.loc[df.index.max()+1] = [105,’e’,6000], or, df.loc[len(df)+1]=[105,’e’,6000], print(df), , he, , rs, , OUTPUT, , empno name salary, 1, 101, a, 3000, 2, 102, b, 5000, 3, 103, c, 8000, 4, 104, d, 9000, 5, 105, e, 6000, #By append function: This function will append the rows at the end., , ot, , 48. Write code to add new row at the end by using append method., Ans. import pandas as pd, , Br, , Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, df=pd.DataFrame(Dic,index=[1,2,3,4]), df=df.append({‘empno’:105,’name’:’e’,’salary’:878},ignore_index=True), print(df), , oy, , al, , , empno name salary, 0, 101, a, 3000, 1, 102, b, 5000, 2, 103, c, 8000, 3, 104, d, 9000, 4, 105, e, 878, Remember to specify ignore_index=True:, , G, , 49. Create two dataframe df and df1 with same column name. Merge df1 with df and show the new values of df., Ans. import pandas as pd, lst=[[‘Sanjay’,95],[‘Suman’,97],[‘Pahul’,88],[‘Divya’,72]], lst1=[[‘Karun’,98],[‘Arjun’,56]], df=pd.DataFrame(lst,columns=[‘name’,’marks’]), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 51
Page 61 :
marks, 95, 97, 88, 72, , as, ha, n, , Ans. OUTPUT, , name, 1, Nidhi, 2, Gurjeet, 3, Pahul, 4, Divya, , , name, marks, one Nidhi, 95, two Gurjeet, 97, 3, Pahul, 88, 4, Divya, 72, , #other method: Another method can be used to rename the column name using rename() without columns option., Specify the axis=0 or axis=’rows’ with rename function., df.rename({‘oldName1’: ‘newName1’, ‘oldName2’: ‘newName2’}, axis=0,inplace=True), , Pr, ak, , 56. Give the output, , import pandas as pd, df = pd.DataFrame({‘a’: [1, 2, 3], ‘b’: [4, 5, 6]}), print(df), df.rename(index={0:’x’,1:’y’,2:’z’},inplace=True), print(df), , he, , rs, , Ans. OUTPUT, , a b, 0 1 4, 1 2 5, 2 3 6, a b, x 1 4, y 2 5, z 3 6, 57. Write the correct output on execution of the following Pandas code:, , Br, , ot, , import pandas as pd, df = pd.DataFrame({“A”: [“P01”, “P02”,”P03”],“B”: [“Pen”, “Pencil”, “Eraser”]}), df=df.rename(columns={“A”: “PID”, “B”: “PNAME”}), df=df.rename(index={0: ‘A’, 1: ‘B’, 2: ‘C’}), print(df), 2[comptt 2020], , G, , oy, , al, , Ans. PID, PNAME, A P01, Pen, B P02, Pencil, C P03, Eraser, 58. Write the use of the rename(mapper=<dict-like>, axis=1) method for a Pandas Dataframe. Can the mapper and, columns parameter be used together in a rename() method?, Ans. Pandas rename() method is used to rename any index or column. The mapper parameter takes a dict-like Key:Value, pair with Keys as previous names and Values with new names. Axis =1 represents that the mapper is to rename, the columns with the new names mentioned in the mapper dictionary., No, the mapper and columns parameter cannot be used together in a rename() method. Either mapper with axis=1, or columns is to be used., , Change Column Names and Row Indexes Simultaneously, 59. Give the output, , import pandas as pd, 54, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 63 :
BOOLEAN INDEXING, , 62. Give the output, , as, ha, n, , Ans. (i) STOCK.loc[2,’ID’]=1010, #or STOCK.iloc[2,1]=1010, (ii) print(STOCK[(STOCK[‘ID’] >1002) & (STOCK[‘QUANTITY’] < 300)]), or, print(STOCK[(STOCK.ID >1002) & (STOCK.QUANTITY < 300)]), (iii) STOCK.iloc[0,2]=800, #or STOCK.loc[0,’QUANTITY’]=800, (iv) print(STOCK[(STOCK.ID >1002) | (STOCK.QUANTITY < 300)]), , Ans. OUTPUT, , True , False , True , False , , empno, 101, 102, 103, 104, , name, a, b, c, d, , salary, 3000, 5000, 8000, 9000, , Access Boolean Indexing using .loc, 63. Give the output, , Pr, ak, , import pandas as pd, Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, df=pd.DataFrame(Dic,index=[‘True’,’False’,’True’,’False’]), print(df), , Ans. OUTPUT, empno, True 101, True 103, , salary, 3000, 8000, , he, , name, a, c, , rs, , import pandas as pd, Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, df=pd.DataFrame(Dic,index=[‘True’,’False’,’True’,’False’]), print(df.loc[‘True’]), , ot, , PRACTICE QUESTIONS II, , Br, , 1. Write the command using Insert() function to add a new column in the last place(3rd place) named “Salary” from, the list Sal=[10000,15000,20000] in an existing dataframe named EMP already having 2 columns [sp 2019-20], Ans. EMP.insert(loc=2,column=”Salary”,value=Sal), OR, EMP.insert(2,”Salary”,Sal), , OR, , al, , , EMP.insert(2,”Salary”, [10000,15000,20000]), , G, , oy, , 2. Write the command without using Insert() function to add a new column in the last place(3rd place) named, “Salary” from the list Sal=[10000,15000,20000] in an existing dataframe named EMP already having 2 columns., Ans. EMP[‘Salary’]=Sal, OR, , EMP[‘Salary’]=[10000,15000,20000], 3. Write the command using loc() to add a new column in the last place(3rd place) named “Salary” from the list, Sal=[10000,15000,20000] in an existing dataframe named EMP already having 2 columns., Ans. EMP.loc[:,’Salary’]=Sal, , 56, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 64 :
OR, , EMP.loc[:,’Salary’]= [10000,15000,20000], 4. Write a small python code to drop a column “address” from dataframe stud using del., Ans. del stud[“address”], , as, ha, n, , 5. Write a small python code to drop a column “address” from dataframe stud using drop function., , stud=stud.drop(‘address’,1), OR, , stud=stud.drop(‘address’,axis=1), OR, stud.drop(‘address’,axis=1,inplace=True), , Pr, ak, , 6. Aman wants to delete coloumn “admno” from school dataframe. He has written the following code school., drop(“admno”), print(school), But not getting the result. Help Aman to rectify the errors in code., Ans. school=school.drop(“admno”,1) or school.drop(“admno”,1,inplace=True), print(school), 7. Write a small python code to drop a row from dataframe labeled as 0., Ans. df = df.drop(0), print(df ), , 8. Give the output, , [SP 2019-20], , rs, , import pandas as pd, Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, df=pd.DataFrame(Dic), print (df[[‘roll’,’name’]]), , Br, , 10. Give the output:, , ot, , he, , Ans. OUTPUT, roll name, 0, 1 a, 1, 2 b, 2, 3 c, 9. Write the command to display Pid,Price from an existing dataframe named PRODUCT having 4 columns =[Pid,, Pname,Price,Qty], Ans. print (PRODUCT[[‘Pid’,’Price’]]), , al, , import pandas as pd, Dic={‘roll’:(1,2,3),’name’:(‘a’,’b’,’c’),’marks’:(24,53,66)}, df=pd.DataFrame(Dic), print (df), df.insert(loc=1,column=’grade’,value=[‘a’,’b’,’a’]), print(df), , G, , oy, , Ans. OUTPUT, , roll, 0, 1, 1, 2, 2, 3, , roll, 0, 1, 1, 2, 2, 3, , name, a, b, c, grade, a, b, a, , marks, 24, 53, 66, name, a, b, c, , marks, 24, 53, 66, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 57
Page 66 :
Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, df=______.DataFrame(_____,index=[‘A1’,’A2’,’A3’,’A4’]), df=df.drop(______), print(df), , as, ha, n, , OUTPUT, empno, name, salary, A1 101, a, 3000, A2 102, b, 5000, A4 104, d, 9000, Ans. df=pd.DataFrame(Dic,index=[‘A1’,’A2’,’A3’,’A4’]), df=df.drop(df.index[2]), , 16. Write command to add new row in dataframe df (id,name,price) with values(110,’xyz’,800) using append method., Ans. df=df.append({‘id’:110,’name’:’xyz’,’price’:878},ignore_index=True), Item, , Qty, , 101, , Biscuit, , 100, , 102, , Jam, , 110, , 103, , Coffee, , 200, , 104, , Sauce, , 56, , 105, , Chocolate, , 170, , City, , Delhi, , 10, , Kolkata, , 25, , Kolkata, , 55, , Mumbai, , 55, , Delhi, , 25, , rs, , he, , ot, , print(SHOP[SHOP.City==’Delhi’]), , SHOP[‘Net_Price’]=SHOP.Qty*SHOP.Price, print(SHOP.axes[0]), , #or print(SHOP.index), , print(“no of rows”,len(SHOP.axes[0])), , print(SHOP [[‘Price’,’Qty’]] [SHOP.City==’Kolkata’]), print(SHOP[[‘Item’,’City’]][SHOP.Price>50]), , al, , 18. Consider a set of information for an Exam conducted for students with following details:, , Names, , Marks, , Trials, , [comptt 2020], , Passed, , 0, , Sanya, , 95, , 2, , yes, , 1, , Krish, , 30, , 3, , no, , 2, , Rishav, , 96.5, , 1, , yes, , 3, , Deepak, , 75, , 2, , no, , 4, , Kriti, , 92, , 1, , yes, , oy, , G, , Price, , commands to :, Write short code to show the information having city=”Delhi”, Calculate Qty* Price and assign to column ‘Net_Price’, Display name of all rows, Display total no of rows, Show the qty and price whose city is Kolkata, show item and city whose price greater than 50, , Br, , Write, (i), (ii), (iii), (iv), (v), (vi), Ans. (i), (ii), (iii), (iv), (v), (vi), , Pr, ak, , 17. Consider the dataframe SHOP given below:, , Write a Pandas code to create a Dataframe named df with the above information with column names as “Names”,, “Marks”, “Trials” and “Passed” and their values as given in the table. The code should then display the total, number of rows and Total number of columns in the Dataframe separately as follows:, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 59
Page 67 :
Pr, ak, , as, ha, n, , Number of Rows: 5, Number of Columns: 4, , NOTE: The code must use Dataframe methods to display the Total number of rows and Total number of columns, in the datafram, (i) To display the ‘Names’ and ‘Marks’ columns from the DataFrame., (ii) to change the ‘Marks’ in the 4th row (i.e. for index 3) to 91.5, (iii) to display the rows where number of ‘Trials’ in the examination is less than 2 and ‘Marks’ is greater than 95, Ans. import pandas as pd, Data={‘Names’:[‘Sanya’,’Krish’,’Rishav’,’Deepak’,’Kriti’,], ‘Marks’: [95, 70, 96.5, 75, 92],‘Trials’:, [2, 3, 1, 2, 1], ‘Passed’: [‘yes’, ‘no’, ‘yes’, ‘no’, ‘yes’]}, df = pd.DataFrame(Data ), total_rows=len(df.axes[0]), total_cols=len(df.axes[1]), print(“Number of Rows: “, total_rows), print(“Number of Columns: “, total_cols), (i) print(df[[‘Names’, ‘Marks’]]), (ii) df.loc[3, ‘Marks’] = 91.5, (iii) print(df[(df[‘Trials’] < 2) & (df[‘Marks’] > 95)]), , he, , rs, , 19. For the above created Dataframe df write single line statements for each of the following parts (i) to (iv), which, use Pandas method:, (i) To display the information of all failed student., (ii) To change the passed information of Deepak to ‘yes’, (iii) To show all information those marks>75 and Trials>1, (iv) To show name and marks of all students those marks>70 and Trials>1, Ans. (i) print(df[df.Passed==’no’]), (ii) df.loc[3, ‘Passed’] = ‘yes’, (iii) print(df[(df.Marks>75) & (df.Trials>1)]), (iv) print(df[[‘Names’,’Marks’]][(df.Marks>75) & (df.Trials>1)]), , Br, , ot, , 20. Write the single line command to delete the column “marks” from datafram df using drop function., Ans. df=df.drop(‘marks’,1), OR, df=df.drop(‘marks’,axis=1), OR, df.drop(‘marks’,1,inplace=True), 21. Write the correct output on execution of the following Pandas code:, , al, , import pandas as pd, df=pd.DataFrame([(‘Om’,93),(‘Jay’,91)],columns=[‘Name’,’Mark’]), print(df[‘Name’]), , oy, , Ans. OUTPUT, 0, Om, 1, Jay, 22. Write a program in Python Pandas to create the following DataFrame batsman from a Dictionary:, , G, , B_NO, , 60, , Name, , Score1, , Score2, , 1, , Sunil Pillai, , 90, , 80, , 2, , Gaurav Sharma, , 65, , 3, , Piyush Goel, , 70, , 90, , 4, , Kartik Thakur, , 80, , 76, , 45, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 69 :
mark1, 40, 60, 35, 90, , mark2, 35, 70, 60, 100, , , 0, 1, 2, 3, , mark1, 20, 20, -5, -10, , mark2, 5, 20, 0, 40, , , 0, 1, 2, 3, , marks1, 30, 40, 15, 40, , mark2, 20, 45, 30, 70, , , zero, one, 2, 3, , marks1, 30, 40, 15, 40, , as, ha, n, , , 0, 1, 2, 3, , rs, , mark2, 15, 25, 30, 30, , he, , mark1, 10, 20, 20, 50, , ot, , , 0, 1, 2, 3, , Pr, ak, , (iv) df1.rename(index = {0: “zero”, 1:”one”}, inplace = True), print(df1), OUTPUT:, , mark1, mark2, 0, 30, 20, 1, 40, 45, 2, 15, 30, 3, 40, 70, , Br, , mark2, 20, 45, 30, 70, , al, , 26. Consider the following DataFrame, Book, Title, , Price, , ABC of Physics, , 300, , 102, , Informatics made fun, , 250, , 103, , Computers are simple, , 375, , oy, , 101, , G, , Write commands to :, (i) Add a new column ‘Year’ with the followng values : (2005,2010,2018), (ii) Add a new row with values (“Informatics”,350,2020), Ans. (i) Book[‘Year’]=[2005,2010,2018], (ii) Book.loc[104]=[‘Informatics’,350,2020], , 62, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 70 :
27. Consider the following DataFrame, Friends, Name, , Hobbies, , as, ha, n, , F101, Bijoy, Swimming, F102, Abhinav, Reading books, F103, Jyotsna, Dancing, Write commands to :, (i) Add a new column ‘Age’ at 2 position using insert function with the followng values (20,17,18), (ii) Change the column name “Name” to “FName”, Ans. (i) Friends.insert(2’age’,[20,17,18]), (ii) Friends.rename(columns={‘Name’: ‘Fname’},inplace=True), 28. Consider the following DataFrame, Teacher, Department, SCIENCE, ENGLISH, , T103, , MATHEMATICS, , (i), (ii), Ans. (i), (ii), , 32, 30, , Pr, ak, , T101, T102, , Periods, , 34, , Add a new row with values ( “COMPUTER”,35), Delete the column “Department’, Teacher.loc[‘T104’]=[‘COMPUTER’,35], Teacher=Teacher.drop(‘Department’,1), #or Teacher.drop(‘Department’,axis=1,inplace=True), , 29. Consider the following DataFrame, Employee, Sabhyata Sharma, , 102, , Divya Arora, , 103, , Faizal Zaidi, , Commission, 9000, 8900, 15000, , Display the records of employees having index value 101 and 103 using loc, Write code to delete the row whose index value is 102, print(Employee.loc[[101,103]]), Employee=Employee.drop(102), , ot, , (i), (ii), Ans. (i), (ii), , he, , 101, , rs, , NAME, , Br, , 30. Consider the following DataFrame, ITEM, (i) Add new row with ITEM_NO=104 and cost=8000 using append method, (ii) Display the cost of ITEM_NO 103, Ans. (i) ITEM=ITEM.append({‘ITEM_NO’:104,’cost’:8000},ignore_index=True), (ii) print(ITEM.iloc[2,1]), , ITEM_NO, , COST, , 101, , 5000, , 102, , 3000, , 103, , 4000, , al, , 31. Write a program in Python Pandas to create the following DataFrame salesman from a Dictionary:, SID, , Name, , Salary, , S101, , Amit, , S102, , Deepika, , 32000, , 7000, , S103, , Vinay, , 35000, , 9000, , oy, , 67000, , Bonus, 5000, , G, , Perform the following operations on the DataFrame :, (i) Add both the salary and bonus of a salesman and assign to column “Total Salary”, (ii) Display the highest salary and lowest bonus of the DataFrame., (iii) Display the DataFrame, Ans. import pandas as pd, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 63
Page 71 :
dic={‘SID’:(‘S101’,’S102’,’S103’),’Name’:(‘Amit’,’Deepika’,’Vinay’),’Salary’:(67000,32000,35000),, ’Bonus’:(5000,7000,9000)}, salesman=pd.DataFrame(dic), (i) salesman[‘Total Salary’]=salesman[‘Bonus’]+salesman[‘Salary’], (ii) print(max(salesman[‘Salary’]),min(salesman[‘Bonus’])), , as, ha, n, , OR, , print(salesman[‘Salary’].max(),salesman[‘Bonus’].min()), (iii) print(salesman), , 32. Write a program in Python Pandas to create the following DataFrame Furniture from a Dictionary:, FCODE, , NAME, , PRICE, , 10023, , Table, , 4000, , 10001, , Chair, , 2050, 3500, , Pr, ak, , 10012, Sofa, Perform the following operations on the DataFrame :, (i) Calulate 10% of price and assign to column “Tax”, (ii) Count the no of names of DataFrame., (iii) Display the DataFrame, Ans. import pandas as pd, , dic={‘FCODE’:(10023,10001,10012),’Name’:(‘Table’,’Chair’,’Sofa’),’Price’:(4000,2050,3500)}, furniture=pd.DataFrame(dic), (i) furniture[‘Tax’]=furniture[‘Price’]*10/100, (ii) print(furniture[‘NAME’].count()), , rs, , (iii) print(furniture), , 33. Write a program in Python Pandas to create the following DataFrame Order from a Dictionary:, 101, 102, , SalesPerson, , Sales, , he, , OrderId, , Ravi, , 40000, , Rashmi, , 50000, 55000, , Br, , ot, , 103, Rohan, Perform the following operations on the DataFrame :, (i) To change the ‘Sales’ in the 3rd row (i.e. for index 2) to 25000, (ii) Change the column name ‘OrderId’ to ‘Id’, (iii) Display the DataFrame columns names, Ans. import pandas as pd, , dic={‘OrderId’:(101,102,103),’SalesPerson’:(‘Ravi’,’Rashmi’,’Rohan’),’Sales’:(40000,50000,55000)}, , al, , order=pd.DataFrame(dic), , oy, , (i) order.loc[2,’Sales’]=25000, (ii) order.rename(columns={‘OrderId’:’Id’},inplace=True), (iii) print(order.columns), , G, , 34. Consider a dataframe STOCK created with the following information. Write single line Pandas statements for, each of (i), (ii) and (iii). (Assuming necessary modules have been imported as df):, , 64, , ITEMS, , ID, , 0, , PEN, , 1001, , 1, , PENCIL, , 1004, , 2, , ERASER, , 1007, , QUANTITY, 500, 300, 280, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 72 :
B_NO, , Name, , as, ha, n, , (i) To display the total number of all ITEMS in the STOCK, (ii) To display the total QUANTITY of all ITEMS in the STOCK, (iii) To display the highest QUANTITY of all ITEMS in the STOCK, (iv) To change the ‘ID’ 1007 to 1005 in the 3rd row (i.e. for index 2), (v) To display the rows where ‘ID’ in the stock is less than 1005 and ‘Quantity’ is greater than 400, Ans. (i) print(Stock[“ID”].count()), (ii) print(Stock[“QUANTITY”].sum()), (iii) print(Stock[“QUANTITY”].max()), (iv) Stock.loc[2,’ID’]=1005, (v) print(Stock[(Stock[‘ID’] < 1005) and (Stock[‘QUANTITY’] > 400)]), 35. Write a program in Python Pandas to create the following DataFrame batsman from a Dictionary:, Score1, , Sunil Pillai, , 90, , 2, , Gaurav Sharma, , 65, , 3, , Piyush Goel, , 4, , Kartik Thakur, , 80, 45, , Pr, ak, , 1, , Score2, , 70, , 90, , 80, , 76, , Perform the following operations on the DataFrame :, (i) Add both the scores of a batsman and assign to column “Total”, (ii) Display the highest score in both Score1 and Score2 of the DataFrame., (iii) Display the DataFrame, Ans. import pandas as pd, , 5[SP 21], , he, , rs, , d1={‘B_NO’:[1,2,3,4],‘Name’:[“Sunil Pillai”,”Gaurav Sharma”,”Piyush Goel”,”Kartik, Thakur”],’Score1’:[90,65,70,80], ‘Score2’:[80,45,95,76]}, df=pd.DataFrame(d1), print(df), , df[‘Total’] = df[‘Score1’]+ df[‘Score2’], #or df[‘Total’] = sum(df[‘Score1’],, df[‘Score2’]), print(df), , ot, , print(“Maximum scores are : “ , max(df[‘Score1’]), max(df[‘Score2’])), , 36. Sangeeta has created a dataframe with columns- name and marks but wants to display only name column., She has written the code but getting some errors, help sangeeta and recifty the errors., , Br, , import pandas as pd #statement 1, lst=[[‘Nidhi’,95],[‘Gurjeet’,97],[‘Pahul’,88],[‘Divya’,72]] #statement 2, df=pd.DataFrame(lst,columns=[‘name’,’marks’]) #statement 3, print (name) #statement 4, , al, , Ans. error in statement 4, print (df[‘name’]), 37. Give the output, , oy, , , import pandas as pd, , df = pd.DataFrame({‘x’: [1, 2, 3], ‘y’: [4, 5, 6]}), df.rename(columns={‘x’: ‘A’},inplace=True), print(df), , G, , Ans. OUTPUT, , A y, 0 1 4, 1 2 5, 2 3 6, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 65
Page 73 :
Pr, ak, , 39. A dataframe df is given below:, , empno, name, salary, A1, 101, a, 3000, A2, 102, b, 5000, A3, 103, c, 8000, A4, 104, d, 9000, Give the output of the following :, (a) print(df.loc[‘A2’:’A3’,[‘name’,’salary’]]), Ans. name salary, A2, b, 5000, A3, c, 8000, (b) print(df.iloc[0:2]), Ans. empno name salary, A1, 101, a, 3000, A2, 102, b, 5000, (c) print(df.iloc[1:3,2:3]), Ans. salary, A2, 5000, A3, 8000, , as, ha, n, , 38. In a DataFrame, Axis= 1 represents the_____________ elements., , (i) row, (ii) column, (iii) True, (iv) False, Ans. (b), , rs, , CSV FILES, , he, , CSV (Comma-separated values) is a standard for storing tabular data in text format, where commas are used to separate, the different columns, and newlines (carriage return/press enter) used to separate rows. Typically, the first row in a CSV, file contains the names of the columns for the data., , Save csv to working directory, , 64. Write python code to write dataframe data into “a.csv” file., Ans. import pandas as pd, , ot, , Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, df=pd.DataFrame(Dic), df.to_csv(“a.csv”), , In notepad, , oy, , al, , Br, , csv can be opened in excel, notepad, etc., In excel, , G, , Save csv to any other directory., The r character should be placed before the path name., 65. Modify the above code and write the data in d;\software folder., Ans. import pandas as pd, , Dic={‘empno’:(101,102,103,104),’name’:(‘a’,’b’,’c’,’d’),’salary’:(3000,5000,8000,9000)}, df=pd.DataFrame(Dic), df.to_csv(r”D:\software\a.csv”), # or df.to_csv(“D:\\software\\a.csv”), , 66, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 74 :
How to Create CSV File in Excel, , Pr, ak, , as, ha, n, , Step 1: Open excel and write data in worksheet, , Step 2: Select file option from menu and click on save as ..., , Step 3: Select drive and folder name where you want to save csv file., , , Step 4: Click on save as type option and select csv option from list., , Step 5: Click on save button., , Read CSV File as Pandas, , rs, , Using the read_csv() function from the pandas package, you can import tabular data from CSV files into pandas dataframe., 66. Write python code to read a csv file “test.csv” from D:\, Ans. import pandas as pd, name, aleeza, ananya, rajesh, amar, rohit, pahul, jyoti, divya, harshit, himanshi, , marks, 55, 34, 90, 23, 42, 53, 24, 99, 24, 66, , Br, , roll, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, , al, , , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, , ot, , print(df), , he, , df = pd.read_csv(‘d:\\test.csv’) #read the csv file, , G, , oy, , 67. Write command to display the records of students those marks greater than 50 from the above created df., Ans. print(df[df[‘marks’]>50]), roll, name, marks, 0, 1, aleeza, 55, 2, 3, rajesh, 90, 5, 6, pahul, 53, 7, 8, divya, 99, 9, 10, himanshi 66, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 67
Page 75 :
Print Specified Columns, 68. Read name and roll from test.csv, Ans. import pandas, , df = pandas.read_csv(‘d:\\test.csv’, usecols =[‘roll’,’name’]), print(df), , name, aleeka, aleeza, alina, ananya, ananya, arni, bhavna, divya, harshita, himanshi, , as, ha, n, , roll, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, , Pr, ak, , , 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, , MULTIPLE CHOICE QUESTIONS, , 1. Given a Pandas dataframe called “S”, the command which will display the last 5 rows is, , (a) print(S.tail()) , (b) print(S.Tail(5)), , (c) print(S.tails(5)) , (d) print(S.Tails(5)), , he, , rs, , 2. Write a single line command to calculate 10% from ‘sale’ column from dataframe df and assign to new column, ‘Commission’, , (a) df.insert[‘Commission’]=df.sale*10/100, (b) df[‘Commission’]=df.sale*10/100, , (c) , df.loc[‘Commission’]=df.sale*10/100, (d) df[‘Commission’,axis=1]=df.sale*10/100, , Br, , 4. Which one is incorrect option to add a new column using insert() in the last place(3rd place) named “Salary”, from the list Sal=[10000,15000,20000] in an existing dataframe named EMP already having 2 columns, (a) EMP.insert(loc=2,column=”Salary”,value=Sal), (b) EMP.insert(2,”Salary”,Sal), (c) EMP.insert(loc=2,column=”Salary”,value=[10000,15000,20000]), (d) EMP.insert(loc=2,col=”Salary”,value=Sal), 5. Write a small python code to drop a column “address” from dataframe stud using del., (a) del stud[col=“address”] , (b) del stud[column=“address”], (c) del stud[“address”,axis=1] , (d) del stud[“address”], , al, , , , , , , ot, , 3. Write the single line command to delete the column “marks” from dataframe df using drop function., , (a) df=df.drop(col=‘marks’) , (b) df=df.drop(‘marks’,axis=col), , (c) df=df.drop(‘marks’,axis=0) , (d) df=df.drop(‘marks’,axis=1), , oy, , , , , 6. In a DataFrame, Axis= 1 represents the_____________ elements., , (a) Row, (b) Column, (c) True, , G, , , , , , , 68, , (d) False, , 7. Write commands to Add a new column ‘Year’ with the following values(2005,2010,2018) in data frame BOOK., (a) Book[‘Year’]=[2005,2010,2018], (b) Book[col=‘Year’]=[2005,2010,2018], (c) Book[‘Year’,axis=1]=[2005,2010,2018], (d) Book[‘Year’] values [2005,2010,2018], Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 77 :
as, ha, n, , 20. Consider the following DataFrame df and answer any four questions from (i) to (iv)., Roll, Name, marks, , 0, 1, a, 87, , 1, 2, b, 45, , 2, 3, c, 67, , 3, 4, d, 39, , 4, 5, e, 78, , , , , , , (ii) Which of the following command is used to add a new column ‘Grade’ with the values: ‘ A’, ‘B’, ‘A’, ‘B’,, ‘A’ to the DataFrame?, (a) df.column=[’A’,’B’,’A’,’B’,’A’], (b) df [‘Grade’]=[’A’,’B’,’A’,’B’,’A’], (c) df.insert(loc=3,column=’Grade’,value= [’A’,’B’,’A’,’B’,’A’]), (d) both (b) and (c) are correct, , , , , , , (iii) Which of the following command is used to delete the column “Name”?, (a) del df[“Name”], (b) df=df.drop(‘name’,axis=1), (c) df=df.drop(‘name’,axis=0), (d) both (a) and (b) are correct, , , , , , , (iv) Which of the following command is used to rename the column “Marks” to “Tmarks” in the existing dataframe df?, (a) df.rename(columns={‘Marks’: ‘TMarks’},inplace=True), (b) df.rename(columns={‘Marks’: ‘TMarks’}), (c) df.rename({“Marks”:”TMarks”},axis=0), (d) both (a) and (c) are correct, , he, , rs, , Pr, ak, , , , , (i) Which of the following command is used to display all records having rollno>3?, (a) print(df[df[‘Roll’]>3]) , (b) print(df[‘Roll’]>3), (c) print(df.Roll>3]) , (d) print(df(‘Roll’)>3), , 21. Consider the following DataFrame Faculty and answer any four questions from (i)-(v), AGE, , ot, , FNAME, , DEPARTMENT, , GRADE, , Moksha, , 30, , Biology, , A, , 1, , Malini, , 35, , Maths, , A, , Akshit, , 43, , English, , B, , Nishant, , 27, , Maths, , B, , 2, , al, , 3, , Br, , 0, , (i) Which of the following command(s) will display the information whose grade is “A”, (a) print(Faculty[Faculty.Grade= =”A”]), (b) print(Faculty[Faculty[‘Grade’]= =’A’]), (c) print(Faculty[‘Grade’]= =’A’), (d) both (a) and (b), , oy, , , , , G, , , , , , , 70, , (ii) Which of the following command(s) is used to add new row at the end of dataframe with, values(‘Ankur’,30,’Computer’,’A’), (A) Faculty.insert(‘Ankur’,30,’Computer’,’A’), (B) Faculty.loc[4]=[‘Ankur’,30,’Computer’,’A’], (C) Faculty.row(‘Ankur’,30,’Computer’,’A’), (D) Faculty=Faculty.append({‘Fname’:Ankur,’Age’:30,’Department’:’Computer’,’Grade’:’A’},ignore_index=True) , (a) A only, (b) A and C, (c) A and D, (d) B and D, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 78 :
(iv) Which of the following command is used to display the grade of Fname Akshit?, (a) print(Faculty.loc[2,3]) , (b) print(Fauclty.iloc[2,3]), (c) print(Fauclty.iloc[2,4]) , (d) print(Fauclty.iloc[3,4]), , , , , (v) Choose the correct option to change the name of index 0 to new name ‘x’., (a) Faculty.indexname({0:’x’},inplace=True), (b) Faculty.rowname({0:’x’},inplace=True), (c) Faculty.newname({0:’x’},inplace=True), (d) Faculty.rename({0:’x’},inplace=True), , as, ha, n, , , , , , (iii) Select the correct option to delete the row whose index value is 1., (A) Faculty=Faculty.drop(df.index[1]), (B) Faculty=Faculty.drop(1), (C) Faculty=Faculty.drop(1,axis=0), (D) Faculty= Faculty.drop(1,0), (a) only A is correct (b) A and B are correct, (c) A, B and C are correct (d) all are correct, , 22. Consider the following DataFrame stud and answer any four questions from (i) to (v)., roll, , name, , marks, , 1, , Nidhi, , 87, , S2, , 2, , Jyoti, , S3, , 3, , Poonam, , S4, , 4, , Karambir, , 39, , S5, , 5, , Sangeeta, , 78, , Pr, ak, , S1, , 45, , 67, , (i) Which of the following code will display the total number of rows?, (a) print(len(stud.axes[0]) , (b) print(stud.len(0)), (c) print(stud.len[axes=0]) , (d) print(len(stud.axes[row]), , rs, , , , , ot, , he, , (ii) State the command that will give the output as :, , roll, name, S2, 2, Jyoti, S3, 3, Poonam, , (a) print(stud.iloc[1:2,1:2]) (b) print(stud.iloc[2:3,0:2]), , (c) print(stud.iloc[1:3,0:2]) (d) print(stud.iloc[1:3,1:2]), (iii) Which of the following is used to add new row with following data? 6, Divya’,92, (A) stud[‘S6’]=[6,’Divya’,92], (B) stud.iloc[‘S6’]=[6,’Divya’,92], (C) stud..row[‘S6’]=[6,’Divya’,92], (D) stud.loc[‘S6’]=[6,’Divya’,92], (a) print(stud.iloc[1:2,1:2]) , (b) print(stud.iloc[2:3,0:2]), (a) A, (b) C, (c) D, (d) D, , , , , , , , , (iv) Choose the correct option to add new column Gender at position 2 (index value 1) to dataframe stud with, values [‘F’,’F’,’F’,’M’,’F’], (A) stud.insert(1,’Gender’,[‘F’,’F’,’F’,’M’,’F’]), (B) stud.insert(loc=1,column=’Gender’,value=[‘F’,’F’,’F’,’M’,’F’]), (C) stud.insert(loc=1,field=’Gender’,values=[‘F’,’F’,’F’,’M’,’F’]), (D) stud.insert(loc=1,column=’Gender’,values=[‘F’,’F’,’F’,’M’,’F’]), (a) only A is correct , (b) A and B are correct, (c) B and C are corect , (d) A and D are correct, , G, , oy, , al, , Br, , , , , , , , , , (v) Which command is used to display all index values?, (a) print(stud.index) , (b) print(stud.value(axis=0)), (c) print(stud.indexs) , (d) print(stud.index.values()), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 71
Page 79 :
23. Mr. Ankit is working in an organisation as data analyst. He uses Python Pandas and Matplotlib for the same., He got a dataset of the passengers for the year 2010 to 2012 for January, March and December. His manager, wants certain information from him, but he is facing some problems. Help him by answering few questions, given below:, [CBSE QB 2021], month, , 0, , 2010, , Jan, , 1, , 2010, , Mar, , 2, , 2012, , Jan, , 3, , 2010, , Dec, , 4, , 2012, , Dec, , passengers, , as, ha, n, , year, , 25, , 50, , 35, , 55, , 65, , Code to create the above data frame:, , import pandas as ____________ #Statement 1, , Pr, ak, , data={“Year”:[2010,2010,2012,2010,2012],”Month”:[“Jan”,”Mar”,”Jan”,”Dec”,”Dec”], ,”Passengers”:[25,50,35,55,65]}, , df=pd.____________________(data) #Statement 2, print(df), , (i) Choose the right code from the following for statement 1., (a) pd, (b) df, (c) data, , (d) p, , , , (ii) Choose the right code from the following for the statement 2., (a) Dataframe, (b) DataFrame, (c) Series, , (d) Dictionary, , , , (iii) Choose the correct statement/method for the required output: (5,3), (a) df.index, (b) df.shape(), (c) df.shape, , (d) df.size, , he, , rs, , , , (iv) He wants to print the details of “January” month along with the number of passengers. Identify the correct, statement:, month, , 2, (a), (b), (c), (d), , 25, , Jan, , 35, , df.loc[[‘Month’,’Passengers’]][df[‘Month’]==’Jan’], df[[‘Month’,’Passengers’]][df[‘Month’]==’Jan’], df.iloc[[‘Month’,’Passengers’]][df[‘Month’]==’Jan’], df([‘Month’,’Passengers’]][df[‘Month’]==’Jan’), , Br, , , , , , , Jan, , ot, , 0, , passengers, , al, , (v) Mr. Ankit wants to change the index of the Data Frame and the output for the same is given below. Identify, the correct statement to change the index., month, , passengers, , AirIndia, , 2010, , Jan, , 25, , Indigo, , 2010, , Mar, , 50, , Spicejet, , 2012, , Jan, , 35, , Jet, , 2010, , Dec, , 55, , Emirates, , 2012, , Dec, , 65, , G, , oy, , year, , 72, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 80 :
(a), (b), (c), (d), , df.index[]=[“Air India”,”Indigo”,”Spicejet”,”Jet”,”Emirates”], df.index[“Air India”,”Indigo”,”Spicejet”,”Jet”,”Emirates”], df.index=[“Air India”,”Indigo”,”Spicejet”, ”Jet”,”Emirates”], df.index()=[“Air India”,”Indigo”,”Spicejet”,”Jet”,”Emirates”], , First, , Second, , 0, , Chenab, , 5, , 7, , 1, , Ganges, , 10, , 5, , 2, , Jamuna, , 8, , 13, , 3, , Jhelum, , 12, , 9, , 4, , Ravi, , 5, , 5, , Setluj, , 10, , Write Python commands to do the following:, , Third, 6, , 4, , 15, , 12, , Pr, ak, , House, , as, ha, n, , 24. Sanyukta is the event incharge in a school. One of her students gave her a suggestion to use Python Pandas and, Matplotlib for analysing and visualising the data, respectively. She has created a Data frame “SportsDay” to keep, track of the number of First, Second and Third prizes won by different houses in various events. [CBSE QB], , 11, , 10, , 5, , 3, , (i) Display the house names where the number of Second Prizes are in the range of 12 to 20., (a), (b), (c), (d), , df[‘Name’][(df[‘Second’]>=12) and (df[‘Second’]<=20)], df[Name][(df[‘Second’]>=12) & (df[‘Second’]<=20)], df[‘Name’][(df[‘Second’]>=12) & (df[‘Second’]<=20)], df[(df[‘Second’]>=12) & (df[‘Second’]<=20)], , rs, , , , , , , (b) print(df.iloc[::-1]), (d) print(df.reverse()), , , , (iii) Display the bottom 3 records., (a) df.last(3), (b) df.bottom(3), , (c) df.next(3), , (d) df.tail(3), , (c) First, , (d) House, , ot, , he, , , , , (ii) Display all the records in the reverse order., (a) print(df[::1]) , (c) print(df[-1:]+df[:-1]) , , (iv) Choose the correct output for the given statements:, , Br, , x=df.columns[:1], print(x), , , , (b) Name, , (v) Which command will give the output 24?, (a) print(df.size) , (c) print(df.index) , , (b) print(df.shape), (d) print(df.axes), , al, , , , , (a) 0, , oy, , 25. Zeenat has created the following data frame dataframe1 to keep track of data Rollno, Name, Marks1 and Marks2, for various students of her class where row indexes are taken as the default values:, [CBSE QB], , G, , Rollno, , Name, , Marks1, , Marks2, , 1, , Swapnil Sharma, , 30, , 50, , 2, , Raj Batra, , 75, , 45, , 3, , Bhoomi Singh, , 82, , 95, , 4, , Jay Gupta, , 90, , 95, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 73
Page 81 :
(i) She needs to know the marks scored by Rollno 2. Help her to identify the correct set of statement/s from, the given options:, (a) print(dataframe1[dataframe1[‘Rollno’]= =2]), (b) print(dataframe1[‘Rollno’]= =2), (c) print(dataframe1[dataframe1. Rollno = =2]), (d) both (a) and (c), , , , , , , , (iii) Which of the following command will display the total number of elements in the dataframe?, (a) print(dataframe1.shape) , (b) print(dataframe1.num), (c) print(dataframe1.size) , (d) print(dataframe1.elements), , , , , (iv) Now she wants to add a new column Marks3 with relevant data. Help her choose the command to perform, this task., (a) dataframe1.column=[ 45,52,90,95], (b) dataframe1 [‘Marks3’]= [ 45,52,90,95], (c) dataframe1.loc[‘Marks3’]= [ 45,52,90,95], (d) Both (b) and (c) are correct, , Pr, ak, , , , , as, ha, n, , , , , (ii) Which of the following statement/s will delete the 3rd column?, (A) del dataframe1[‘Marks1’], (B) dataframe1.pop(‘Marks1’), (C) drop dataframe1[‘Marks1’], (D) pop dataframe1[‘Marks1’], Choose the correct option:, (a) both (A) and (B) , (b) only (B), (c) (A), (B) and (C) , (d) (A), (B) and (D), , 26. Naman has created following dataframe: “Climate” to record the data about climatic conditions of four, years. , [CBSE QB], MaxTemp, 32, , 2018, , 33, , 2019, , 35, , he, , 2017, , 2020, , MinTemp, , 20, , 123, , 22, , 140, , 21, , 135, , 23, , 160, , rs, , Year, , 34, , Rainfall, , , , , , , (ii) Display the temperature difference between MaxTemp and MinTemp for all the rows in the dataframe Climate., (a) Climate=Climate[“MaxTemp”]-Climate[“MinTemp”], (b) print(Climate[“maxt”]-Climate[“mint”]), (c) print(Climate[“MaxTemp”]-Climate[“MinTemp”]), (d) print(Climate.Climate[“MaxTemp”]-Climate[“MinTemp”]), , Br, , ot, , , , , (i) Which of the following code snippets will return the MaxTemp and Rainfall for year 2018 and 2019?, (a) Climate[[‘MaxTemp’,’Rainfall’]][1:3], (b) Climate[‘MaxTemp’, ‘Rainfall’][1:3], (c) Climate.iloc[1:3, [0,2]] , (d) Climate.iloc[1:3,1:2], , al, , (iii) To display 2 rows from the top in the dataframe, which of the following statement is correct?, (a) print (Climate.head()=2 ), (b) print (Climate.head(n==2) ), (c) print (Climate.head(range(2)) ), (d) print (Climate.head(2) ), , oy, , , , , G, , , , , , , , , 74, , (iv) Which of the following statement/s will give the exact number of values in each column of the dataframe?, (A) print(Climate.count()) , (B) print(Climate.count(0)), (C) print(Climate.count) , (D) print(Climate.count(axis=’index’)), Choose the correct option:, (a) print(dataframe1.shape) , (b) print(dataframe1.num), (a) both (A) and (B) , (b) only (B), (c) (A), (B) and (C) , (d) (A), (B) and (D), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 82 : (v) To display 2 rows from the bottom in the dataframe, which of the following statement is correct?, (a) print (Climate.tail()=2 ) , (b) print (Climate.tail(n==2) ), (c) print(Climate.tail(range(2))), (d) print (Climate.tail(2) ), , , , , as, ha, n, , 27. HR Department of ABCTech has created following dataframe to store data about salaries and bonus paid to their, employees:, [CBSE QB], import pandas as pd, import numpy as np, d1={‘EName’:[ ‘Kavita’, ‘Sudha’,, ‘Garima’]’],’Sal’:[50000,60000,55000],’Bonus’:[3000,4000,5000]}, Df1=pd.DataFrame(d1), Choose the python statement using suitable functions for the following tasks:, , , , (i) Display the columns Sal and Bonus., (a) df1 ['Sal :Bonus] , (c) df1.iloc([‘Sal’,’Bonus’]) , , , , , (ii) Display the details of employee Kavita., (a) df1[df1.EName==’Kavita’], (c) df1.iloc[df1.EName==’Kavita’], , , , (iii) Display the details of the last employee., (a) Df1.tail(1), (b) Df1.tail (-1), , , , , (iv) Add a new column named ‘Email’ with the value “
[email protected]”., (a) Df1[‘Email’]= ‘
[email protected]’, (b) Df1[Email]=’
[email protected]’, (c) Df1.loc[‘Email’]=’
[email protected]’, (d) Df1(‘Email’)=’
[email protected]’, , , , , (v) Write a python statement to print the details of employees having Sal more than 50000., (a) df1.Sal>=5000 , (b) df1[df1.Sal>=5000], (c) df1[df1.’Sal’>=5000] , (d) df1.iloc[df1.Sal>=5000], , Pr, ak, , (b) df1.loc([‘Sal’,’Bonus’]), (d) df1[[‘Sal’,’Bonus’]], , (b) df1.loc[df1.EName==’Kavita’], (d) df1[EName=’Kavita’], , (d) Df1.head(), , he, , rs, , (c) Df1.head(n=1), , ot, , 2. (b), 12. (d), (a), (d), (a), (a), (c), (d), (c), (d), , 3., 13., (ii), (ii), (ii), (ii), (ii), (ii), (ii), (ii), , (d), (b), (d), (d), (c), (a), (b), (a), (c), (a), , 4. (d), 14. (c), (iii), (iii), (iii), (iii), (iii), (iii), (iii), (iii), , Br, , (a), (a), (i), (i), (i), (i), (i), (i), (i), (i), , (d), (d), (d), (c), (d), (c), (d), (a), , 5. (d), 15. (b), , 6. (b), 16. (a), (iv) (a), (iv) (b), (iv) (b), (iv) (b), (iv) (d), (iv) (b), (iv) (d), (iv) (a), , 7. (a), 17. (c), (v), (v), (v), (v), , 8. (d), 18. (b), , 9. (a), 19. (d), , 10. (b), , (d), (a), (c), (a), , (v) (d), (v) (b), , G, , oy, , al, , 1., 11., 20., 21., 22., 23., 24., 25., 26., 27., , ANSWERS, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 75
Page 83 :
3, , as, ha, n, , Visualization, LINE GRAPH, , RESULT, , 1. Draw a Line Graph from the following program, import matplotlib.pyplot as p1, a=[82,25,87,14,90], p1.ylabel(“marks”), p1.plot(a), p1.show(), , 90, 80, , marks, , 60, 50, 40, 30, 20, , 0.0, , 0.5, , 1.0, , 1.5, , 2.0, names, , 2.5, , 3.0, , 3.5, , rs, , Ans. You may be wondering why the x-axis ranges, from 0-4 If you provide a single list or array, to the plot() command, matplotlib assumes it, is a sequence of y values, and automatically, generates the x values for you. Since python, ranges start with 0, the default x vector has the, same length as y but starts with 0. Hence the, x data are [0,1,2,3,4]., , Pr, ak, , 70, , Legend, , 5, 4, 3, , A legend is an area describing the elements of the graph. In the, matplotlib library, there’s a function called legend() which is used, to Place a legend on the axes., , Br, , 2, 1, , Legend loc, , 2, , 3, , 4, , 5, , 6, , 7, , ‘best’ (By, default), , ‘upper, right’, , ‘upper, left’, , ‘lower, left’, , ‘lower, right’, , ‘right’, , ‘center, left’, , ‘center, right’, , ‘lower, center’, , ‘upper, center’, , ‘center’, , 0, , 1, , 2, , 3, , 4, , 5, , 6, , 7, , 8, , 9, , 10, , oy, , al, , Location, String, Location, Code, , 3[SP 21], , 6, , ot, , a = [1,2,3,4,5,6], b = [2,3,4,5,6,7], plt.plot (a,b), plt.show(), , he, , 2. Consider the following graph. Write the code to plot it., Ans. import matplotlib.pyplot as plt, , 4.0, , G, , The string ‘best’ places the legend at the location, among the locations defined so far, with the minimum overlap with, other drawn artists., The elements to be added to the legend are automatically determined, when you do not pass any extra arguments.In, this case, the labels are taken from the artist., 3. Give the output from the given python code, Ans. import numpy as np, import matplotlib.pyplot as p1, , 76, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 84 :
SALES CHART, , #or x=[0,1,2,3,4], , 90, , y2018=[45,76,45,90,34], y2019=[50,26,73,86,45], p1.ylabel(“sales in lakhs”), p1.xlabel(“months”), p1.title(“SALES CHART”), p1.plot(x,y2018), p1.plot(x,y2019), p1.legend([‘sales 2018’,’sales 2019’],loc=4), p1.show(), , sales in lakhs, , 80, 70, 60, 50, 40, , as, ha, n, , x=np.arange(5), , sales 2018, sales 2019, , 30, 0.0, , 0.5, , 1.0, , 1.5, , 2.0, 2.5, months, , 3.0, , 3.5, , 4.0, , Save the figure using savefig(), , 50, 40, 30, 20, , Pr, ak, , 60, , rs, , x=[‘A’,’B’,’C’,’D’,’E’], y=[82,25,87,14,90], p1.ylabel(“marks”), p1.xlabel(“names”), p1.title(“RESULT”), p1.plot(x,y), p1.show(), , marks, , 4. Write python code to create a Line Graph using list of elements x and y. Set ylabel as “marks” and xlabel as, “names” . Title of graph is “Result”, RESULT, x=[‘A’,’B’,’C’,’D’,’E’], 90, y=[82,25,87,14,90], 80, Ans. import matplotlib.pyplot as p1, 70, , A, , B, , C, names, , D, , E, , ot, , he, , savefig() method is used to save the figure created after plotting data. The figure created can be saved to our local, machines by using this method. For example :, plt.savefig(‘result.png’), The .savefig() method requires a filename be specified as the first argument. This filename can be a full path and as, seen above, can also include a particular file extension., 5. Mr. Harry wants to draw a line chart using a list of elements named LIST. Complete the code to perform the, following operations:, [SP 2019-20], , al, , Br, , (i) To plot a line chart using the given LIST, (ii) To give a y-axis label to, the line chart named “Sample Numbers”., , import matplotlib.pyplot as PLINE, LIST=[10,20,30,40,50,60], _____________________ Statement 1, 12, _____________________ Statement 2, Normal, PLINE.show(), , oy, , Ans. (i) PLINE.plot(LIST), (ii) PLINE.ylabel(“Sample Numbers”), , 6. Write a code to plot the speed of passenger train, shown in the figure given alongside:, [SP 2019-20], Ans. import matplotlib.pyplot as plt, , G, , import numpy as np, x = np.arange(1, 5), #or x=[1,2,3,4], plt.plot(x, x*1.5, label=’Normal’), plt.plot(x, x*3.0, label=’Fast’), , Fast, Slow, , 10, 8, 6, 4, 2, , 0, 1.0, , 1.5, , 2.0, , 2.5, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 3.0, , 3.5, , 4.0, , 77
Page 86 :
80, , 9. Modify the above program and set xlabel as, “Names” and ylabel as “Marks”, Ans. import matplotlib.pyplot as p1, , 60, , x=[‘aman’,’mohit’,’pahul’,’karan’,’divya’], y=[82,25,87,14,90], p1.bar(x,y), p1.title(“Result”), p1.xlabel(“Names”), p1.ylabel(“Marks”), p1.show(), , Marks, , Give title, X axis Label and Y axis Label, , 40, , 20, , 0, aman, , 10. Draw the following bar graph representing the number of, students in each class., 3[SP 21], Ans. import matplotlib.pyplot as plt, , Draw Bargraph Horizontally, , 40, , pahul, Names, , karan, , divya, , Pr, ak, , classes = [‘VII’,’VIII’,’IX’,’X’], students = [40,45,35,44], plt.bar(classes, students), plt.show(), , mohit, , as, ha, n, , Result, , 30, , 20, , 10, , 11. Write code in python to draw a bargraph horizontally with, the given values x and y., x=[1,2,3,4,5,6,7], y=[38,40,23,35,42,10,34], set the xlabel “no of students” and ylabel as “Days of, week”, Ans. import matplotlib.pyplot as p1, , 0, , rs, , VII, , VIII, , IX, , X, , 7, , Days of week, , he, , 6, , ot, , x=[1,2,3,4,5,6,7], y=[38,40,23,35,42,10,34], p1.barh(x,y), p1.title(“Attendance”), p1.xlabel(“no of students”), p1.ylabel(“Days of week”), , 5, 4, 3, 2, , Br, , 1, 0, , 5, , 10, , 15, , 20, , 25, , 30, , 35, , 40, , al, , no of students, 12. A bar chart is drawn (using pyplot) to represent sales data, of various models of cars, for a month. Write appropriate statements in Python to provide labels Month - June, and Sale done to x and y axis respectively., Sales Bar Graph, , [sp cs 2019-20], 12000, Ans. import matplotlib.pyplot as plt, , ’Tucson’,’Elantra’), , sale=[12369,12174,9390,4663, 4077,3712,2000], plt.bar(model,sale), , G, , plt.xlabel(‘Month-June’), plt.ylabel(‘Sale done’), , plt.title(‘Sales Bar Graph’), , plt.show(), , 10000, Sale done, , oy, , model=(‘i20’,’Grandi10’,’Creta’,’Eon’,’Verna’,, , 8000, 6000, 4000, 2000, 0, i20, , Grand i10 Create, Eon Verna, Month-June, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , Tucson Elantra, , 79
Page 87 :
as, ha, n, , 13. Mr. Sanjay wants to plot a bar graph for the given set of values of subject on x-axis and number of students who, opted for that subject on y-axis., [SP 2019-20], Complete the code to perform the following :, (i) To plot the bar graph in statement 1, (ii) To display the graph in statement 2, import matplotlib.pyplot as plt, , x=[‘Hindi’, ‘English’, ‘Science’, ‘SST’], y=[10,20,30,40], , 80, , _____________________ Statement 2, , 60, , _____________________ Statement 1, , Ans. (i) plt.bar(x,y), (ii) plt.show(), , 40, , 14. Write the output from the given python code:, , [CS comptt 2020], Ans. import matplotlib.pyplot as plt, , Pr, ak, , 20, , Months = [‘Dec’, ‘Jan’, ‘Feb’, ‘Mar’], Attendance = [70, 90, 75, 95], plt.bar(Months, Attendance), plt.show(), , 0, , Dec, , Jan, , Feb, , Mar, , rs, , 15. Fill in the blank with the correct statement to plot a bar graph using a matplotlib method, so that Company ABC, can see the graphical presentation of its Profitfigures for the 2nd quarter of the financial year 2019 (i.e. August,, September, October, November)., import matplotlib.pyplot as mtp, , Months = [‘AUG’, ‘SEP’, ‘OCT’, ‘NOV’] #X Axis, , he, , Profits = [125, 220, 230, 175] #Y Axis, , _________________________________, mtp.show(), , ot, , Ans. mtp.bar(Months, Profits), , 1[comptt 2020], Result, , 16. On the basis of the given graph, fill in the blanks, import matplotlib.pyplot as p1, , 80, , p1._______(x,y,color=’red’), , 60, , Br, , x=[1,2,3,4,5], , p1.title(‘______’), , al, , p1.______(‘Rollno’), , Marks, , y=[82,25,87,14,90], , 40, , p1.ylabel(‘______’), p1.show(), , 20, , oy, , Ans. import matplotlib.pyplot as p1, x=[1,2,3,4,5], , 0, , y=[82,25,87,14,90], , 1, , 2, , 3, Rollno, , 4, , 5, , G, , p1.bar(x,y,color=’red’), p1.title(‘Result’), , p1.xlabel(‘Rollno’), p1.ylabel(‘Marks’), p1.show(), , 80, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 88 :
17. Write a code to plot a bar chart to depict the pass percentage of students in CBSE exams for the years 2015 to, 2018 as shown below., [SP 2019-20], Ans. import matplotlib.pyplot as plt, 100, 90, 80, 70, , plt.show(), , 60, 50, 40, 30, 20, 10, , 18. On the basis of the given bar graph, fill in the blanks, , as, ha, n, , Pass Percentage, , import numpy as np, x=[‘2015’,’2016’,’2017’,’2018’], y=[82,83,85,90], plt.bar(x,y), plt.yticks(np.arange(0,110,10)), plt.ylabel(‘Pass Percentage’), plt.xlabel(‘Years’), , 2015, , 2016, , 2017, , 2018, , Years, , Result, , rs, , Marks, , Pr, ak, , import numpy as np, import matplotlib.pyplot as p1, x=[1,2,3,4,5], 90, y=[82,25,87,14,90], 80, p1._____(x,y), p1.yticks(np.arange(10,100,10)), 70, # p1.yticks([10,20,30,40,50,60,70,80,90]), 60, p1.title(“_______”), 50, p1._______(“Marks”), 50, p1.show(), 50, Ans. import numpy as np, 20, import matplotlib.pyplot as p1, 10, x=[1,2,3,4,5], y=[82,25,87,14,90], p1.bar(x,y), p1.yticks(np.arange(10,100,10)), # p1.yticks([10,20,30,40,50,60,70,80,90]), p1.title(“Result”), p1.ylabel(“Marks”), p1.show(), , 2, , 3, , 4, , 5, , Br, , ot, , he, , 1, , HISTOGRAM, , You can use Matplotlib to create histogram. Histogram has bins, every bin has the minimum and maximum value,, Histogram shows the frequency on vertical axis., , Template to plot a Histogram, , 3.0, 2.5, , plt.hist(x, bins = number of bins), , 2.0, , al, , import matplotlib.pyplot as plt, , oy, , x = [value1, value2, value3,....]n, plt.show(), , G, , 19. Write code to create a Histogram with the given values of x, x=[10,15,55,70,10,30,75,89,98,81] and bins=5, Ans. import matplotlib.pyplot as plt, , 1.5, 1.0, , x=[10,15,55,70,10,30,75,89,98,81], , 0.5, , plt.show(), , 0.0, , plt.hist(x,bins=5), , 20, , 30, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 40, , 50, , 60, , 81
Page 89 :
How to calculate number of bins, may derive the bins using the following formulas:, , as, ha, n, , 5, , 4, , 3, , 2, , 1, , 0, , Pr, ak, , You can set any number of bins according to data. Alternatively, you, ● n = number of observations, ● Range = maximum value – minimum value, ● # of intervals = √n, ● Width of intervals = Range / (# of intervals), You can create frequency table by using these formulas, Lets take the data from previous question, x=[10,15,55,1,99,75,89,100,81], Using formulas:, ● n = number of observations = 9, ● Range = maximum value – minimum value = 100 – 1 = 99, ● # of intervals = √n = √9 = 3, ● Width of intervals = Range / (# of intervals) = 99/3 = 33, Based on these values we can create frequency table, Intervals(bins)Frequency, 0-33 3, 34-67 1, 68-101 5, (will not get the exact figure, output may slightly differ), , 0, , 20, , 40, , 60, , 80, , 100, , 4.0, 3.5, , he, , rs, , 20. Write code to create a Histogram with the given values of, x(4 bins) using facecolor=red, x=[10,10,155,70,50,125,75,149,98,81], Ans. import matplotlib.pyplot as plt, , 1.5, , plt.hist(x,bins=4,facecolor=’red’), , ot, , 1.0, 0.5, 0.0, 20, , marks=[30,10,55,70,50,25,75,49,28,81], , plt.hist(marks, bins=’auto’, color=’green’), , G, , plt.xlabel(‘marks’), , plt.ylabel(‘Frequency’), plt.title(‘Result’), plt.show(), , 82, , 40, , 60, , 80 100, , 120 140 160, , Result, 3.0, 2.5, , Frequency, , oy, , al, , Br, , 21. On the basis of the given histogram fill the blanks, import matplotlib.pyplot as plt, marks=[30,10,55,70,50,25,75,49,28,81], plt._____(marks, bins=’auto’, color=’green’), plt._______(‘marks’), plt.ylabel(‘______’), plt._____(‘Result’), plt.show(), Ans. import matplotlib.pyplot as plt, , 2.5, 2.0, , x=[10,10,155,70,50,125,75,149,98,81], plt.show(), , 3.0, , 2.0, 1.5, 1.0, 0.5, 0.0, 10, , 20, , 30, , 40, , 50, marks, , 60, , 70, , 80, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 90 :
MULTIPLE CHOICE QUESTIONS, Fill in the blanks :, , 1. The command used to give a heading to a graph is _________, (a) plt.show(), (b) plt.plot(), (c) plt.xlabel(), , (d) plt.title(), , 1[SP 21], , as, ha, n, , , , 2. Using Python Matplotlib _________ can be used to count how many values fall into each interval., 1[SP 21], , (a) line plot, (b) bar graph, (c) histogram, (d) None of these, , 3. Mr. Sharma is working in a game development industry and he was comparing the given chart on the basis of, the rating of the various games available on the play store. He is trying to write a code to plot the graph. Help, Mr. Sharma to fill in the blanks of the code and get the desired output., [CBSE QB], 5, , 3, , Pr, ak, , Rang, , 4, , 2, , 1, , 0, , Subway Surfer Temple Run Candy Crush, , Bo le Shot, , Runner Best, , , , , ot, , oy, , , , Br, , , , (i) Choose the right code from the following for statement 1., (a) matplotlib as plt , (b) pyplot as plt, (c) matplotlib.pyplot as plt , (d) matplotlib.plt as pyplot, (ii) Identify the name of the function that should be used in statement 2 to plot the above graph., (a) line(), (b) bar(), (c) hist(), (d) barh(), (iii) Choose the correct option for the statement 3., (a) title(“Rating”), (b) ytitle(“Rating”), (c) ylabel(“Rating”), (d) yaxis(“Rating”), (iv) Choose the right function/method from the following for the statement 4., (a) display(), (b) print(), (c) bar(), (d) show(), (v) In case Mr. Sharma wants to change the above plot to any other shape, which statement, should he change., (a) Statement 1, (b) Statement 2, (c) Statement 3, (d) Statement 4, 4. Gaurav has written a Python Code to create a bar plot as given below using the following data: [CBSE QB], , al, , , , , he, , rs, , , import__________________________ #Statement 1, Games=[“Subway Surfer”,”Temple Run”,”Candy Crush”,”Bottle Shot”,”Runner Best”], Rating=[4.2,4.8,5.0,3.8,4.1], plt.______________(Games,Rating) #Statement 2, plt.xlabel(“Games”), plt.______________(“Rating”) #Statement 3, plt._______________ #Statement 4, , G, , City, , Happiness_Index Male, , Happiness_Index Female, , Delhi, , 60, , 30, , Beijing, , 40, , Washington, , 70, , 70, , Tokyo, , 65, , 55, , Moscow, , 85, , 75, , 60, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 83
Page 91 :
Male, Female, , 80, , 60, 50, 40, 30, 20, 10, 0, Delhi, , Bejing, , Washington, , Moscow, , #Statement 1, , Pr, ak, , , import ________as________, , Tokyo, , as, ha, n, , 70, , City=[‘Delhi’,’Beijing’,’Washington’,’Tokyo’,’Moscow’], , Gender=[‘Male’,’Female’] Happiness_Index_Male=[60,40,70,65,85], , Happiness_Index_Female=[30,60,70,55,75], , plt.bar([0.25,1.25,2.25,3.25,4.25],Happiness_Index_, Male,color=’blue’,label=”Male”,width=.5), , rs, , p l t ., _______________([.75,1.75,2.75,3.75,4.75],Happiness_, Index_Female,color= ’Green’,width= .5,label= ”Female”) , #Statement 2, pos=range(len(City)) print(pos), , he, , plt.xticks(pos,City,fontsize=10), plt.xlabel(‘City’, fontsize=16), , plt.ylabel(‘Happiness_Index’, fontsize=16), _______ #Statement 3, , ot, , _______ #Statement 4, _______ #Statement 5, , , , (ii) What is the name of the function to plot the required bar graph in the line marked as Statement 2, (a) hist(), (b) pie(), (c) bar(), (d) scatter(), , Br, , , , , (i) Identify the suitable code to be used in the blank space in line marked as Statement1., (a) matplotlib as plt , (b) numpy as np, (c) pandas as pd , (d) matplotlib.pyplot as plt, , al, , (iii) Fill in the blank in statement 3 to set Chart Title as “Happiness Index across cities by gender“and font size, as 18., (a) plt.xtitle(“Happiness Index across cities by gender”,fontsize=18), (b) plt.title(“Happiness Index across cities by gender”,fontsize=18), (c) plt.ytitle(“Happiness Index across cities by gender”,fontsize=18), (d) plt.show(“Happiness Index across cities by gender”,fontsize=18), , G, , oy, , , , , , , , , , 84, , (iv) Identify the suitable code for line marked as Statement 4 to display the legends as shown in the plot., (a) plt.showlegend(), (b) plt.legend(), (c) plt.display(), (d) plt.show(), (v) Fill in the blank marked in Statement 5 to display the plot., (a) plt.plot(), (b) plt.showplot(), (c) plt.display(), (d) plt.show(), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 92 :
5. Fill in the blanks :, (d) p1.graphbar(x,y), , , , (ii) The command used to draw a bar graph horizontally is _________, (a) p1.barhor(x,y), (b) p1.hbar(x,y), (c) p1.barh(x,y), , (d) p1.graphbarh(x,y), , , , (iii) The command used to display the graph is _________, (a) plt.show(), (b) plt.plot(), (c) plt.display(), , (d) plt.disp(), , , , (iv) The command used to set the label of x axis is _________, (a) plt.xaxis(), (b) plt.labelx(), (c) plt.xtitle(), , (d) plt.xlabel(), , (v) Fill in the blanks :, The command used to set the label of y axis is _________, , (a) plt.yaxis(), (b) plt.labely(), (c) plt.ytitle(), 7. Fill the missing statement, import matplotlib.pyplot as plt, , marks=[30,10,55,70,50,25,75,49,28,81], , (d) plt.ylabel(), , Pr, ak, , 6. Give single line python code to set the heading of a Line Graph is “Result”, , as, ha, n, , , , (i) The command used to draw a bar graph is _________, (a) p1.bargraph(x,y), (b) p1.bar(x,y), (c) p1.bgraph(x,y), , plt._____(marks, bins=’auto’, color=’green’), plt.show(), , (d), 2. (c), (i) (c), (ii) (b), (i) (d), (ii) (c), (i) (b), (ii) (c), p1.title(“Result”), , (c) hist, , (d) hist, , ANSWERS, , (iii), (iii), (iii), 7., , (c), (b), (a), (c), , (iv) (d), (iv) (b), (iv) (d), , (v) (b), (v) (d), (v) (d), , G, , oy, , al, , Br, , ot, , 1., 3., 4., 5., 6., , (b) bar, , rs, , (a) plot, , he, , , , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 85
Page 93 :
DIGITAL FOOTPRINTS, , as, ha, n, , 4, , Societal Impacts, , he, , rs, , Pr, ak, , 1. What is a digital footprint?, Ans. A digital footprint is data that is left behind when users have been online. There are two types of digital footprints, which are passive and active. Examples of dgital footprint are websites that install cookies on your devices, apps, and websites that use your geolocation, and social media that use your likes, shares and comments to profile., 2. What are the two types of digital footprint?, Ans. There are two main types of digital footprint: passive and active., A passive digital footprint is data you leave behind without knowing when using the internet. For example, your, IP address, approximate location, or browser history. A passive footprint is made when information is collected, from the user without the person knowing this is happening., An active digital footprint is created when you deliberately submit information, 3. Priyanka is using her internet connection to book a flight ticket. This is a classic example of leaving a trail of, web activities carried by her. What do we call this type of activity? What is the risk involved by such kind of, activity? , 2[SP 21], Ans. We call this type of activity as Digital Footprints, , Risk involved: It includes websites when she sends emails and any information she submit online, etc., along, with the computer’s IP address, location, and other device specific details. Such data could be used for targeted, advertisement or could also be misused or exploited., , ot, , NET AND COMMUNICATION ETIQUETTES, , oy, , al, , Br, , 4. What do you understand by Net Etiquettes? Explain any two such etiquettes., 3[SP 21], Ans. Net etiquettes refers to the proper manners and behaviour we need to exhibit while being online., These include :, (i) No copyright violation: We should not use copyrighted materials without the permission of the creator or, owner. We should give proper credit to owners/creators of open source content when using them., (ii) Avoid cyber bullying: Avoid any insulting, degrading or intimidating online behaviour like repeated posting, of rumours, giving threats online, posting the victim’s personal information, or comments aimed to publicly, ridicule a victim., (iii) Data Protection, , G, , 5. What do you mean by Identity theft? Explain with the help of an example., 3[SP 21], Ans. Identity theft is the crime of obtaining the personal or financial information of another person for the sole purpose, of assuming that person’s name or identity to make transactions or use it to post inappropriate remarks, comments, etc., , Example: Alex likes to do his homework late at night. He uses the Internet a lot and also sends useful data, through email to many of his friends. One Day he forgot to sign out from his email account. In the morning, his, twin brother, Flex started using the computer. He used Flex’s email account to send inappropriate messages to, his contacts., , 86, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 94 :
7. What can be done to reduce the risk of identity theft? Write any two ways., Ans. Follow steps to reduce the risk of identity theft:, (i) Don’t Give out Personal Information to anyone, (ii) Don’t Carry Your Social Security Card., , Firewall, , as, ha, n, , 6. What is a Unique Id? Write the name of the Unique Identification provided by Government of India for Indian, Citizens. , [2][comptt 2020], Ans. Unique identifier (UID) is any identifier which is guaranteed to be unique among all objects and is used for, identifying various objects. The Unique Identification provided by the Government of India for Indian Citizens, is Aadhaar., 2[CS SP 2019-20], , 8. Define Firewall. , [SP 14], Ans. Firewall is hardware or software based network security system. It prevents unauthorized access to or from a, network., , Pr, ak, , 9. What do you understand by the term Firewall? What is it used for?, Ans. Refer to Q8 above., , 10. What term we use for a software/hardware device, which is used to block, unauthorized access while permitting, authorized communications. This term is also used for a device or set of devices configured to permit, deny,, encrypt, or proxy all (in and out) computer traffic between different security domains based upon a set of rules, and other criteria., [D 10], Ans. Firewall, , rs, , 11. How is firewall useful in ensuring network security?, [OD 16], Ans. A Firewall permits only that data to enter or leave a computer/Network for which permissions have been granted, by the computer/network administrator., , Br, , ot, , he, , 12. Explain two measures that a school should take to ensure security of their computer network., [compt 2017], Ans. Use a firewall and be careful when using computer., 13. Name the following devices:, (i) This device constantly looks at all the data entering and exiting your connection. It can block or reject data, in response to an established rule., (ii) This device connects multiple nodes to form a network. It redirects the received information only to the, intended node(s)., 2 [2018], Ans. (i) Firewall, (ii) Switch, , oy, , al, , 14. Explain the terms Firewall and Cyber Law., 2 [D 17], Ans. Firewall: A Firewall is a hardware/software that permits only authorised data to enter/leave the network., , Cyber Law: Cyber Law is the law that deals with offences related to data/information stored on computers or, networked devices/solutions., 15. To prevent unauthorized access to and or from the network, a system known as ____________, can be implemented, by hardware and/or software, [SP 21], Ans. Firewall, , G, , 16. Ms. Sita trying to log into your Internet Banking account for online transaction activity. However, as strange as, it may seem, she is denied of an access to the bank's website, in spite of having a swift internet connection., What do you think the reason behind this problem is and suggest her few simple precautions in order to overcome, any such type of network security threats. , 2[SP 18], Ans. She could be under a DoS attack! She should deploy an antivirus program and firewall into her network if not, already done. This helps in restricting the bandwidth usage to authenticated users only., Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 87
Page 95 :
INTELLECTUAL PROPERTY, , 17. What is Intellectual property?, Ans. Intellectual property refers to creations of the mind: inventions; literary and artistic works; and symbols, names, and images used in commerce., , as, ha, n, , 18. What are the different types of Intellectual property?, Ans. T h ere are four primary types of intellectual property (IP) that can be legally protected: patents, trademarks,, copyrights, and trade secrets., , Copyright, , Pr, ak, , 19. What is copyright?, Ans. A copyright is a collection of rights that automatically vest to someone who creates an original work of authorship, – like a literary work, song, movie or software. It allows the copyright owner to protect against others copying, or reproducing their work, The following types of works are allowed protection under the copyright law:, , ● Literary Works. ..., , ● Musical Works. ..., , ● Dramatic Works. ..., , ● Pantomimes and Choreographic Works. ..., , ● Pictorial, Graphic, and Sculptural Works. ..., , ● Motion Pictures and Other Audiovisual Works. ..., , ● Sound Recordings. ..., , ● Compilations., , ot, , he, , rs, , 20. What things can not be copyrighted?, Ans. Ideas, Methods, or Systems. Ideas, methods, and systems are not covered by copyright protection. ..., Commonly Known Information. This category includes items that are considered common property and with no, known authorship. ..., Choreographic Works. ..., Names, Titles, Short Phrases, or Expressions. ..., Fashion, , Br, , 21. What is the difference between copyright and license?, Ans. Copyright is the legal term used to declare and prove who owns the intellectual property (the code, text, etc.)., Licensing is the legal term used to describe the terms under which people are allowed to use the copyrighted, material. Only the copyright owner (or their agent) can enter in to a license agreement., , Plagiarism, , al, , 22. What is plagiarism?, Ans. The act of plagiarism simply involves taking someone else’s work and/or ideas and using them as your own,, rather than giving credit to the rightful owner or receiving consent before taking the material., , oy, , 23. Plagiarism is wrong, or right?, Ans. It’s wrong because it is a literary theft and academic misconduct., , G, , 24. Is copy from internet called plagiarism?, Ans. Yes, we cannot copy anything from internet no matter whether it belongs to a book/journal/or from a web source, without giving reference to the source. All you needs to do is give due credit to the source from where ever you, have taken., 25. Why does student plagiarize?, Ans. There are many reasons for students to do plagiarize:, , 88, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 96 :
as, ha, n, , (i) Study pressure: It is one of the reasons why do students plagiarize in academic writing. Students are, busy with lot many things like assignments/presentations/term end examinations and along with that, they also have to write their synopsis/papers so may be this is one of the reason they find it easy to, cut/copy and paste., (ii) Disorganization: Disorganizations is when lot many thing going in your mind what to do what not to, do and what to do first ..What to do later…somewhere in between you may thing of just copying from, internet or from any other source., , (iii) Poor study habits: When students do not take much interest in their research/work. They just take it very casually, and they try to find any easy way of completing their assignment or whatever work they have been assigned., (iv) Lack of strict academic discipline, , Lack of understanding the implications of plagiarism, sometimes students as well as even teachers are not aware of, consequences of plagiarism. It can sometimes lead to plagiarism., , Pr, ak, , 26. Th e practice of taking someone else’s work or ideas and passing them off as one’s own is known as, _____________, [SP 21], Ans. Plagiarism, , rs, , 27. Write names of any two common types of Intellectual Property Rights which are protected by the Law. [comptt 2020], Ans. Types of Intellectual Property Rights (Any two from the following):, ● Rights upon musical, literary, and artistic works, ● Rights upon discoveries and inventions, ● Words, phrases, symbols, and designs, ● Copyrights, trademarks, patents, industrial design rights and trade secrets, , E-WASTE, , Br, , ot, , he, , 28. What is e-waste and why is it a problem?., Ans. The term “e-waste” is an abbreviation of “electronic and electrical waste”. E-Waste is a term used to cover items, of all types of electrical and electronic equipment (EEE) and its parts that have been discarded by the owner as, waste without the intention of re-use., People replace things: smartphones, tablets, phablets, laptops, LEDs, LCDs, DVD players, portable music players., Whether from breakdown, slow-down, or just the availability of a newer model, people discard electronics at the, slightest inconvenience., The increase in consumption of electronics has two major adverse ecological effects. First, it significantly increases, mining and procurement for the materials needed for production of gadgets. And second, discarded devices produce, large quantities of electronic waste. That waste could be reduced through reuse, repair, or resale., , G, , oy, , al, , 29. What are the problems caused by e-waste?, Ans. Electronic devices also comprise toxic heavy metals like lead, mercury, cadmium and beryllium, polluting PVC plastic,, and hazardous chemicals, such as brominated flame retardants, which can harm human health and the environment., 30. What is the solution to e-waste., Ans. The solution of e-waste:, , (i) Recycling: Electronic devices are made of a complex mix of materials that include gold, silver, copper,, platinum, palladium, lithium, cobalt and other valuable elements. These precious materials can be reclaimed, through recycling., , (ii) Designing better products: In order to reduce e-waste, manufacturers need to design electronics that are, safer, and more durable, repairable and recyclable. Most importantly, this means using less toxic materials., , (iii) The right to repair: In addition to recycling, it’s also important to be able to repair and reuse the devices, we have. But even if you know how to and want to repair your electronic device, you cannot do it because, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 89
Page 97 :
your product’s software is subject to copyright. The copyright often forbids consumers by law to use an, unauthorized repairer. So the people should have the right to repair devices and teaches people how to do it., Finally,the best thing you can do is to resist buying a new device until you really need it. Try to get your, old product repaired if possible and if it can’t be fixed, resell or recycle it responsibly., , Pr, ak, , as, ha, n, , 31. According to a survey, one of the major asian country generates approximately about 2 million tonnes of electronic, waste per year. Only 1.5% of the total e-waste gets recycled. Suggest a method to manage e-waste., [SP 21], Ans. Buy environmentally friendly electronics Donate used electronics to social programs Reuse, refurbish electronics, Recycling e-waste, 32. As a citizen of india, What advise you should give to others for e-waste disposal?, 1[CS SP 2019-20], Ans. As a citizen of india, We can advice the following principle of waste management:, Reduce, Reuse and Recycle., 33. Ms Samtha has many electronics gadgets which are not usable due to outdated hardware and software. Help her, to find any three best ways to dispose the used electronic gadgets., [SP 20], Ans. (i) Give Your Electronic Waste to a Certified E-Waste Recycler, (ii) Donating Your Outdated Technology, (iii) Give Back to Your Electronic Companies and Drop Off Points, , Awareness about health concerns related to the usage of technology, , he, , rs, , 34. List any two health hazards related to excessive use of Technology., 2[SP 21], 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., , HACKERS AND CRACKERS, , Br, , ot, , 35. Who is a hacker?, Ans. Hackers are the good people who do hacking with a good purpose. Hackers are also known as White Hats or, saviour. They are the programmers or computer experts with adequate knowledge of programming and coding, who find the loopholes present in a system and try to cover them and hence protect the system. The hackers try, and remove the flaws in the system, making it more secure. They never work with the objective of harming the, system or stealing and misusing the data., , oy, , al, , 36. How is a Hacker different from a Cracker?, Ans. The general view is that, while hackers build things, crackers break things. Crackers also have the same knowledge, of the systems, programming and coding as the hackers do. They also perform the same activities as hackers do., However, their objective is of breaking the system and network to gain unauthorized access. This is the main, difference between hacker and cracker. The activity performed by crackers is illegal. They use their coding and, programming knowledge to get personal and financial gains, steal data, destroy data or even delete crucial data.., , G, , 37. Jai is an IT expert and a freelancer. He recently used his skills to access the Administrator password for the, network server of Megatech Corpn Ltd. and provided confidential data of the organization to its Director, informing, him about the vulnerability of their network security. Out of the following options (i) to (iv), which one most, appropriately defines Jai. Justify the reason for your chosen option:, (i) Hacker, (ii) Cracker, (iii) Operator, (iv) Network Admin, Ans. (i) Hacker: A Hacker is a person who breaks into the network of an organization without any malicious intent., , 90, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 98 :
CYBER CRIME AND CYBER LAW, 38. What is the significance of Cyber Law?, Ans. Cyber law is a term used to describe the legal issues related to use of communications technology, particularly, “cyberspace”, i.e. the Internet., , as, ha, n, , 39. What is cyber crime?, Ans. Cyber crime is a crime that involves a computer and a network. The computer may have been used in the, commission of a crime, or it may be the target. Cyber crime may harm someone’s security and financial health., We can categorize Cyber crimes in two ways:, (i) The Computer as a Target: using a computer to attack other computers, e.g. Hacking, Virus/Worm attacks,, DOS attack etc., (ii) The computer as a weapon: using a computer to commit real world crimes, e.g. Cyber Terrorism, IPR violations,, Credit card frauds, EFT frauds, Pornography etc. Cyber Crime is regulated by Cyber Laws or Internet Laws., , Pr, ak, , 40. Which of the following crime(s) is/are covered under cyber crime?, , (i) Stealing brand new hard disk from a shop., , (ii) Getting into unknown person’s social networking account and start messaging on his behalf., , (iii) Copying some important data from a computer without taking permission from the owner of the data., Ans. (ii) and (iii), , rs, , 41. Which out of the following comes under Cyber Crime?, , (i) Operating someone’s Internet banking account, without his knowledge., , (ii) Stealing a keyboard from someone’s computer., , (iii) Working on someone’s computer with his/her permission., , (iv) Looking at online activities of a friends blog., Ans. (i) Operating someone’s Internet banking account, without his knowledge., , ot, , he, , 42. Out of the following, which all comes under cyber crime?, , (i) Stealing away a brand new computer from a showroom., , (ii) Getting in someone’s social networking account without his consent and posting pictures on his behalf to, harass him., , (iii) Secretly copying files from server of a call center and selling it to the other organization., , (iv) Viewing sites on a internet browser., Ans. (ii) and (iii), , Br, , 43. Out of the following, which all comes under cyber crime?, , (i) Stealing away a brand new hard disk from a showroom., , (ii) Getting in someone’s social networking account without his consent and posting on his behalf., , (iii) Secretly copying data from server of a organization and selling it to the other organization., , (iv) Looking at online activities of a friends blog., Ans. (ii) and (iii), , oy, , al, , 44. Jhilmalini has stolen a credit card. She used that credit card to purchase a laptop. What type of offence has she, committed?, 1[SP 20], Ans. She has committed a fraud., , G, , 45. Identify the type of cyber crime for the following situations:, [SP 2019-20], , (i) A person complains that ` 4.25 lacs have been fraudulently stolen from his/her account online via some online, transactions in two days using NET BANKING., , (ii) A person complaints that his/her debit/credit card is safe with him still some body has done shopping/ATM, transaction on this card., , (iii) A person complaints that somebody has created a fake profile on Facebook and defaming his/her character, with abusive comments and pictures., Ans. (i) Bank Fraud, (ii) Identity Theft, (iii) Cyber Stalking, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 91
Page 99 :
PHISHING, , Pr, ak, , as, ha, n, , 46. Ravi received a mail form IRS department (as shown below). On clicking “ ClickHere” ,he was taken to a site, designed to imitate an official-looking website, such as IRS.gov. He uploaded some important information on it., Identify and explain the cyber crime being discussed in the above scenario., [CS SP 2019-20], , Ans. It is an example of phishing. Phishing is a term used to describe a malicious individual or group of individuals, who scam users. They do so by sending e-mails or creating web pages that are designed to collect an individual’s, online bank, credit card, or other login information., 47. Name the primary law in India dealing with cyber crime and electronic commerce., Ans. The primary law is Information Technology Act 2000., , 1[SP 20], , he, , rs, , 48. Sutapa received an email from her bank stating that there is a problem with her account. The email provides, instructions and a link, by clicking on which she can logon to her account and fix the problem. Help Sutapa by, telling her the precautions she should take when she receives these type of emails., 2[SP 20], Ans. She should check whether it is a valid bank site or not by checking in the url https. It is always better to type, the url and then login to the site. She should not click on the link provided in the email., , IT ACT, , Br, , ot, , The Information Technology Act, 2000 (also known as ITA-2000, or the IT Act) is an Act of the Indian Parliament, notified on 17 October 2000. It is the primary law in India dealing with cyber crime and electronic commerce., List of some Offence:, ● Tampering with computer source documents, ● Hacking with computer system, ● Receiving stolen computer or communication device ● Using password of another person, ● Cheating using computer resource, ● Publishing private images of others, ● Failure to maintain records, , al, , 49. Name the primary law in India dealing with cybercrime and electronic commerce., Ans. The primary law is Information Technology Act 2000., , 1[SP 20], , CYBERBULLYING, , G, , oy, , 50. What is cyberbullying?, Ans. Cyberbullying includes sending, posting, or sharing negative, harmful, false, or mean content about someone else., It can include sharing personal or private information about someone else causing embarrassment or humiliation., , Example of cyberbullying:, , ● Sending mean texts or IMs to someone., ● Pranking someone’s cell phone., , ● Hacking into someone’s gaming or social networking profile., , ● Being rude or mean to someone in an online game., , ● Spreading secrets or rumours about people online., , 92, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 100 :
OPEN SOURCE SOFTWARE, , [2011 SP], , Pr, ak, , 52. Which of the following is not a characteristic of Open Source Software?, , (i) Its source code is available for modification, , (ii) It is owned by a company or an individual, , (iii) It can be downloaded from internet, Ans. (ii) It is owned by a company or an individual, , as, ha, n, , 51. What is open source software? Write the names of any two software which can be categorized as Open, Source., 2[comptt 2020], Ans. Open source software is software with source code that anyone can inspect, modify, and enhance., Names of open source software (Any two):, , ● Mozilla’s Firefox web browser., ● Thunderbird email client., , ● PHP scripting language., ● Python programming language., , ● Apache HTTP web server., ● LibreOffice, , ● GNU Image Manipulation Program, ● Linux operating system, , 53. Ms. Vidya Chauhan is confused between Proprietary Software and Open Source Software. Mention at least two, points of difference to help her understand the same., [2011 OD], OR, Distinguish between Open Source software and Proprietary Software., , [2014 OD], , Source Code is available, , Proprietary Software, , he, , Open Source Software, , rs, , OR, Distinguish between Open Source Software and Proprietary software with reference to customizability of the, software?, [SP 11], Ans. Difference between:, Source Code is not available., Modifications to source code cannot be done, , Supported by a community of users and developers, , Supported by vendors at a cost, , Generally no license fee, , License fee is charged, , Example : Open Office, , Example: Microsoft Office, , Br, , ot, , Modifications to source code can be done, , [2012 D], , [2014 OD], [OD 14,D 13], [D 13], [OD 13], [OD 13], , G, , oy, , al, , 54. Write examples of one proprietary and one open source software., Ans. Proprietary Softwares : Microsoft windows, Adobe Photoshop, Open source software: MySQL, Java, 55. Expand the following terms :, , (i) OSS, , (ii) ODF, , (iii) XML, , (iv) FLOSS, , (v) HTTP, Ans. (i) Open Source Software, , (ii) Open Document Format, , (iii) XML : Extensible Markup Language, , (iv) FLOSS : Free Libre and Open Source software, (v) HTTP : Hypertext Transfer Protocol, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 93
Page 101 :
56. Name one open source indian operating system., Ans. BOSS (Bharat Operating Systems Solutions), , [2015 D], [2015 OD], , as, ha, n, , 57. Write one advantage and one disadvantage of Open Source software over Proprietary software., Ans. Advantages of Open Source software over Proprietary software any one:, , (i) Free to use, distribute, and modify, , (ii) No dependence on the developer for updates, support, and fixes., , (iii) Uses Open Standards, , Disadvantages of Open Source software over Proprietary software any one:, , (i) Lack of Software Support, , (ii) Generally low Security, , [SP 18], , 59. Which of the following softwares are Open Source:, Linux, MS Windows 7, Photoshop, MySql, Ans. Linux and MySQL, , [SP 11], , Pr, ak, , 58. Write down any two advantages of Open Source Software over Proprietary software., Ans. Advantages:, , (i) Source code is available., , (ii) Money need not to be paid for procuring the license for usage and further distribution., , rs, , 60. “Open Source Software developers work for the good of community”. Is this statement true? Give reason. [D 16], Ans. Yes, the above statement is true. These include:, , (i) Open source developers choose to make the source code of their software publicly available to which many, developers can view/use the software and also modify it., , (ii) Users can download the software free of cost. So, they work for the good of the community., , he, , 61. What is the meaning of ‘Open source’ in the term ‘Open Source Database Management System’?, [OD 16], Ans. Open source means that the software can be studied, copied, redistributed freely and even modified according to, one’s need without seeking any kind of permission. In order to modify such software, the developers also provide, the source code to the users, , ot, , 62. Which of the following are open source software:, GNU, MS-Office, BOSS, Windows OS, Ans. GNU, BOSS, , G, , oy, , al, , Br, , 63. Write two examples each of software in the following categories:, , (i) Open Source Operating System, , (ii) Open Source Web Browser , 2 [2018], Ans. (i) Linux, Android, FreeBSD, OpenBSD, NetBSD, DragonFly BSD, OpenSolaris, illumos, AuroraUX, Darwin,, OpenDarwin, MINIX, FreeRTOS, FreeDOS, Haiku, House KolibriOS, MenuetOS, GNU, ReactOS, L4, Fiasco,, Pistachio, Plan 9, AROS, Syllable, Inferno, NuttX, eCos, RTEMS, HelenOS, E/OS, TempleOS, Linux, BOSS,, Ubuntu, Kali Linux, , (ii) Mozilla Firefox, Google Chrome, Opera, QupZilla, Midori, rekonq, Tor Browser, NetSurf, Pale Moon, GNOME, Web., 64. Name the government organization that contributes to the growth of FOSS in India., Ans. National Resource Centre for free and open source software (NRCFOSS) is the government organization that, contributes to the growth of FOSS in India., 65. Does Open source software only mean that the software is free of cost? Give reason for your answer. 2 [OD17], Ans. No, it does not only mean that the software is free of cost., , Reason: It also means that the source code is available to user with freedom to use, modify and distribute, , 94, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 102 :
68. Expand the following:, , (i) ODF, Ans. (i) Open Document Format, , (ii) Point to Point Protocol, , 1[SP 17], , Pr, ak, , (ii) PPP, , as, ha, n, , 66. Differentiate between open source and open data., 2 [CS SP 2019-20], Ans. These licenses are based on the copyright protection of the code., Thus, the “open” of open source refers to the source code. Difference between open data and open source is that, of data versus application. Data can be numbers, locations, names, etc., 67. After realising the issues with proprietary software, Ms. Sunita has decided to use only Open Source Software., Suggest any one suitable open source software to her, for each of the following categories:, , (i) Operating System, , (ii) Browser, 1[SP 17], Ans. (i) Linux or Google Chrome OS or any other open source OS, , (ii) Mozilla Firefox or Google Chrome or any other open source browser, , MULTIPLE CHOICE QUESTIONS, , 1. An organisation purchases new computers every year and dumps the old ones into the local dumping yard. Write, the name of the most appropriate category of waste that the organisation is creating every year, out of the following, options: , [1] [comptt 2020 cs], , (a) Solid Waste, (b) Commercial Waste, (c) E-Waste, (d) Business Waste, , ot, , he, , rs, , 2. A software company purchases new computers every year and discards the old ones into the local dumping yard., Write the name of the most appropriate category of waste that the organisation is creating every year, out of the, following options:, 1[comptt 2020], , (a) Business Waste , (b) Commercial Waste, , (c) Solid Waste , (d) E-Waste, 3. Ms. Raveena Sen is an IT expert and a freelancer. She recently used her skills to access the Admin password, for the network server of Super Dooper Technology Ltd. and provided confidential data of the organization to, its CEO, informing him about the vulnerability of their network security. Out of the following options (a) to (d),, which one most appropriately defines Ms. Sen?, , (a) Hacker, (b) Cracker, (c) Operator, (d) Network Admin, , Br, , 4. Pratibha is an IT expert and a freelancer. She is undertakes those jobs, which are related to setting up security, software/tools and managing networks in various companies. If we name her role in these companies, what it, will be out of the following:, [comptt 2017], , (a) Cracker, (b) Network Admin, (c) Hacker, (d) Operator, , al, , oy, , , , , , , 5. Which out of the following does not come under Cyber Crime?, (a) Copying data from the social networking account of a person without his/her information & consent., (b) Deleting some files, images, videos, etc. from a friend's computer with his consent., (c) Viewing and transferring funds digitally from a person's bank account without his/her knowledge., (d) Intentionally making a false account on the name of a celebrity on a social networking site., , G, , 6. The school offers Wi-Fi to the students of Class XII. For communication, the network security-staff of the school, is having a registered URL “schoolwifi.edu”. On 17th September 2017, emails were received by all the students, regarding expiry of their passwords. Instructions were also given renew their password within 24 hours by clicking, on particular URL provided. On the bases of the above case study, answer the questions given below. Specify which, type of cybercrime is it., [CBSE QB], , (a) Spamming, (b) Phishing, (c) Identity Theft, (d) Hacking, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 95
Page 103 :
7. Data which has no restriction of usage and is freely available to everyone under Intellectual Property Rights is, categorised as:, [comptt 2020 cs], [1] [comptt 2020 cs], , (a) Open Source, (b) Open Data, (c) Open Content, (d) Open Education, , as, ha, n, , 8. Consider the following scenario and answer the questions which follow:, [comptt 2020 cs], “A student is expected to write a research paper on a topic. The student had a friend who took a similar class five, years ago. The student asks his older friend for a copy of his paper and then takes the paper and then submits, the entire paper as his own research work.”, , , (i) Which of the following activities appropriately categorises the act of the writer?, (a) Plagiarism, (b) Spamming, (c) Virus, , , , , (ii) Which kind of offense out of the following is made by the student?, (a) Cyber Crime , (b) Civil Crime, (c) Violation of Intellectual Property Rights, (d) None of these, , (d) Phishing, , [2], , , , , Pr, ak, , 9. A research student is expected to write a thesis on a topic. The student browses Internet for the topic and luckily, finds it on the Internet. He copies and submits the entire thesis as his own research work. Which of the following, activities appropriately categorises the act of the writer?, 1[comptt 2020], , (a) Spamming, (b) Phishing, (c) Plagiarism, (d) Trojan, 10. Which of the following is not an intellectual property?, (a) A poem written by a poet , (c) Trademark of a Company , , (b) An original painting made by a painter, (d) A remixed song, , 1[SP 20], , he, , rs, , 11. Sumit has to prepare a project on “Swachh Bharat Shreshth Bharat”. He decides to get information from the, Internet. He downloads three web pages (webpage1, webpage 2, webpage 3) containing information on the given, topic. , [CBSE QB], , 1. He read a paragraph on from webpage 1 and rephrased it in his own words. He finally pasted the rephrased, paragraph in his project., , 2. He downloaded three images of from webpage 2. He made a collage for his project using these images., , 3. He also downloaded an icon from web page 3 and pasted it on the front page of his project report., (i) Step 1 : An Example of __________, (a) Plagiarism , (c) Copyright infringement , , (b) Paraphrasing, (d) Intellectual Property Right, , , , , (ii) Step 2 : An act of __________, (a) Plagiarism , (c) Intellectual Property Right, , (b) Copyright infringement, (d) Digital Footprints, , , , , (iii) Step 3 : An act of _________, (a) Plagiarism , (c) Copyright infringement , , (b) Paraphrasing, (d) Intellectual Property Right, , al, , Br, , ot, , , , , G, , , , 96, , (c) Browsers, , (d) Hyperlinks, , (v) The process of getting web pages, images and files from a web server to local computer is called, (a) FTP, (b) Uploading, (c) Downloading, (d) Remote access, , oy, , , , (iv) A website is a collection of ___________, (a) Web servers, (c) Web pages, , 1. (c), 9. (c), , 2. (d), 10. (b), , ANSWERS, , 3. (i), 4. (iii), 5. (ii), 11. (i) (b) (ii) (a) (iii) (c), , 6. (b), (iv) (b), , 7. (b), (v) (c), , 8. (i) (a) (ii) (c) , , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 104 :
CBSE SAMPLE QUESTION PAPER, , SECTION : B, , (Released by CBSE for the academic year 2021-22), , Maximum Marks : 35, , as, ha, n, , Time Allowed : 90 Minutes, , General Instructions :, • The paper is divided into 3 Sections- A, B and C., • Section A, consists of Question 1 to 25 and student need to attempt 20 questions., • Section B, consists of Question number 26 to 49 and student need to attempt 20 questions., • Section C, consists of Question number 50 to 55 and student need to attempt 5 questions., • All questions carry equal marks., , SECTION - A, , Pr, ak, , Section A consists of 25 questions, attempt any 20 questions., (c) Python Document, , 2. The command to install the pandas is:, , (a) install pip pandas , , (c) pip pandas , , (b) install pandas, (d) pip install pandas, , 3. Python pandas was developed by:, , (a) Guido van Rossum (b) Travis Oliphant, , (c) Wes McKinney, , 4. Pandas Series is:, , (a) 2 Dimensional , , (c) 1 Dimensional , , (b) 3 Dimensional, (d) Multidimensional, , he, , rs, , 1. The name “Pandas” is derived from the term:, , (a) Panel Data, (b) Panel Series, , 5. Pandas is a:, , (a) Package, , (b) Language, , (d) Brendan Eich, , (c) Library, , (d) Software, , (c) Both of the above, , (d) None of the above, , 7. Out of the following, which function cannot be used for customization of charts in Python?, (a) xlabel(), (b) colour(), (c) title(), (d) xticks(), , Br, , , , ot, , 6. We can analyse the data in pandas with, , (a) Series, (b) Data Frame, , (d) Panel Data Frame, , 8. What is the minimum number of arguments required for plot() function in matplotlib?, , (a) 1, (b) 2, (c) 3, (d) 4, , al, , 9. Method or function to add a new row in a data frame is:, , (a) .loc(), (b) .iloc(), (c) join, , oy, , 10. _____________ is the function to save the graph., (a) Savefig(), (b) Savefigure(), , (c) Savegraph(), , (d) add(), (d) Savechart(), , G, , 11. A ______________ is a unique data trace of a user’s activities, actions, communications or transactions in digital, media., , (a) Digital Handprint , (b) Digital Footprint, (c) Offline Footprint, (d) Offline Handprint, 12. Which of the following is not a type of cybercrime?, , (a) Data theft , (b) Forgery of online documents, , (c) Damage to data and systems, (d) Installing antivirus for protection, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 97
Page 105 :
13. ‘F’ in FOSS stands for:, , (a) Free, , (b) Forever, , (c) Fire, , (d) Freezing, , 14. Which of the following import statement is not correct?, (a) import pandas as class12 , (b) import pandas as 1pd, (c) import pandas as pd1 , (d) import pandas as pd, , , , , 15. IPR stands for:, (a) Intelligent Property Rights, (c) Intellectual Property Rights, , (b) Intellectual Property Reserve, (d) Intellectual Product Rights, , , , , 16. Which of the following is not a violation of IPR?, (a) Plagiarism , (c) Patent , , (b) Copyright Infringement, (d) Trademark Infringement, , as, ha, n, , , , , Pr, ak, , 17. While accessing the column from the data frame, we can specify the column name. In case column does not, exist, which type of error it will raise:, , (a) Key Error , (b) Syntax Error, , (c) Name Error , (d) Runtime Error, 18. ____________is the practice of taking someone else's work or ideas and passing them off as one's own., , (a) Plagiarism, (b) Copyright, (c) Patent, (d) All of the above, 19. Function to display the first n rows in the DataFrame:, (a) tail (n), (b) head (n), (c) top (n), , 20. Following are the impact of e-waste on the environment. Choose the odd one out., (a) Soil Pollution , (b) Water Pollution, (c) Air Pollution , (d) Sound Pollution, , rs, , , , , (d) first (n), , he, , 21. Abdul deleted all his chats from all his social media accounts, and he thinks that all his traces are deleted, completely. Is he right in thinking so?, , (a) Yes, (b) No, (c) May be, (d) Not sure, 22. The legal and regulatory aspects of the internet refer to _________________., (a) Cyber Space, (b) Cyber crime, (c) Criminal law, , , , , 23. Pandas data frame cannot be created using:, (a) Dictionary of tuples , (c) Dictionary of List , , , , 24. Which function will be used to read data from a CSV file into pandas data frame?, (a) readcsv(), (b) to_csv(), (c) read_csv(), (d) csv_read(), , , , 25. Which of the following is not an attribute of pandas data frame?, (a) length, (b) T, (c) Size, , oy, , al, , Br, , ot, , , , (d) IT act, , (b) Series, (d) List of Dictionaries, , (d) shape, , SECTION - B, , Section B consists of 24 Questions (26 to 49). Attempt any 20 questions., , 26. What will be the output of the given code?, import pandas as pd, , G, , s = pd.Series([1,2,3,4,5],, , , index=['akram','brijesh','charu','deepika','era']), , , , (b) 2, , print(s['charu']), , 98, , (a) 1, , (c) 3, , (d) 4, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 106 :
27. Assuming the given series, named stud, which command will be used to print 5 as output?, , Amit, , 90, , Mahesh, , 50, , john, , Abdul, , 100, 67, 89, , Name: Student, dtype: int64, , , , , (a) stud.index , (c) stud.values , , (b) stud.length, (d) stud.size, , as, ha, n, , Ramesh, , 28. A social science teacher wants to use a pandas series to teach about Indian historical monuments and its states., The series should have the monument names as values and state names as indexes which are stored in the given, lists, as shown in the code. Choose the statement which will create the series:, import pandas as pd, , Pr, ak, , Monument=['Qutub Minar','Gateway of India','Red Fort','Taj Mahal'], State=['Delhi','Maharashtra','Delhi','Uttar Pradesh'], , , , , , , (a) S=df.Series(Monument,index=State), (b) S=pd.Series(State,Monument), (c) S=pd.Series(Monument,index=State), (d) S=pd.series(Monument,index=State), , rs, , 29. ____________ 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., , (a) Plagiarism, (b) Phishing, (c) Cyberstalking, (d) Hacking, , Br, , ot, , he, , 30. Observe the following figure. Identify the coding for obtaining this as output., , al, , (a) import matplotlib.pyplot, plt.plot([1,2],[4,5]), plt.show(), , (b) import matplotlib.pyplot, plt.plot([1,2,3],[4,5,1]), plt.show(), , (c) import matplotlib.pyplot, plt.plot([2,3],[5,1]), plt.show(), , (d) import matplotlib.pyplot, plt.plot([1,3],[4,1]), plt.show(), , G, , oy, , , , as plt, as plt, as plt, as plt, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 99
Page 107 :
as, ha, n, , 31. Read the statements given below and identify the right option to draw a histogram., , Statement A: To make a Histogram with Matplotlib, we can use the plt.hist() function., Statement B: The bin parameter is compulsory to create histogram., , (a) Statement A is correct, , (b) Statement B is correct, , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, , 32. Which graph should be used where each column represents a range of values, and the height of a column corresponds, to how many values are in that range?, , (a) plot, (b) line, (c) bar, (d) histogram, 33. Suhhani is confused about the free operating system available in the market. Few of her friends suggested a few, operating systems. Help her in choosing free operating system for her device., , (a) Ubuntu, (b) Windows, (c) Mozilla Firefox, (d) Blender, , he, , rs, , 35. Consider the following series named animal:, , Pr, ak, , 34. Consider the following statements with reference to the use of email:, , Statement 1: Sending threatening messages to a classmate., Statement 2: Inviting friends to participate in a school club or sports activity., , Statement 3: Asking your teacher for help on homework., , Statement 4: Responding to or forwarding spam emails., Which of the above statements refer to appropriate use of email?, , (a) Statements 1 and 2. , (b) Statements 2 and 3., , (c) Statements 3 and 4. , (d) Statements 2 and 4., , oy, , al, , Br, , ot, , , Write the output of the command:, print(animal[::-3]), , (a) L, Lion, T Tiger, dtype: object , , (b) B, Bear, E, Elephant, dtype: object, , (c) W, Wolf, B, Bear, dtype: object , , (d) W, Wolf, T, Tiger, dtype: object, , G, , 36. Saharsh is a student of class -9 and he is a very frequent user of internet applications. One day he got an unpleasant, message on his instant messenger. What do you think he should do?, , (a) ignore it and start chatting to someone else., (b) reply back to them and find out what their problem is., , (c) shut down the computer and hope they'll leave him alone in future., , (d) go to his parents, teacher, or other trusted adult and let them know that he feels uncomfortable., , 100, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 108 :
37. What is a correct syntax to return the values of first row of a Pandas DataFrame?, Assuming the name of the DataFrame is dfRent., , (a) dfRent[0], (b) dfRent.loc[1], (c) dfRent.loc[0], (d) dfRent.iloc[1], , , , , , , (c) Recycle, , (d) All of the above, , as, ha, n, , 38. Feasible method(s) to manage e-waste:, , (a) Reduce, (b) Reuse, , 39. Difference between loc() and iloc().:, (a) Both are Label indexed based functions., (b) Both are Integer position-based functions., (c) loc() is label based function and iloc() integer position based function., (d) loc() is integer position based function and iloc() index position based function., 40. Write the output of the given program:, , import pandas as pd, , S1=pd.Series([5,6,7,8,10],index=['v','w','x','y','z']), , Pr, ak, , l=[2,6,1,4,6], , he, , oy, , al, , Br, , ot, , print(S1-S2), , (a) a, 0, v, –1.0, w, 2.0, x, NaN, y, 2.0, z, 8.0, dtype: float64, , (b) a, NaN, v, –1.0, w, 2.0, x, NaN, y, 2.0, z, 8.0, dtype: float64, , (c) v, –1.0, w, 2.0, y, 2.0, z, 8.0, dtype: float64, , (d) a, NaN, v, –1.0, w, 2.0, x, 3.0, y, 2.0, z, 8.0, , rs, , S2=pd.Series(l,index=['z','y','a','w','v']), , dtype: float64, , G, , 41. We should exhibit proper manners and etiquettes while being online. Choose the right net etiquette(s) from the, following:, , (a) Avoid Cyber Bullying , (b) Respect Other’s Privacy, , (c) No Copyright violation , (d) All of the above, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 101
Page 109 :
42. Which command will be used to delete 3 and 5 rows of the data frame. Assuming the data frame name as DF., , (a) DF.drop([2,4],axis=0) , (b) DF.drop([2,4],axis=1), , (c) DF.drop([3,5],axis=1) , (d) DF.drop([3,5]), , Pr, ak, , as, ha, n, , 43. Write the output of the given command:, import pandas as pd, s=pd.Series([1,2,3,4,5,6],index=['A','B','C','D','E','F']), print(s[s%2==0]), , (a) B, 0, D, 0, F, 0, dtype: int64, , (b) A, 1, B, 2, C, 5, dtype: int64, , (c) B, 2, D, 4, F, 6, dtype: int64, , (d) B, 1, D, 2, F, 3, dtype: int64, , ot, , he, , rs, , 44. Ritika is a new learner for the python pandas, and she is aware of some concepts of python. She has created, some lists, but is unable to create the data frame from the same. Help her by identifying the statement which, will create the data frame., import pandas as pd, Name=['Manpreet','Kavil','Manu','Ria'], Phy=[70,60,76,89], Chem=[30,70,50,65], , (a) df=pd.DataFrame({"Name":Name,"Phy":Phy,"Chem":Chem}), , (b) d=("Name":Name,"Phy":Phy,"Chem":Chem) df=pd.DataFrame(d), , (c) df=pd.DataFrame([Name,Phy,Chem],columns=['Name',"Phy","Chem","Total"]), , (d) df=pd.DataFrame({Name:"Name", Phy :"Phy",Chem: "Chem"}), , Br, , 45. Linux, MySQL and Mozilla Firefox software come under_______ category., , (a) Proprietary , (b) FOSS, , (c) Freeware , (d) Shareware, , G, , oy, , al, , 46. Assuming the given structure, which command will give us the given output:, , Output Required: (3,5), , (a) print(df.shape() , , (c) print(df.size) , , 102, , (b) print(df.shape), (d) print(df.size()), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 110 :
(a) 0 Kavita 50000 3000 , (c) 3000 , , (b) 50000, (d) 50000, , Pr, ak, , 48. Consider the following data frame name df., , as, ha, n, , 47. Write the output of the given command:, df1.loc[:0,'Sal'], Consider the given dataframe., , Write the output of the given command: print(df.marks/2), (a) 0, , 45.0, , 2, , 43.5, , 1, , NaN, , rs, , , , , , (b) 0, , 1, 2, , he, , Name: Marks, dtype: float64, 45.0, NaN, 43, , (c) 0, , 1, 2, , 45, , NaN, , Br, , , , ot, , Name: Marks, dtype: float64, , 43.5, , Name: Marks, dtype: float64, , , , (d) 0, , 0, , al, , 1, , 45.0, , 2, , 43.5, , oy, , Name: Marks, dtype: float64, , G, , 49. Read the statements given below. Identify the right option from the following for Attribute and method/function., , Statement A: Attribute always ends without parenthesis., , Statement B: Function/Method cannot work without arguments., , (a) Both statements are correct., , (b) Both statements are incorrect., , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 103
Page 111 :
SECTION - C, Section C consists of 6 Questions (50 to 55). Attempt any 5 questions., , as, ha, n, , Mr. Sharma is working with an IT company, and he has provided some data. On which he wants to do some operations,, but he is facing some problem, help him:, Code:, import pandas as pd, ResultSheet={, , 'Naveen': pd.Series([90, 91, 97],, , he, , rs, , index=['Maths','Science','Hindi']),, 'John': pd.Series([89, 91, 88],, index=['Maths','Science','Hindi']),, 'Roja': pd.Series([81, 71, 67],, index=['Maths','Science','Hindi']),, 'Mannat': pd.Series([94, 95, 99],, index=['Maths','Science','Hindi'])}, DF = pd.DataFrame(ResultSheet), print(DF), Output of the above code:, , Pr, ak, , index=['Maths','Science','Hindi']),, 'Rehana': pd.Series([92, 81, 96],, , Based on the given information, answer the questions NO. 50-55., , Br, , ot, , 50. He wants to add a new column with name of student ‘Prem’ in above data frame choose the right command to, do so:, , (a) DF['Prem']=[89,78,76] , (b) df['Prem']=[89,78,76], , (c) DF['Prem']=[89,78,76,67] , (d) DF['Name']=[89,78,76], 51. He wants to set all the values to zero in data frame, choose the right command to do so:, , (a) DF=0, (b) DF[]=0, (c) DF[:]=0, (d) DF[:]==0, , al, , 52. He wants to delete the row of science marks:, , (a) DF.drop('Science', axis=1) , , (c) DF.drop('Science', axis=-1), , (b) DF.drop('Science', axis=0), (d) DF.drop('Science', axis==0), , G, , oy, , 53. The following code is to create another data frame, which he wants to add to the existing Data frame. Choose, the right command to do so:, Sheet1={, , 'Aaradhya': pd.Series([90, 91, 97],, index=['Maths','Science','Hindi'])}, S1=pd.DataFrame(Sheet1), , (a) DF.append(S1,axis=0) , (b) DF.append(S1), , (c) DF.insert(S1) , (d) DF.join(S1), , 104, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 112 :
54. What will be the output of the given command?, DF.index=['A','B','C'], Rehana, , John, , Roja, , Mannat, , Maths, , 90, , 90, , 89, , 81, , 94, , B, , Science, , 91, , 81, , 91, , 71, , 95, , C, , Hindi, , 97, , 96, , 88, , 67, , 99, , as, ha, n, , A, , Naveen, , Rehana, , John, , Roja, , Mannat, , A, , 90, , 92, , 89, , 81, , 94, , B, , 91, , 81, , 91, , 71, , 95, , C, , 97, , 96, , 88, , 67, , 99, , A, , B, , C, , Roja, , Mannat, , Maths, , 90, , 92, , 89, , 81, , 94, , Science, , 91, , 81, , 91, , 71, , 95, , Hindi, , 97, , 96, , 88, , 67, , 99, , Pr, ak, , , , Naveen, , (d) Error, Index already exists and cannot be overwritten., , (c) 21, , (c) 23, , ANSWERS, , 2. (d), 12. (d), , 3. (c), 13. (a), , 4. (c), 14. (b), , 5. (c), 15. (c), , 6. (c), 16. (c), , 7. (b), 17. (a), , 8. (a), 18. (a), , 9. (a), 19. (b), , 10. (a), 20. (d), , 21. (b), 31. (c), 41. (d), , 22. (d), 32. (d), 42. (a), , 23. (a), 33. (a), 43. (c), , 24. (c), 34. (b), 44. (a), , 25. (a), 35. (c), 45. (b), , 26. (c), 36. (d), 46. (b), , 27. (d), 37. (c), 47. (b), , 28. (c), 38. (d), 48. (a), , 29. (b), 39. (c), 49. (c), , 30. (b), 40. (b), 50. (a), , 51. (c), , 52. (b), , 53. (b), , 54. (b), , 55. (a), , G, , oy, , al, , 1. (a), 11. (b), , (b) 18, , Br, , , print(DF.size), , (a) 15, , ot, , he, , rs, , 55. What will be the output of the given command?, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 105
Page 113 :
MODEL TEST PAPER – 1, , SECTION : C, , (Based on the Latest CBSE Sample Paper), Maximum Marks : 35, , as, ha, n, , Time Allowed : 90 Minutes, , General Instructions :, • The paper is divided into 3 Sections- A, B and C., • Section A, consists of Question 1 to 25 and student need to attempt 20 questions., • Section B, consists of Question number 26 to 49 and student need to attempt 20 questions., • Section C, consists of Question number 50 to 55 and student need to attempt 5 questions., • All questions carry equal marks., , SECTION - A, , , , , 1. Python is a:, (a) Hardware , (c) Programming Language , , , , 2. Pandas is:, (a) open-source library, , , , , Pr, ak, , Section A consists of 25 questions, attempt any 20 questions., (b) Termware, (d) Package, , (c) free-source library, , (d) none of these, , 3. Select the correct statement to create empty series., (a) s=pd.Series(), (b) s=pd.series(), , (c) s=pd[‘Series’], , (d) s=pd.Series, , 4. Pandas Series is one dimensional, (a) Data Frame, (b) List, , (c) Labeled Array, , (d) Tuple, , rs, , (b) close-source library, , he, , 5. ___________method in Pandas can be used to change the index of rows and columns of a Series or Dataframe., , (a) rename(), (b) reindex(), (c) reframe(), (d) none of these, , , , , ot, , 6. Write a single line command to create a series by given list C and index values, , C=[‘red’,’green’,’blue’] , index values=[‘r’,’g’,’b’], (a) p=pd.Series(C,index=[‘r’,’g’,’b’]), (c) p=pd.Series(C]) , , 8. The command used to draw a bar graph is, (a) p1.bargraph(x,y), (b) p1.bar(x,y), , (c) plt.display(), , (d) plt.show(), , (c) p1.bgraph(x,y), , (d) p1.graphbar(x,y), , al, , , , Br, , 7. Which command is correct to display the plot?, , (a) plt.plot(), (b) plt.showplot(), , (b) p=pd.Series(list=C,index=[‘r’,’g’,’b’]), (d) p=pd.Series(values=C,index=[‘r’,’g’,’b’]), , 9. Method or function to add a new column in a data frame is:, , (a) loc(), (b) iloc(), (c) join(), , (d) add(), , oy, , 10. What is the minimum number of arguments required for savefig() function in matplotlib?, , (a) 1, (b) 2, (c) 3, (d) 4, , G, , , , 11. A ____________ is data that is left behind when users have been online., (a) Digital Handprint, (b) Digital Footprint, (c) Offline Footprint, , (d) Offline Handprint, , 12. Posting the your friend’s personal information on social media without taking permission from her is the, violation of, , (a) Copyright, (b) Net Etiquettes, (c) Plagiarism, (d) None of these, , 106, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 114 :
13. ‘F’ in ODF stands for:, , (a) Free, , (b) File, , (c) Fire, , (d) Format, , as, ha, n, , 14. Which of the following import statement is not correct?, , (a) import pandas as pd1 , (b) import pandas as pdii, , (c) import pandas as pd 3 , (d) import pandas as PD5, , 15. A research student is expected to write a thesis on a topic. The student browses Internet for the topic and luckily, finds it on the Internet. He copies and submits the entire thesis as his own research work. Which of the following, activities appropriately categorises the act of the writer?, , (a) Spamming, (b) Phishing, (c) Plagiarism, (d) Trojan, 16. Which of the following is not an intellectual property?, , (a) A poem written by a poet , (b) An original painting made by a painter, , (c) Trademark of a Company , (d) A remixed song, , Pr, ak, , 17. While adding new column in data frame, if length of new column is bigger than length of index, which type of, error it will raise?, , (a) Key Error, (b) Syntax Error, (c) Name Error, (d) Value Error, , 18. Downloading three images from web page and making a collage for his project using these images is an act of, ______________, , (a) Plagiarism , (b) Copyright infringement, , (c) Intellectual Property Right , (d) Digital Footprints, , , 19. Function to display the last n rows in the DataFrame:, (a) tail (n), (b) head (n), (c) top (n), , (d) last (n), , he, , rs, , 20. An organisation purchases new computers every year and dumps the old ones into the local dumping yard. Write, the name of the most appropriate category of waste that the organisation is creating every year, out of the following, options., , (a) Solid Waste, (b) Commercial Waste, (c) E-Waste, (d) Business Waste, , ot, , 21. Pratibha is an IT expert and a freelancer. She undertakes those jobs, which are related to setting up security, software/tools and managing networks in various companies. If we name her role in these companies, what it, will be out of the following?, , (a) Cracker, (b) Network Admin, (c) Hacker, (d) Operator, (c) dictionary, , (d) all of these, , 23. From a series P, print[P[-3:]) will display, , (a) last 3 records, (b) last 2 records, , (c) 1st 3 records, , (d) 3rd record from back, , Br, , 22. DataFrame can be created by using, , (a) list, (b) tuple, , al, , 24. Which function will be used to write data into CSV file from pandas data frame?, , (a) readcsv(), (b) to_csv(), (c) read_csv(), (d) csv_read(), , oy, , 25. Which of the following is not an attribute of pandas data frame?, , (a) add, (b) index, (c) size, , (d) shape, , SECTION - B, Section B consists of 24 Questions (26 to 49). Attempt any 20 questions., , G, , 26. What will be the output of the given code?, , , import pandas as pd, data ={‘a’:0,’b’:1.,’c’:2.}, s =pd.Series(data,index=[‘b’,’c’,’d’,’a’]), , print(s), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 107
Page 115 :
(a) b, c, d, a, , 0.0, (b) b, 1.0 c, 2.0 d, NaN a, , 1.0, (c) a, 2.0 b, NaN c, 0.0 d, , 0.0, (d) b 1.0, 1.0 c 2.0, 2.0 a 0.0, NaN, , , , as, ha, n, , 27. Assuming the given series, named stud, which command will be used to print 5 as output?, , 1 5, , 2 10, , 3 15, , 4 20, , 5 25, , (a) stud.index, (b) stud.length, (c) stud.values, (d) stud.size, , 28. Given a Pandas dataframe called “S”, the command which will display the last 5 rows is, (a) print(S.tail()), (b) print(S.Tail(5)), (c) print(S.tails(5)), (d) print(S.Tails(5)), , Pr, ak, , 29. Priyanka is using her internet connection to book a flight ticket. This is a classic example of leaving a trail of, web activities carried by her. What do we call this type of activity? What is the risk involved by such kind of, activity?, , (a) Digital Footprints, (b) Web Footprints, (c) Internet Footprints, (d) Net Footprints, 30. Observe the following figure., 7, 6, , rs, , 5, , he, , 4, 3, 2, , 1, , 2, , 3, , 4, , 5, , 6, , ot, , , Identify the coding for obtaining this as output., (a) import matplotlib.pyplot as plt, , Br, , (b) import matplotlib.pyplot as plt, plt.plot([1,2,3,4,5,6],[2,3,4,5,6,7]) plt.plot([1,2,3],[4,5,6]), plt.show() plt.show(), (c) import matplotlib.pyplot as plt, (d) import matplotlib.pyplot as plt, plt.plot([2,3,4,5],[1,2,3,4]) plt.plot([1:6],[2:7]), plt.show() plt.show(), , G, , oy, , al, , 31. Read the statements given below and identify the right option to draw a Line Graph., Statement A: To make a Line Graph with Matplotlib, we can use the plt.plot() function., Statement B: Two parameters are compulsory to create Line Graph., , (a) Both are correct , (b) Both are incorrect, , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, 32. The command used to draw a bar graph is _________., , (a) p1.bargraph(x,y), (b) p1.bar(x,y), (c) p1.bgraph(x,y), (d) p1.graphbar(x,y), 33. Which of the following is not a characteristic of Open Source Software?, , (a) Its source code is available for modification, (b) It is owned by a company or an individual, , (c) It can be downloaded from internet, (d) None of these, , 108, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 116 :
Pr, ak, , ot, , he, , rs, , 35. Consider the following series named Result., Rohan, 90, Aman, 60, Divya, 34, Jeet, 78, Raj, 25, Jyoti, 85, Gagan, 32, Write the output of the command:, print(Result[::-1]), , (a) Gagan, 32, , (b) Gagan, 32, Jyoti, 85, Raj, 25, Jeet, 78, Divya, 34, Aman, 60, Rohan, 90, , (c) Gagan, 32, Raj, 25, Divya, 34, Rohan, 90, , (d) No output, , as, ha, n, , 34. Consider the following statements with reference to the Net Etiquettes:, Statement 1: Should not use copyrighted materials without the permission of the creator or owner., Statement 2: Avoid any insulting, degrading or intimidating online behaviour like repeated posting of rumours., Statement 3: Posting inappropriate jokes on social media, Statement 4: Responding to or forwarding spam emails., , Which of the above statements refer to good Net Ettiquets?, , (a) Statements 1 and 2., (b) Statements 2 and 3. (c) Statements 3 and 4. (d) Statements 2 and 4., , al, , Br, , 36. Aman got a call from bank who was asking his aadhar card number for verification. What do you think he should, do?, , (a) ignore it and dont tell anything to them., , (b) reply back to them., , (c) shut down the phone and hope they’ll leave him alone in future., , (d) go to the cyber police and do register the complaint., , oy, , 37. What is a correct syntax to return the values of first row of a Pandas DataFrame?, , Assuming the name of the DataFrame is df., , (a) df[0], (b) df.loc[1], (c) df.loc[0], (d) df.iloc[1], , G, , 38. Feasible method (s) to manage e-waste:, , (a) Reduce, (b) Reuse, , (c) Recycle, , (d) All of these, , 39. Difference between drop() and del (choose the correct one), , (a) Both operates on columns and rows;, (b) del operates on column only., , (c) drop operates on column only., (d) del operates on rows only, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 109
Page 117 :
40. Write the output of the given program:, , , import pandas as pd, , , , print(S+2), , S=pd.Series([10,20,30,40],index=[‘a’,’b’,’c’,’d’]), , 12, (c) a+2, 22 b+2, 32 c+2, 42 d+2, int64 dtype:, , 10, (d) abcd, 102, 20 dtype: int64, 30, 40, int64, , as, ha, n, , , (a) a 12, (b) a+2, b, 22 b+2, c 32 c+2, d, 42 d+2, dtype: int64 dtype:, , 41. A software company purchases new computers every year and discards the old ones into the local dumping yard., Write the name of the most appropriate category of waste that the organisation is creating every year, out of the, following options:, , (a) Business Waste, (b) Commercial Waste, (c) Solid Waste, (d) E-Waste, , 43. Write the output of the given command:, import pandas as pd, , Pr, ak, , 42. Which command will be used to delete 4 and 6 rows of the data frame. Assuming the data frame name as DF., , (a) DF.drop([3,5],axis=0) , (b) DF.drop([3,5],axis=1), , (c) DF.drop([4,6],axis=1) , (d) DF.drop([4,6]), , s=pd.Series([10,20,30,40,50],[1,2,3,4,5]), print(s*s), , (a) 1, , 100, , (b) 1, , 100, , (c) 1, , 10, , rs, , , , 400 2, , 400 2, , 20, , 6, , 900 3, , 900 3, , 30, , 8, , 1600 4, , 1600 4, , 40, , 10, , 2500 5, , 2500 5, , 50, , he, , 4, , (d) Error, , Name, , Marks1, , Marks2, , 1, , Swapnil Sharma, , 30, , 50, , 2, , Raj Batra, , 75, , 45, , 3, , Bhoomi Singh, , 82, , 95, , 4, , Jay Gupta, , 90, , 95, , al, , Br, , Rollno, , ot, , 44. Zeenat has created the following data frame dataframe1 to keep track of data Rollno, Name, Marks1 and Marks2, for various students of her class where row indexes are taken as the default values:, , G, , oy, , , Now she wants to add a new column Marks3 with relevant data. Help her choose the command to perform this task., , (a) dataframe1.column=[ 45,52,90,95], , (b) dataframe1 [‘Marks3’]= [ 45,52,90,95], , (c) dataframe1.loc[‘Marks3’]= [ 45,52,90,95], , (d) Both (b) and (c) are correct, 45. Python software come under ____________ category., , (a) Proprietary, (b) FOSS, (c) Freeware, , 110, , (d) Shareware, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 118 :
47. Consider the following dataframe df, , name, marks, 1, Nidhi, 95, 2, Gurjeet, 97, 3, Pahul, 88, 4, Divya, 72, , Pr, ak, , as, ha, n, , 46. Consider the dataframe df, , empno, name, salary, A1, 101, a, 3000, A2, 102, b, 5000, A3, 103, c, 8000, A4, 104, d, 9000, , Choose the correct option to display the 1st record of employee from dataframe df, , (i) print(df.iloc[0]) , (ii) print(df.loc[‘A1’]), (iii) print(df.iloc[‘A1’]) , (iv) print(df.loc[0]), , (a) only (i) , (b) only (ii), , (c) (i) and (ii) , (d) (iii) and (iv), , , Choose the correct statement to change the index values 1 and 2 into ‘one’ and ‘two’, (a) df.rename({1:’one’,2:’two’},inplace=True), , , , (b) df.rename(row={1:’one’,2:’two’},inplace=True), , , , (c) df.rename(index={1:’one’,2:’two’},inplace=True), , , , (d) df.rename({1:’one’,2:’two’},axis=1,inplace=True), , rs, , , , ot, , he, , 48. Consider the following data frame name df, , roll, name, marks, , 0, 1, aman, 25, , 1, 2, bhavna, 55, , 2, 3, rahul, 60, command:, , G, , oy, , al, , Br, , , Write the output of the given, , print(df.marks/2), , (a) 0, 12.5, 1, 27.5, 2, 30.0, , (b) 0, 12, 1, 27, 2, 30, , (c) 12.5, 27.5, 30.0, , (d) roll, name, 0, 1 aman, 1, 2 bhavna, 2, 3 rahul, , marks, 12.5, 27.5, 30, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 111
Page 119 :
as, ha, n, , 49. Read the statements given below. Identify the right option from series and dataframe., Statement A: Python Pandas DataFrame is a heterogeneous two-dimensional object., Statement B : Python Pandas Series is a heterogeneous one-dimensional object., , (a) Both statements are correct., , (b) Both statements are incorrect., , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, , SECTION - C, , Section C consists of 6 Questions (50 to 55). Attempt any 5 questions., , Mr. Kapil is working with an IT company, and he has provided some data. On which he wants to do some operations,, but he is facing some problem, help him:, , Pr, ak, , Code:, import pandas as pd, , Data={‘Names’:[‘Sanya’,’Krish’,’Rishav’,’Deepak’,’Kriti’,], ‘Marks’: [95, 70, 96.5, 75,, 92],‘Trials’:[2, 3, 1, 2, 1], ‘Passed’: [‘yes’, ‘no’, ‘yes’, ‘no’, ‘yes’]}, df = pd.DataFrame(Data ), print(df), , Output of the above code:, , 1, , Krish, , 2, , Rishav, , 3, , Deepak, , 4, , Kriti, , Passed, , 95, , 2, , yes, , 30, , 3, , no, , 96.5, , 1, , yes, , 75, , 2, , no, , 92, , 1, , yes, , he, , Sanya, , Trials, , ot, , 0, , Marks, , rs, , Names, , Based on the given information, answer the questions NO. 50-55., , Br, , 50. The code should display the total number of rows in the Dataframe separately as follows:, , Number of Rows: 5, , (a) print(“Number of Rows: “, len(df.axes[0]), (b) print(“Number of Rows: “, count(df.axes[0]), , (c) print(“Number of Rows: “, length(df.axes[0]), (d) print(“Number of Rows: “, df.count.index), , oy, , al, , 51. He wants to change the ‘Marks’ in the 4th row (i.e. for index 3) to 91.5., , (a) df.iloc[3, ‘Marks’] = 91.5 , (b) df.change[3, ‘Marks’] = 91.5, , (c) df[3, ‘Marks’] = 91.5 , (d) df.loc[3, ‘Marks’] = 91.5, , G, , 52. He wants to display the rows where number of ‘Trials’ in the examination is less than 2 and ‘Marks’ is greater, than 95., , (a) print(df[(df[‘Trials’] < 2) && (df[‘Marks’] > 95)]), , (b) print(df[(df[‘Trials’] < 2) and (df[‘Marks’] > 95)]), , (c) print(df[(df[‘Trials’] < 2) & (df[‘Marks’] > 95)]), , (d) print(df[(df[‘Trials’] < 2) or (df[‘Marks’] > 95)]), , 112, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 120 :
53. He wants to display the information of all failed student., , (a) print(df[df.Passed= =’no’]) , (b) print(df.Passed= =’no’), , (c) print(df[df.Passed=’no’]) , (d) print(df.’Passed’= =’no’), , as, ha, n, , 54. By mistake he has marked ‘no’ in passed column of Deepak. He wants to change the passed information of, Deepak to ‘yes’, , (a) df.iloc[3, ‘Passed’] = ‘yes’ , (b) df.loc[3, ‘Passed’] = ‘yes’, , (c) df[3, ‘Passed’] = ‘yes’ , (d) df.loc[3, 3] = ‘yes’, 55. He wants to display the ‘Names’ and ‘Marks’ columns from the DataFrame., , (a) print(df[‘Names’, ‘Marks’]) , (b) print(df.columns=[‘Names’, ‘Marks’]), , (c) print(df[[‘Names’, ‘Marks’]]), (d) print(df.loc[‘Names’, ‘Marks’]), ANSWERS, 3. (a), 13. (d), , 4. (c), 14. (c), , 5. (b), 15. (c), , 21. (c), 31. (c), 41. (d), , 22. (d), 32. (b), 42. (a), , 23. (a), 33. (b), 43. (b), , 24. (b), 34. (a), 44. (b), , 25. (a), 35. (b), 45. (b), , 51. (d), , 52. (c), , 53. (a), , 54. (b), , 55. (c), , 6. (a), 16. (d), , 7. (d), 17. (d), , 8. (b), 18. (a), , 9. (a), 19. (a), , 10. (a), 20. (c), , 26. (b), 36. (d), 46. (c), , 27. (d), 37. (c), 47. (c), , 28. (a), 38. (d), 48. (a), , 29. (a), 39. (b), 49. (c), , 30. (a), 40. (a), 50. (a), , Pr, ak, , 2. (a), 12. (b), , G, , oy, , al, , Br, , ot, , he, , rs, , 1. (c), 11. (b), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 113
Page 121 :
MODEL TEST PAPER – 2, , (Based on the Latest CBSE Sample Paper), Maximum Marks : 35, , as, ha, n, , Time Allowed : 90 Minutes, , General Instructions :, • The paper is divided into 3 Sections- A, B and C., • Section A, consists of Question 1 to 25 and student need to attempt 20 questions., • Section B, consists of Question number 26 to 49 and student need to attempt 20 questions., • Section C, consists of Question number 50 to 55 and student need to attempt 5 questions., • All questions carry equal marks., , SECTION - A, , Pr, ak, , Section A consists of 25 questions, attempt any 20 questions., , , 1. Which of the following is module in python?, (a) pandas, (b) matplotlib, , , , , 2. Python Pandas is used for, (a) Graphic Designing , (c) Data Manipulation and Analysis, , , , 3. Series can be created by using, (a) List, (b) Tuple, , , , , 4. Series represents a, (a) Single column in memory , (c) Three columns in memory , , , , 5. Given a Pandas series called “S”, the command which will display the last 4 rows is __________________., (a) print(S.tail(4)), (b) print(S.Tail(4)), (c) print(S.tails(4)), (d) print(S.Tails(4)), , (c) numpy, , (d) All of these, , (b) Animaion, (d) All of these, , he, , rs, , (c) Numpy, , (d) All of these, , (b) Double columns in memory, (d) Multi columns in memory, , (c) Mutable,Mutable, , (d) Immutable,Immutable, , 7. The command used to draw a line graph is, , (a) plt.line(x,y), (b) plt.linegraph(x,y), , (c) plt. lineplot(x,y), , (d) plt. plot(x,y), , , , Br, , ot, , 6. Size and values of data of Series is, , (a) Mutable,Immutable, (b) Immutable,Mutable, , 8. Which command is correct to set upper left position of legend in line graph?, (a) pos=2, (b) position=2, (c) loc=2, , al, , 9. Method or function to add a new column in a data frame is:, , (a) iloc(), (b) insert(), (c) join(), , (d) location =2, (d) add(), , oy, , 10. What is the minimum number of arguments required for bar() function in matplotlib?, , (a) 1, (b) 2, (c) 3, (d) 4, , , 11. ________is made when information is collected from the user without the person knowing this is happening., (a) active footprint, (b) passive footprint, (c) pass footprint, (d) known footprint, (d) None of these, , 13. ‘O’ in ODF stands for:, , (a) Original, , (d) Operator, , G, , 12. Repeated posting of rumours online is the violation of, , (a) Copyright, (b) Cybercrime, (c) plagiarism, , 114, , (b) Open, , (c) Operating, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 122 :
14. Which of the following statement is correct to create series?, , (a) s=Series.pd, (b) s=Series(pd), (c) s=pd.Series(), , (d) pd.Series()=s, , 16. A website is a collection of ___________, , (a) Web Servers, (b) Web pages, , (c) Browsers, , as, ha, n, , 15. __________includes sending, posting, or sharing negative, harmful, false, or mean content about someone else., , (a) Cyberbullying., (b) Spamming, (c) Phishing, (d) Plagiarism, (d) Hyperlinks, , 17. If you are deleting a column in dataframe using drop() function but same column name in not there, which type, of error it will raise?, , (a) Key Error, (b) Syntax Error, (c) Name Error, (d) Value Error, 18. Which of the following is suggested while on social media?, , (a) Don’t save password on other computers/phone (b) Don’t share personal information, , (c) Don’t use abusing language., (d) All of these, (d) false, , Pr, ak, , 19. In a DataFrame, Axis= 0 represents the_____________ elements., , (a) row, (b) column, (c) true, , 20. Which of the following method can be used to change the name of column in dataframe?, , (a) colname, (b) newname, (c) rename, (d) reindex, , 21. Which of the following statement is correct to set the value True to ignore_index?, , (a) ignore.index:true, (b) ignore_index:True, (c) ignore_index=True, (d) ignore_index=true, , rs, , 22. Which of the following is incorrect statement to create DataFrame using list?, , (a) df=pd.DataFrame(data=[‘red’,’green’,’blue’,’yellow’]), , (b) df=pd.DataFrame(list=[‘red’,’green’,’blue’,’yellow’]), , (c) df=pd.DataFrame([‘red’,’green’,’blue’,’yellow’]), , (d) all of these, , he, , 23. Which of the following command is used to display all records having rollno>3?, , (a) print(df[df[‘Roll’]>3]) (b) print(df[‘Roll’]>3), (c) print(df.Roll>3]), (d) print(df(‘Roll’)>3), , ot, , 24. Which function will be used to write data into dataframe from CSV file?, , (a) readcsv(), (b) to_csv(), (c) read_csv(), , (d) csv_read(), , Br, , 25. Which of the following code will display the total number of rows?, , (a) print(len(stud.axes[0]) (b) print(stud.len(0)), (c) print(stud.len[axes=0]) (d) print(len(stud.axes[row]), , SECTION - B, , Section B consists of 24 Questions (26 to 49). Attempt any 20 questions., 26. What will be the output of the given code?, , al, , , import pandas as pd, s =pd.Series(5, index=[0,1,2,3]), print(s), , 5, (b) 0 1 2 3 5, (c) 0, 5 1, 5 2, 5 3, will be the output of the given code?, , G, , oy, , , (a) 0, 1, 2, 3, 27. What, , 0, (d) 00000, 5 11111, 10 22222, 15 33333, , , import pandas as pd, s=pd.Series([10,20,30,40,50],index =[‘a’,’b’,’c’,0,1]), , print(s.iloc[1]), , , , (a) 10, , (b) 20, , (c) 40, , (d) 50, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 115
Page 123 :
as, ha, n, , , , , , , 28. Write a single line command to calculate 10% from ‘sale’ column from dataframe df and assign to new column, ‘Commission’., (a) df.insert[‘Commission’]=df.sale*10/100, (b) df[‘Commission’]=df.sale*10/100, (c) df.loc[‘Commission’]=df.sale*10/100, (d) df[‘Commission’,axis=1]=df.sale*10/100, , 29. ___________refers to the proper manners and behaviour we need to exhibit while being online., , (a) Human Etiquets , (b) Net Etiquettes, , (c) Web Etiquets , (d) Online Etiquets, 30. Observe the following figure., SALES CHART, 90, , 70, 60, 50, 40, , Pr, ak, , Sales in lakhs, , 80, , sales 2018, sales 2019, , 30, 0.0, , 0.5, , 1.0, , , Identify the location of legend., , (a) loc=1, (b) loc=2, , 1.5, , 2.0, 2.5, months, , 3.0, , 4.0, , (d) loc=4, , rs, , (c) loc=3, , 3.5, , ot, , he, , 31. Read the statements given below and identify the right option while draw a Line Chart., Statement A: While making line chart, it is compulsory to give legend location., Statement B: If single list or array is provided to the plot() command, matplotlib assumes it is a sequence of y values., , (a) Both are correct , , (b) Both are incorrect, , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, , Br, , 32. The command used to draw a bar graph horizontally is _________., , (a) p1.barhor(x,y), (b) p1.hbar(x,y), (c) p1.barh(x,y), 33. Which of the following not a Open Source software?, , (a) Linux, (b) MS Windows, (c) MySql, , (d) p1.graphbarh(x,y), (d) Python, , oy, , al, , 34. Consider the following statements with reference to the plagiarism., , Which of the following is not considered as plagiarism?, , (a) The practice of taking someone else’s work or ideas and passing them off as one’s own, , (b) Copy data from internet, , (c) Credit the original author in an in-text citation and reference list., , (d) Using graphs, charts, figures, or images without reference of source, , G, , , , , , , , 35. Consider the following series named Result., Rohan, 90, Aman, 60, Divya, 34, Jeet, 78, Raj, 25, , 116, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 124 :
Pr, ak, , as, ha, n, , Jyoti, 85, Gagan, 32, Write the output of the command:, print(Result[::), , (a) Rohan, 90, Aman, 60, Divya, 34, Jeet, 78, Raj, 25, Jyoti, 85, Gagan, 32, , (b) Gagan, 32, Jyoti, 85, Raj, 25, Jeet, 78, Divya, 34, Aman, 60, Rohan, 90, , (c) No output, (d) Error, , he, , rs, , 36. Rajiv received a fake email from an unknown person who claimed that Rajiv won Lottery of `50 Lacs. They, asked Rajiv to provide his personal information for verification. What do you think he should do?, , (a) ignore it and dont give any response, , (b) reply back to them and share his personal information, , (c) delete the mail and hope they’ll leave him alone in future., , (d) go to the cyber police and do register the complaint., 37. What is a correct syntax to return the values of last row of a Pandas DataFrame? Assuming the name of the, DataFrame is df., , (a) df[-1], (b) df.loc[-1], (c) df.loc[0], (d) df.iloc[0], (b) FOSS, (d) Shareware, , Br, , ot, , 38. Python software come under_______ category., , (a) Proprietary , , (c) Freeware , , import pandas as pd, , oy, , , , al, , 39. Difference between drop() and del (choose the correct one), , (a) drop can operate on multiple items at a time; del operates only on one at a time., , (b) Both can operate on multiple items at a time., , (c) Both operates only on one at a time, , (d) delete can operate on multiple items at a time; drop operates only on one at a time., 40. Write the output of the given program:, S=pd.Series([10,20,30,40],index=[‘a’,’b’,’c’,’d’]), , , print(S-3), , G, , , (a) a, 7, b, 17, c, 27, d, 37, dtype: int64, , , (b) a-3, 7, b-3, 17, c-3, 27, d-3, 37, dtype: int64, , , (c) a-3, 10, b-3, 20, c-3, 30, d-3, 40, dtype: int64, , , (d) abcd, 97, dtype: int64, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 117
Page 125 :
41. A research student is expected to write a thesis on a topic. The student browses Internet for the topic and luckily, finds it on the Internet. He copies and submits the entire thesis as his own research work. Which of the following, activities appropriately categorises the act of the writer:, , (a) Spamming, (b) Phishing, (c) Plagiarism, (d) Trojan, , as, ha, n, , 42. Consider the following dataframe df, , month, , passengers, , 0, , 2010, , Jan, , 25, , 1, , 2010, , Mar, , 50, , 2, , 2012, , Jan, , 35, , 3, , 2010, , Dec, , 55, , 4, , 2012, , Dec, , 65, , Pr, ak, , year, , Choose the correct statement/method for the required output: (5,3), , (a) df.index, (b) df.shape(), (c) df.shape, 43. Write the output of the given command:, , , import pandas as pd, , , , print(s+s), , he, , al, , Br, , , (a) 1, 20, 2, 40, 3, 60, 4, 80, 5, 100, , (b) 2, 20, 4, 40, 6, 60, 8, 80, 10 100, , (c) 2, 10, 4, 20, 6, 30, 8, 40, 10 50, , (d) Error, , rs, , s=pd.Series([10,20,30,40,50],[1,2,3,4,5]), , ot, , , , (d) df.size, , G, , oy, , 44. Naman has created the following dataframe “Climate” to record the data about climatic conditions of four years., , 118, , Year, , MaxTemp, , MinTemp, , Rainfall, , 2017, , 32, , 20, , 123, , 2018, , 33, , 22, , 140, , 2019, , 35, , 21, , 135, , 2020, , 34, , 23, , 160, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 127 :
49. Read the statements given below. Identify the right option from the following for series and dataframe, , Statement A: Series is size immutable but value mutable., , , , , , (a), (b), (c), (d), , Both statements are correct., Both statements are incorrect., Statement A is correct, but Statement B is incorrect, Statement A is incorrect, but Statement B is correct, , SECTION - C, , as, ha, n, , Statement B: Dataframe is size and value mutable., , Section C consists of 6 Questions (50 to 55). Attempt any 5 questions., , Pr, ak, , Mr. Ankit is working in an University as data analyst. He uses Python Pandas and Matplotlib for the same. He got, a dataset of the students for the year 2010 and 2011. His management wants certain information from him, but he is, facing some problems. Help him by answering few questions given below., CODE, import pandas as pd, , df1 = pd.DataFrame({‘mark1’:[30,40,15,40],’mark2’:[20,45,30,70]});, , #values change, , df2 = pd.DataFrame({‘mark1’:[10,20,20,50],’mark2’:[15,25,30,30]});, print(df1), , mark2, 15 , 45 , 30 , 70 , , 0, 1, 2, 3, , df2, , rs, , 0, 1, 2, 3, , mark1, 10, 40, 15, 40, , df1, , mark1, 30, 20, 20, 50, , mark2, 20, 25, 30, 30, , he, , print(df2), , ot, , 50. He wants to add dataframes df1 and df2., (i) print(df1+df2)) , , (ii) print(df1.sum(df2)), , , , (iii) print(df1.append(df2)) , , (iv) print(df1.add(df2)), , , , (a) Only (i) is correct , , (b) Both (ii) and (iii) are correct, , , , (c) Both (iii) and (iv) are correct, , (d) Both (i) and (iv) are correct, , Br, , , , , , (i) print(df1-df2)) , , (ii) print(subtract(df1,df2)), , , , (iii) print(df2.minus(df1)) , , (iv) print(df1.subtract(df2)), , , , (a) Only (i) is correct , , (b) Only (iv) is correct, , , , (c) Both (ii) and (iii) are correct, , (d) Both (i) and (iv) are correct, , oy, , al, , 51. He wants to subtract df2 from df1., , 52. He wants to rename column mark1 as marks1in dataframe df1., (a) df1.rename({‘mark1’:’marks1’}, inplace=True), , , , (b) df1.rename(columns={‘mark1’:’marks1’}, inplace=True), , , , (c) df1.rename(columns{‘mark1’:’marks1’}, inplace=True), , , , (d) df1.rename(colnames={‘mark1’:’marks1’}, inplace=True), , G, , , , 120, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 128 :
(a) df1.rename(index = {0: “zero”, 1:”one”}, inplace = True), , , , (b) df1.rename(row = {0: “zero”, 1:”one”}, inplace = True), , , , (c) df1.rename(rows = {0: “zero”, 1:”one”}, inplace = True), , , , (d) df1.rename(index{0: “zero”, 1:”one”}, inplace = True), , as, ha, n, , 53. He wants to change index label of df1 from 0 to zero and from 1 to one., , 54. He wants to delete column mark2 from dataframe df1., , , (a) df1.drop(‘mark2’,axis=0,inplace=True), , , , (b) df1.del(‘mark2’,axis=1,inplace=True), , , , (c) del df[‘marks’,axis=1,inplace=True), , , , (d) df1.drop(‘mark2’,axis=1,inplace=True), , , , (a) df2[‘Total’]=df2.mark1+df2.mark2, , , , (b) df2.column[‘Total’]=df2[mark1+mark2], , , , (c) df2.add[‘Total’]=df2[mark1+mark2], , , , (d) df2.newcolumn[‘Total’]=df2[mark1+mark2], , Pr, ak, , 55. Add new column Total in dataframe df2 which is the sum of mark1 and mark2., , ANSWERS, 2. (c), 12. (b), , 3. (d), 13. (b), , 4. (a), 14. (c), , 5. (a), 15. (a), , 21. (c), 31. (d), 41. (c), , 22. (b), 32. (c), 42. (c), , 23. (a), 33. (b), 43. (a), , 24. (c), 34. (c), 44. (a), , 25. (a), 35. (a), 45. (a), , 51. (d), , 52. (b), , 53. (a), , 6. (b), 16. (b), , 7. (d), 17. (a), , 8. (c), 18. (d), , 9. (b), 19. (a), , 10. (b), 20. (c), , 26. (a), 36. (d), 46. (b), , 27. (b), 37. (b), 47. (c), , 28. (b), 38. (b), 48. (b), , 29. (b), 39. (a), 49. (a), , 30. (d), 40. (a), 50. (d), , he, , rs, , 1. (d), 11. (b), , 55. (a), , G, , oy, , al, , Br, , ot, , 54. (d), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 121
Page 129 :
MODEL TEST PAPER – 3, , (Based on the Latest CBSE Sample Paper), Maximum Marks : 35, , as, ha, n, , Time Allowed : 90 Minutes, , General Instructions :, • The paper is divided into 3 Sections- A, B and C., • Section A, consists of Question 1 to 25 and student need to attempt 20 questions., • Section B, consists of Question number 26 to 49 and student need to attempt 20 questions., • Section C, consists of Question number 50 to 55 and student need to attempt 5 questions., • All questions carry equal marks., , SECTION - A, 1. PANDAS stands for, , (a) Panel Data, , (b) Panel Chart, , 2. Python pandas was developed in:, , (a) 2007, (b) 2008, , Pr, ak, , Section A consists of 25 questions, attempt any 20 questions., , he, , 4. Select the correct statement, , (a) import panda as pd , , (c) import pd as pandas , , (d) Panel Discussion, , (c) 2009, , (d) 2010, , (c) s=pd[‘Series’], , (d) s=pd.Series, , rs, , 3. Select the correct statement to create empty series., , (a) s=pd.Series(), (b) s=pd.series(), , (c) Panel Light, , (b) import pandas as pd, (d) import pd as panda, , 5. Given a Pandas series called “S”, the command which will delete the 1st row(index value 0) __________________., , (a) S.delete(0), (b) S.drop(0), (c) S.pop(0), (d) S.del(0), (d) print(M1.sum(M2)), , 7. Which of the following is not a valid plotting function of pyplot?, , (a) bar(), (b) line(), (c) hist(), , (d) plot(), , , , Br, , ot, , 6. Select code to display the sum of Series M1 and Series M2., , (a) print (sum(M1,M2)) (b) print(M1+M2), (c) print(M1.add(M2)), , 8. In line graph loc=1 is used to set the legend position, (a) upper left, (b) upper right, (c) lower left, , al, , 9. Method or function to add a new row in a data frame is:, , (a) loc(), (b) iloc(), (c) join(), , (d) lower right, (d) add(), , oy, , 10. What is the minimum number of arguments required for hist() function in matplotlib?, , (a) 1, (b) 2, (c) 3, (d) 4, 11. _______footprint is created when you deliberately submit information., , (a) active footprint, (b) passive footprint, (c) pass footprint, , (d) known footprint, , G, , 12. Posting the your friend’s personal information on social media without taking permission from her is the violation of, , (a) Copyright, (b) Cybercrime, (c) Plagiarism, (d) None of these, 13. ‘D’ in ODF stands for:, , (a) Digital, , 122, , (b) Develop, , (c) Document, , (d) Dataframe, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 130 :
14. Which of the following del statement is correct?, , (a) del df[‘Name’], (b) df.del[‘Name’], , (c) del.df[‘Name’], , (d) del df.Name, , 15. Name the primary law in India dealing with cybercrime and electronic commerce., , (a) Crime law, (b) Cyber Law, (c) IT Act, (d) IT Law, , as, ha, n, , 16. The process of getting web pages, images and files from a web server to local computer is called, , (a) FTP, (b) Uploading, (c) Downloading, (d) Remote access, , 17. While creating dataframe if no of index values is not equal to no of rows, which type of error it will raise?, , (a) Key Error, (b) Syntax Error, (c) Name Error, (d) Value Error, , , , 18. Which of the following can be called as cyber-crime?, (a) Stealing someone’s harddisk, (b) Harassing somone over internet, (c) Download copyright free songs, (d) Sending emails to your friends, , Pr, ak, , 19. Write code to delete the row whose index value is A1 from dataframe df., , (a) df=df.drop(‘A1’) , (b) df=df.drop(index=‘A1’), , (c) df=df.drop(‘A1,axis=index’) , (d) df=df.del(‘A1’), , 20. Which of the following method can be used to change the name of index in dataframe?, , (a) rowname, (b) indexname, (c) rename, (d) reindex, 21. Which statement is incorrect to delete the rows 3 and 4 (index values 2,3) in dataframe df, , (a) df=df.drop([2,3],axis=0) , (b) df=df.drop(index=[2,3]), , (c) df=df.drop([2,3]) , (d) df=df.drop(2,3,axis=0), , rs, , he, , , , , , , 22. Which of the following statement is correct in order to create DataFrame using list, (a) df=pd.DataFrame([‘red’,’green’,’blue’,’yellow’],column=[‘Colour’]), (b) df=pd.DataFrame([‘red’,’green’,’blue’,’yellow’],columns=[‘Colour’]), (c) df=pd.DataFrame([‘red’,’green’,’blue’,’yellow’],colnames=[‘Colour’]), (d) df=pd.DataFrame([‘red’,’green’,’blue’,’yellow’],column[‘Colour’]), , Br, , ot, , 23. Which of the following command is used to add a new column ‘Grade’, with the values, ‘ A’, ‘B’, ‘A’, ‘B’, ‘A’, to the DataFrame?, , (a) df.column=[’A’,’B’,’A’,’B’,’A’], , (b) df [‘Grade’]=[’A’,’B’,’A’,’B’,’A’], , (c) df.insert(loc=3,column=’Grade’,value= [’A’,’B’,’A’,’B’,’A’]), , (d) Both (b) and (c) are correct, , al, , 24. CSV file can be opened in, , (a) notepad, (b) wordpad, , (c) excel, , (d) all of these, , SECTION - B, , Section B consists of 24 Questions (26 to 49). Attempt any 20 questions., 25. Dataframe stud is given below, , name, , marks, , S1, , 1, , Nidhi, , 87, , S2, , 2, , Jyoti, , 45, , S3, , 3, , Poonam, , 67, , S4, , 4, , Karambir, , 39, , S5, , 5, , Sangeeta, , 78, , G, , oy, , roll, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 123
Page 131 :
State the command that will give the output as:, , roll, name, S2, 2, Jyoti, S3, 3, Poonam, , (a) print(stud.iloc[1:2,1:2]) , , (c) print(stud.iloc[1:3,0:2]) , , as, ha, n, , (b) print(stud.iloc[2:3,0:2]), (d) print(stud.iloc[1:3,1:2]), , 26. What will be the output of the given code?, , , import pandas as pd, , name=[‘Raj’,’Ankur’,’Harsh’], , p=pd.Series(name,index=[2,5,6]), p1=p.reindex([2,5]), , , , print (p1), , , (a) 2, 5, 6, , Raj, (b) 2, Ankur 5, Harsh, , Raj, (c) 2, Ankur 5, , Raj, Harsh, , (d) 6, , Harsh, , Pr, ak, , , , 27. From the given series, which command will be used to print [ 5 10 15 20 25] as output?, s=pd.Series([5,10,15,20,25],index=[1,2,3,4,5]), , (a) s.index, (b) s.length, (c) s.values, (d) s.size, , rs, , 28. Write the single line command to delete the column “marks” from dataframe df using drop function., , (a) df=df.drop(col=‘marks’) , (b) df=df.drop(‘marks’,axis=col), , (c) df=df.drop(‘marks’,axis=0) , (d) df=df.drop(‘marks’,axis=1), , he, , 29. _____________is the crime of obtaining the personal or financial information of another person for the sole, purpose of assuming that person’s name or identity to make transactions or use it to post inappropriate remarks,, comments etc., , (a) Plagiarism, (b) Phishing, (c) Identity theft, (d) Cyberstalking, , ot, , 30. Observe the following figure., , RESULT, , 90, , Br, , 80, , marks, , 70, 60, 50, , oy, , al, , 40, 30, 20, A, , B, , C, , D, , E, , , Identify the coding for obtaining this as output., , G, , (a) import matplotlib.pyplot as plt, (b) import matplotlib.pyplot as plt, plt.plot([82,25,87,14],[‘A’,’B’,’C’,’D’]) plt.plot([82,25,87,14,90],[‘A’,’B’,’C’,’D’,E’]), plt.show() plt.show(), (c) import matplotlib.pyplot as plt, (d) import matplotlib.pyplot as plt, plt.plot([‘A’,’B’,’C’,’D’,’E’],[82,25,87,14,90]) plt.plot([A:E], [82,25,87,14,90]), plt.show() plt.show(), , 124, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 132 :
32. The command used to display the graph is _________, , (a) plt.show(), (b) plt.plot(), (c) plt.display(), , , 33. Which of the following is a Open Source software?, (a) Linux, (b) MS Windows, , (c) Photoshop, , as, ha, n, , 31. Read the statements given below and identify the right option while drawing a Line Chart., Statement A: While making line Chart, default value of legend loc is upper left., , Statement B: If x values is missing, matplotlib automatically generates the x values as the same length of y but, starts with 1., , (a) Both statements are correct, , (b) Both statements are incorrect, , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, (d) plt.disp(), , (d) MS office, , he, , rs, , the following series named Result., 90, 60, 34, 78, 25, 85, 32, , ot, , 35. Consider, Rohan, Aman, Divya, Jeet, Raj, Jyoti, Gagan, , Pr, ak, , 34. Consider the following statements with reference to e-waste:, , Statement 1: If you don’t need a thing, donate it so someone else can use., , Statement 2: Purchase new model of Gadgets even your old one working properly., , Statement 3: Discard your old gadgets which are not working properly., , Statement 4: Try to purchase new equipment those have buy back option., Which of the above refers to Managing e-Waste?, , (a) Statements 1 and 2. , (b) Statements 2 and 3., , (c) Statements 3 and 4. , (d) Statements 1 and 4., , Write the output of the command:, print(Result[:’Jeet’:2]), , Br, , , (a) Rohan, 90, (b) Aman 60, (c) Rohan, 90, (d) Rohan, 90, Divya, 34 Jeet 78 Divya, 34 Aman, 60, Jeet, 78 Divya, 34, Jeet, 78, , oy, , al, , 36. Rohit is a student of class 12th and he is a very frequent user of internet applications. One day he comes to, know that someone is using his email and sending unpleasant messages to other person on his behalf. What do, you think he should do?, , (a) ignore it and dont tell anything to anyone, , (b) stop using own emial id, , (c) talk to him and hope he will not do such kind of things in future, , (d) go to his parents, teacher, or other trusted adult and let them know that he feels uncomfortable, , G, , 37. What is a correct syntax to return the values of last two row of a Pandas DataFrame?, Assuming the name of the DataFrame is df., , (a) df[-1:] , (b) df.loc[-2], , (c) df.loc[:-2] , (d) df.iloc[-2:], Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 125
Page 133 :
38. Photoshop software come under_______ category., , (a) Proprietary , , (c) Freeware , , (b) FOSS, (d) Shareware, , 40. Given the following two series P1 and P2, P1, 10, , A, , 100, , B, , 20, , B, , 200, , C, , 30, , D, , 40, , E, , 50, , 300, , D, , 400, , E, , 500, , rs, , 110, (c) A, 220 B, 330 C, 440 D, 550 E, , 10+A, 20+B, 30+C, 40+D, 50+E, , 100, 200, 300, 400, 500, , (d) None of these, , 41. Which of the following is not an intellectual property?, (a) A poem written by a poet , (b) An original painting made by a painter, (c) Trademark of a Company, (d) Programe Developed by computer science student, , ot, , , , , , , 110, (b) A, 220 B, 330 C, 440 D, 550 E, , C, , he, , (a) 2A, 2B, 2C, 2D, 2E, , Pr, ak, , A, , , Give the output of following command., print(P1+P2), , P2, , as, ha, n, , 39. Difference between drop() and del (choose the correct one), , (a) both operates in-place or return a copy;, , (b) del can operate in-place or return a copy; drop is an in-place operation only, , (c) drop can operate in-place or return a copy; del is an in-place operation only, , (d) both operates in-place operation only, , Br, , 42. Consider the following dataframe df, , month, , passengers, , 0, , 2010, , Jan, , 25, , 1, , 2010, , Mar, , 50, , 2, , 2012, , Jan, , 35, , 3, , 2010, , Dec, , 55, , 4, , 2012, , Dec, , 65, , oy, , al, , year, , G, , , Choose the correct statement/method to print the details of “January” month along with the number of passengers., , 126, , 0, , month, Jan, , passengers, 25, , 2, , Jan, , 35, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 134 :
(a) df.loc[[‘Month’,’Passengers’]][df[‘Month’]==’Jan’], , , , (b) df[[‘Month’,’Passengers’]][df[‘Month’]==’Jan’], , , , (c) df.iloc[[‘Month’,’Passengers’]][df[‘Month’]==’Jan’], , , , (d) df([‘Month’,’Passengers’]][df[‘Month’]==’Jan’), , , , import pandas as pd, , , , print(s[::2]), , as, ha, n, , 43. Write the output of the given command:, s=pd.Series([10,20,30,40,50],[1,2,3,4,5]), , , (a) 3, 30, (b) 2, 20, (c) 1, 10, (d) 1, 3, 30 3, 5, , 10, 30, 50, , 44. HR Department of ABCTech has created following dataframe df to store data about salaries and bonus, EName, , Sal, , Bonus, , 0, , Kavita, , 50000, , 3000, , 1, , Sudha, , 60000, , 4000, , 2, , Garima, , 55000, , 5000, , Pr, ak, , paid to their employees:, , , , rs, , , Choose the python statement to display the columns Sal and Bonus, , (a) df1 [:Sal :Bonus] , (b) df1.loc([‘Sal’,’Bonus’]), , (c) df1.iloc([‘Sal’,’Bonus’]) , (d) df1[[‘Sal’,’Bonus’]], 45. MS Office software come under_______ category., , (a) Proprietary, (b) FOSS, , (c) Freeware, , (d) Shareware, , al, , Br, , ot, , he, , 46. Consider the dataframe df, , empno name salary, A1, 101, a, 3000, A2, 102, b, 5000, A3, 103, c, 8000, A4, 104, d, 9000, , Choose the correct option to display name and salary of all employees from dataframe df., , (a) print(df.loc[:,[‘name’,’salary’]]), , (b) print(df.loc[[‘name’,’salary’]]), , (c) print(df.iloc[:,[1,2]]) , , (d) all of the above, , oy, , 47. Consider the following dataframe df, , name, marks, 1, Nidhi, 95, 2 Gurjeet, 97, 3, Pahul, 88, 4, Divya, 72, , G, , Which command will give us the given output:, Output Required: (4,2), , (a) print(df.shape()) , , (c) print(df.dimension) , , (b) print(df.shape), (d) print(df.length), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 127
Page 135 :
print(df.marks*2), , , (a) 0, 1, 2, , (d) , 0, 1, 2, , 50, (b) 50, 110 110, 120 120, roll, name marks, 1, aman, 50, 2 bhavna, 110, 3, rahul, 120, , (c) (50,110,120), , as, ha, n, , 48. Consider the following data frame name df, , roll, name marks, 0, 1, aman, 25, 1, 2 bhavna, 55, 2, 3, rahul, 60, , Write the output of the given command:, , rs, , Pr, ak, , 49. Read the statements given below. Identify the right option from the following for graphs., , Statement A: Minimum two parameters are required for both plot() and bar() graph, , Statement B: The default position of legend is 1 (loc=1), , (a) Both statements are correct., , (b) Both statements are incorrect., , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, , SECTION - C, , he, , Section C consists of 6 Questions (50 to 55). Attempt any 5 questions., , Naman has created the following dataframe “Climate” to record the data about climatic conditions of four years., MaxTemp, , MinTemp, , Rainfall, , 2017, , 32, , 20, , 123, , 2018, , 33, , 22, , 140, , 2019, , 35, , 21, , 135, , 2020, , 34, , 23, , 160, , Br, , ot, , Year, , 50. Which of the following code snippets will return the MaxTemp and Rainfall for year 2018 and 2019?, (a) Climate[[‘MaxTemp’,’Rainfall’]][1:3], , (b) Climate[‘MaxTemp’, ‘Rainfall’][1:3], , , , (c) Climate.iloc[1:3] , , (d) Climate.iloc[1:3,1:2], , al, , , , oy, , 51. Display the temperature difference between MaxTemp and MinTemp for all the rows in the dataframe Climate., (a) Climate=Climate[“MaxTemp”]-Climate[“MinTemp”], (b) print(Climate[“maxt”]-Climate[“mint”]), (c) print(Climate[“MaxTemp”]-Climate[“MinTemp”]), (d) print(Climate.Climate[“MaxTemp”]-Climate[“MinTemp”]), , G, , , , , , , 52. To display 2 rows from the top in the dataframe, which of the following statement is correct?, , (a) print (Climate.head()=2 ) , (b) print (Climate.head(n==2) ), , (c) print (Climate.head(range(2)) ), (d) print (Climate.head(2) ), , 128, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 136 :
53. Which of the following statement/s will give the exact number of values in each column of the dataframe?, (A) print(Climate.count()) , , (B) print(Climate.count(0)), , , , (C) print(Climate.count) , , (D) print(Climate.count(axis=’index’)), , Choose the correct option:, , , , , (a) both (A) and (B) , (c) (A), (B) and (C) , , (b) only (B), (d) (A), (B) and (D), , as, ha, n, , , , 54. To display 2 rows from the bottom in the dataframe, which of the following statement is correct:, , (a) print (Climate.tail()=2 ) , (b) print (Climate.tail(n==2) ), , (c) print(Climate.tail(range(2))) , (d) print (Climate.tail(2) ), 55. Display the details of 2019 year., (a) Climate[2] , , (c) Climate.iloc[2] , , Pr, ak, , (b) Climate.loc[2], (d) Both (b) and (c), ANSWERS, , 2., 12., 22., 32., 42., 52., , (b), (b), (b), (a), (b), (d), , 3., 13., 23., 33., 43., 53., , (a), (c), (d), (a), (d), (d), , 4., 14., 24., 34., 44., 54., , (b), (a), (d), (d), (d), (d), , 5., 15., 25., 35., 45., 55., , (b), (c), (c), (c), (a), (d), , 6., 16., 26., 36., 46., , (b), (c), (b), (d), (d), , 7., 17., 27., 37., 47., , (b), (d), (c), (d), (b), , 8., 18., 28., 38., 48., , (b), (b), (d), (a), (a), , 9., 19., 29., 39., 49., , (a), (a), (c), (c), (b), , 10., 20., 30., 40., 50., , (a), (c), (c), (b), (a), , rs, , (a), (a), (d), (b), (d), (c), , G, , oy, , al, , Br, , ot, , he, , 1., 11., 21., 31., 41., 51., , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 129
Page 137 :
MODEL TEST PAPER – 4, , (Based on the Latest CBSE Sample Paper), Maximum Marks : 35, , as, ha, n, , Time Allowed : 90 Minutes, , General Instructions :, • The paper is divided into 3 Sections- A, B and C., • Section A, consists of Question 1 to 25 and student need to attempt 20 questions., • Section B, consists of Question number 26 to 49 and student need to attempt 20 questions., • Section C, consists of Question number 50 to 55 and student need to attempt 5 questions., • All questions carry equal marks., , SECTION - A, 1. Which of the following is module in python?, , (a) pandas, (b) dataFrame, , 3. Series can be created by using, , (a) Numpy , , (c) Scalar Value , s =pd.Series(data), , , index values of s is __________, , , , (d) All of these, , (c) 2018, , (d) None of these, , (b) Dictionary, (d) All of these, , 4. data ={‘a’:10.,’b’:11.,’c’:12.}, , he, , , , (c) series, , rs, , 2. Python pandas was developed in:, , (a) 1998, (b) 2008, , Pr, ak, , Section A consists of 25 questions, attempt any 20 questions., , (a) 0,1,2, , (b) 10,11,12, , (c) a,b,c, , (d) 10a,11b,12c, , ot, , 5. Given a Pandas series called Sequences, the command which will display the first 4 rows is _________., , (a) print(Sequences.head(4)) , (b) print(Sequences.Head(4)), , (c) print(Sequences.heads(4) , (d) print(Sequences.Heads(4)), , Br, , 6. Select code to show rows where values of series M1 greater than 75., , (a) print(M1>75) , (b) (print(M1[M1>75]), , (c) print(M1>’75’) , (d) print(M1(M1>75)), , al, , 7. The command used to draw a line graph is, , (a) line(), (b) chart(), , (c) linechart(), , (d) plot(), (d) lower right, , 9. Method or function to add a new row in a data frame is:, , (a) append(), (b) iloc(), (c) join(), , (d) add(), , oy, , 8. In line graph loc=2 is used to set the legend position., , (a) upper left, (b) upper right, (c) lower left, , G, , 10. What is the minimum number of arguments required for legend() function in matplotlib?, , (a) 0, (b) 1, (c) 2, (d) 3, 11. Download images from internet and paste in your project is the violation of ________________., , (a) net etiquettes, (b) plagiarism, (c) copyright, (d) none of these, , 130, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 138 :
12. _______ is a term used to describe the legal issues related to use of communications technology, particularly, “cyberspace”, i.e. the Internet., , (a) Cyber law, (b) Net law, (c) Online law, (d) Network law, (b) Open, , (c) Operating, , 14. Which of the following plot statement is not correct?, , (a) p.plot(x,y), (b) p.plot(y,x), (c) p.plot(y), , , 15. Hackers are known as, (a) White hats, , (b) Black hats, , (c) Red hats, , 16. BOSS is open source ____________, , (a) Operating System, (b) Browser, , (c) Software, , (d) Operator, , as, ha, n, , 13. ‘O’ in OSS stands for:, , (a) Original, , (d) p.plot(), , (d) Blue hats, , (d) None of these, , Pr, ak, , 17. This shape attribute returns the number of rows and number of columns available in dataframe in form of, , (a) tuple, (b) list, (c) dictionary, (d) string, , 18. A __________ is a type of intellectual property that gives its owner the legal right to exclude others from making,, using, or selling an invention for a limited period of years., , (a) Trademark, (b) Patent, (c) Copyright holder, (d) Plagiarism, 19. Write code to delete rows those getting 5000 salary., , (a) df=df.drop[salary==5000] , (b) df=df[df.salary!=5000], , (c) df.drop[df.salary==5000,axis=0], (d) df=df.drop[salary!=5000], , rs, , 20. Which of the following attribute can be used to change the name of column in dataframe?, , (a) colname, (b) newname, (c) column, (d) reindex, , he, , 21. How to set value of axis to 1 while renaming any column name?, , (a) axis:1, (b) axis(1), (c) axis=1, , (d) axis[1], , ot, , 22. If Dictionary keys name is not same the dataframe columns name then it will display ____ values in dataframe, column., , (a) 0, (b) NaN, (c) blank, (d) error message, , Br, , 23. Which of the following command is used to delete the column “Name”?, , (a) del df[“Name”] , (b) df=df.drop(‘name’,axis=1), , (c) df=df.drop(‘name’,axis=0) , (d) Both (a) and (b) are correct, 24. When Saving csv to any other directory the _____ character should be placed before the path name., , (a) c, (b) s, (c) v, (d) r, , oy, , al, , 25. Which of the following is used to add new row with following data with index value ‘S6’:, , 6,’Divya’,92, , (a) stud[‘S6’]=[6,’Divya’,92] , (b) stud.iloc[‘S6’]=[6,’Divya’,92], , (c) stud..row[‘S6’]=[6,’Divya’,92], (d) stud.loc[‘S6’]=[6,’Divya’,92], , SECTION - B, Section B consists of 24 Questions (26 to 49). Attempt any 20 questions., , G, , 26. What will be the output of the given code?, , , , import pandas as pd, , name=[‘Raj’,’Ankur’,’Harsh’], , p=pd.Series(name,index=[2,5,6]), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 131
Page 139 :
p1=p.reindex([2,4,5]), print (p1), , , (a) 2, Raj, (b) 2, 5 Ankur 4, 6, Harsh 5, 6, , Raj, (c) 2, NaN 4, Ankur 5, Harsh, , Raj, (d) 2, NaN 4, Ankur 5, , Raj, Ankur, Harsh, , as, ha, n, , , , , 27. Which attribute is used to returns the data type of the underlying data for the given Series object?, , (a) s.dtype, (b) s.type, (c) s.datatype, (d) s.size, , , , , , , 28. Which one is incorrect option to add a new column using insert() in the last place(3rd place) named “Salary”, from the list Sal=[10000,15000,20000] in an existing dataframe named EMP already having 2 columns?, (a) EMP.insert(loc=2,column=”Salary”,value=Sal), (b) EMP.insert(2,”Salary”,Sal), (c) EMP.insert(loc=2,column=”Salary”,value=[10000,15000,20000]), (d) EMP.insert(loc=2,col=”Salary”,value=Sal), , Pr, ak, , 29. Alex likes to do his homework late at night. He uses the Internet a lot and also sends useful data through email, to many of his friends. One Day he forgot to sign out from his email account. In the morning, his twin brother,, Flex started using the computer. He used Flex’s email account to send inappropriate messages to his contacts., Such type of activity is called ________________?, , (a) Plagiarism, (b) Phishing, (c) Identity theft, (d) Cyberstalking, 30. Observe the following figure., , RESULT, , rs, , 90, 80, , 60, , he, , marks, , 70, , 50, 40, 30, , ot, , 20, , A, , B, , Br, , , Identify the statement for writing ‘RESULT’., , (a) p1.head(“RESULT”) , , (c) p1.top(“RESULT”) , , C, , D, , E, , (b) p1.heading(“RESULT”), (d) p1.title(“RESULT”), , oy, , al, , 31. Read the statements given below and identify the right option while draw a Line Chart., , Statement A: While making line chart, legend can be placed at any location., , Statement B: It is complusory to provide xlabel and ylabel values., , (a) Statement A, B both are correct, , (b) Statement A, B both are incorrect, , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, , G, , 32. The command used to set the label of x axis is _________, , (a) plt.xaxis(), (b) plt.labelx(), (c) plt.xtitle(), , (d) plt.xlabel(), , 33. Poonam is confused about the free operating system available in the market. Few of her friends suggested a few, operating systems. Help her in choosing free operating system for her device., , (a) Linux, (b) Opera, (c) Mozilla Firefox, (d) Google Chrome, , 132, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 140 :
as, ha, n, , 34. Consider the following statements with reference to cyber crime:, , (i) Stealing brand new hard disk from a shop., , (ii) Getting into unknown person’s social networking account and start messaging on his behalf., , (iii) Copying some important data from a computer without taking permission from the owner of the data., , (iv) Looking at online activities of a friends blog., , 35. Consider the, Rohan, Aman, Divya, Jeet, Raj, Jyoti, Gagan, , following series named Result., 90, 60, 34, 78, 25, 85, 32, , Write the output of the command:, print(Result[-1:-5:-1]), , (d) Statements 2 and 4., , Pr, ak, , Which out of the following comes under Cyber Crime?, , (a) Statements 1 and 2., (b) Statements 2 and 3. (c) Statements 3 and 4., , rs, , , (a) No output, (b) Gagan, 32, (c) Aman, 60, (d) Gagan, Jyoti, 85 Divya, 34 Jyoti, Raj, 25 Jeet, 78 Raj, Jeet, 78 Raj, 25 Jeet, , Divya, , 32, 85, 25, 78, 34, , ot, , he, , 36. The school offers Wi-Fi to the students of Class XII, emails were received by all the students regarding expiry, of their passwords. Instructions were also given renew their password within 24 hours by clicking on particular, URL provided. What do you think they should do?, , (a) ignore it and dont tell anything to anyone, , (b) stop using their emial id, , (c) click on link for renew their password, , (d) talk to their parents, teacher, or other trusted adult and let them know about the situation, , al, , Br, , 37. From the following dataframe df, calculate the sum of sal and bonue of 1st row (index value 0) using iloc, , EName, Sal, Bonus, 0 Kavita, 50000, 3000, 1 Sudha, 60000, 4000, 2 Garima, 55000, 5000, , (a) print(df.iloc[0,1]+df.iloc[0,2]), (b) print(df.iloc[1,0]+df.iloc[0,2]), , (c) print(df.iloc[0,1]+df.iloc[1,2]), (d) print(df.iloc[0,1]+df.iloc[0,1]), , oy, , 38. MS Office software come under_______ category., , (a) Proprietary, (b) FOSS, , (c) Freeware, , (d) Shareware, , G, , 39. Choose the correct one about Series and DataFrame, , (a) Both are one dimensional , , (b) Both are two dimensional, , (c) Series is one dimensional whereas a DataFrame is two dimensional., , (d) Data Frame is one dimensional whereas a Series is two dimensional., Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 133
Page 141 :
40. Given the following two series P1 and P2, A, B, C, D, E, , P2, A, B, C, D, E, , 10, 20, 30, 40, 50, , 100, 200, 300, 400, 500, , Give the output of following command., , print(P1-P2), (a) A, , 90, , (b) A, , -90, , as, ha, n, , P1, , (c) A, , 10-A, , 100, , (d) -90, , 180 B, , -180 B, , 20-B, , 200 -180, , C, , 270 C, , -270 C, , 30-C, , 300 -270, , D, , 360 D, , -360 D, , 40-D, , 400 -360, , E, , 450 E, , -450 E, , 50-E, , 500 -450, , Pr, ak, , B, , 41. Open Office software come under_______ category., , (a) Proprietary , , (c) Freeware , 42. Consider the following dataframe df, , month, , passengers, , Jan, , 25, , Mar, , 50, , 2012, , Jan, , 35, , 2010, , Dec, , 55, , 2012, , Dec, , 65, , 2010, , 1, , 2010, , he, , 0, , 2, , ot, , 3, 4, , rs, , year, , (b) FOSS, (d) Shareware, , Br, , Choose the correct statement/method to change the index of the Data Frame and the output for the same is given, below., month, , passengers, , AirIndia, , 2010, , Jan, , 25, , Indigo, , 2010, , Mar, , 50, , Spicejet, , 2012, , Jan, , 35, , Jet, , 2010, , Dec, , 55, , Emirates, , 2012, , Dec, , 65, , oy, , al, , year, , (a) df.index[]=[“Air India”,”Indigo”,”Spicejet”,”Jet”,”Emirates”], , , , (b) df.index[“Air India”,”Indigo”,”Spicejet”,”Jet”,”Emirates”], , , , (c) df.index=[“Air India”,”Indigo”,”Spicejet”,”Jet”,”Emirates”], , , , (d) df.index()=[“Air India”,”Indigo”,”Spicejet”,”Jet”,”Emirates”], , G, , , , 134, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 142 :
43. Write the output of the given command:, , , import pandas as pd, , , , print(s[:2]), , s=pd.Series([10,20,30,40,50],[1,2,3,4,5]), , 44. Consider the following dataframe Climate, Year, , MaxTemp, , MinTemp, , 2017, , 32, , 20, , 2018, , 33, , 22, , 2019, , 35, , 21, , 2020, , 34, , 23, , 10, 20, 30, , as, ha, n, , , (a) 1, 10, (b) 2, 20, (c) 1, 10, (d) 1, 2, 20 2, 3, Rainfall, 123, 140, , Pr, ak, , 135, 160, , , To display 2 rows from the top in the dataframe, which of the following statement is correct?, , (a) print (Climate.head()=2 ) , (b) print (Climate.head(n==2) ), , (c) print (Climate.head(range(2)) ), (d) print (Climate.head(2) ), , rs, , 45. A student is expected to write a research paper on a topic. The student had a friend who took a similar class five, years ago. The student asks his older friend for a copy of his paper and then takes the paper and then submits, the entire paper as his own research work., , Which of the following activities appropriately categorises the act of the writer:, , (a) Plagiarism, (b) Spamming, (c) Virus, (d) Phishing, , al, , Br, , ot, , he, , 46. Consider the dataframe df, , empno name salary, A1, 101, a, 3000, A2, 102, b, 5000, A3, 103, c, 8000, A4, 104, d, 9000, , Choose the correct option to display name and salary of A1 and A2 from dataframe df., , (i) print(df.loc[[‘A1’,’A2’],[‘name’,’salary’]]), , (ii) print(df.loc[‘A1’:’A2’,[‘name’,’salary’]]), , (iii) print(df[[‘A1’,’A2’],[‘name’,’salary’]]), , (iv) print(df.iloc[[0,1],[‘name’,’salary’]]), , (a) (i) and (iii), (b) (i) and (ii), (c) (iii) and (iv), (d) (i) and (iv), 47. Consider the dataframe “EMP”, Basic, , E1, , Sanya, , 9500, , 3000, , 2000, , E2, , Krish, , 7000, , 5000, , 1900, , E3, , Rishav, , 9650, , 1500, , 2100, , E4, , Deepak, , 7500, , 2000, , 2700, , E5, , Kriti, , 9200, , 1800, , 500, , G, , oy, , Name, , Da, , Hra, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 135
Page 143 :
48. Consider the following data frame name df, , roll, name, marks, 0, 1, aman, 25.0, 1, 2, bhavna NaN, 2, 3, rahul, 60.0, Write the output of the given command:, print(df.size), , , , (a) 6, , (b) 7, , (c) 8, , as, ha, n, , , Choose command to Change the Da of Krish to 8000, , (i) EMP.iloc[1,2]=8000 , (ii) EMP.iloc[‘E2’,’Da’]=8000, (iii) EMP.loc[1,2]=8000 , (iv) EMP.loc[‘E2’,’Da’]=8000, , (a) only i, (b) i and ii, (c) iii and iv, (d) i and iv, , (d) 9, , Pr, ak, , 49. Read the statements given below. Identify the right option from the following for insert function in dataframe., Statement A: insert() can be used to add new column at any position in dataframe., Statement B: pos is a parameter of insert() to set the location of new column., , (a) Both statements are correct., , (b) Both statements are incorrect., , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, , rs, , SECTION - C, , Section C consists of 6 Questions (50 to 55). Attempt any 5 questions., , Name, a, b, c, d, e, , marks, 87, 45, 67, 39, 78, , ot, , Roll, 1, 2, 3, 4, 5, , Br, , 0, 1, 2, 3, 4, , he, , Mr. Karambir is working as Examinor In-Charge in school, and he has provided some data. On which he wants to do, some operations, but he is facing some problem, help him:, , 50. Which of the following command is used to display all records having rollno>3?, , (a) print(df[df[‘Roll’]>3]) , (b) print(df[‘Roll’]>3), , (c) print(df.Roll>3]) , (d) print(df(‘Roll’)>3), , G, , oy, , al, , 51. Which of the following command is used to add a new column ‘Grade’, with the values, ‘ A’, ‘B’, ‘A’, ‘B’, ‘A’, to the DataFrame?, , (a) df.column=[’A’,’B’,’A’,’B’,’A’], , (b) df [‘Grade’]=[’A’,’B’,’A’,’B’,’A’], , (c) df.insert(loc=3,column=’Grade’,value= [’A’,’B’,’A’,’B’,’A’]), , (d) Both (b) and (c) are correct, , , , , , 52. Which of the following command is used to delete the column “Name”?, (a) del df[“Name”] , (b) df=df.drop(‘name’,axis=1), (c) df=df.drop(‘name’,axis=0) , (d) Both (a) and (b) are correct, , 136, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 144 :
54. He wants to add new rows with data [6,’f’,90]., , (a) df.iloc[5]=[6,’f’,90] , , (c) df[5]=[6,’f’,90] , , (b) df[5]={6,’f’,90}, (d) df.loc[5]=[6,’f’,90], , 55. Give the output, print(len(df.axes[0])), , , , (a) 4, , (b) 5, , (c) 6, , (d) 7, , 3. (d), 13. (b), , 4. (c), 14. (d), , 5. (a), 15. (a), , 21. (c), 31. (b), 41. (b), , 22. (b), 32. (d), 42. (c), , 23. (d), 33. (a), 43. (a), , 24. (d), 34. (b), 44. (d), , 25. (d), 35. (b), 45. (a), , 51. (d), , 52. (d), , 53. (a), , 54. (d), , 55. (b), , 6. (b), 16. (a), , 7. (d), 17. (a), , 8. (a), 18. (b), , 9. (a), 19. (b), , 10. (a), 20. (c), , 26. (c), 36. (d), 46. (b), , 27. (a), 37. (a), 47. (c), , 28. (d), 38. (a), 48. (d), , 29. (c), 39. (c), 49. (c), , 30. (d), 40. (b), 50. (a), , G, , oy, , al, , Br, , ot, , he, , rs, , 2. (b), 12. (a), , Pr, ak, , ANSWERS, 1. (a), 11. (b), , as, ha, n, , 53. Which of the following command is used to rename the column “Marks” to “Tmarks” in the existing dataframe df?, , (a) df.rename(columns={‘Marks’: ‘TMarks’},inplace=True), , (b) df.rename(columns={‘Marks’: ‘TMarks’}), , (c) df.rename({“Marks”:”TMarks”},axis=0), , (d) both (a) and (c) are correct, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 137
Page 145 :
MODEL TEST PAPER – 5, , (Based on the Latest CBSE Sample Paper), Maximum Marks : 35, , as, ha, n, , Time Allowed : 90 Minutes, , General Instructions :, • The paper is divided into 3 Sections- A, B and C., • Section A, consists of Question 1 to 25 and student need to attempt 20 questions., • Section B, consists of Question number 26 to 49 and student need to attempt 20 questions., • Section C, consists of Question number 50 to 55 and student need to attempt 5 questions., • All questions carry equal marks., , SECTION - A, 1. Which of the following is module in python?, , (a) pandas, (b) bar, , , , 2. Python Pandas is used for:, (a) Data Gathering , (c) Data Manipulation and Analysis, , Pr, ak, , Section A consists of 25 questions, attempt any 20 questions., (c) line, , (d) All of these, , (b) Data Storage, (d) All of these, (c) dtype, , rs, , 3. Which is not the part of parameter of Series()?, , (a) index, (b) columns, , he, , 4. Pandas Series is a ________________:, , (a) one-dimensional labeled array, , (c) three-dimensional labeled array, , (d) none of these, , (b) two-dimensional labeled array, (d) multi-dimensional labeled array, , ot, , 5. Command to create empty Series is ________________., , (a) s=pd.emptySeries() , (b) s=pd.Series(empty), , (c) s=pd.Series() , (d) s=pd.Series(NaN), , Br, , 6. Set the series name “Marks1” of M1 series., , (a) M1.seriesname=”Marks1” , , (c) M1.newname=”Marks1” , , (b) M1.name=”Marks1”, (d) M1.setname=”Marks1”, (d) Yellow, , 8. In line graph loc=3 is used to set the legend position _____________., , (a) upper left, (b) upper right, (c) lower left, , (d) lower right, , al, , 7. By default color of one line graph is _____________., , (a) Red, (b) Green, (c) Blue, , oy, , 9. This attribute is used to fetch the index’s names from dataframe:, , (a) indexname , (b) index.name, , (c) index , (d) name.index, , G, , 10. What is the default loc value of legend() function?, , (a) 0, (b) 1, , (c) 2, , (d) 3, , 11. Download music from internet and use it in your youtube video is the violation of ___________., , (a) net etiquettes , (b) plagiarism, , (c) copyright , (d) None of these, , 138, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 146 :
13. First ‘S’ in OSS stands for:, , (a) Simple, (b) Signature, , (c) Source, , as, ha, n, , 12. Which of the following crime(s) is/are covered under cybercrime?, , (i) Stealing brand new hard disk from a shop., , (ii) Getting into unknown person’s social networking account and start messaging on his behalf., , (iii) Copying some important data from a computer without taking permission from the owner of the data., , (iv) Working on someone’s computer with his/her permission., , (a) only (ii), (b) (ii) and (iv), (c) (ii) and (iii), (d) (iii) and (iv), (d) Software, , 14. Which of the following statement is not correct to create series?, , (a) s=pd.Series(data=[10,20,30],index=[‘a’,’b’,’c’]), (b) s=pd.Series([10,20,30],index=[‘a’,’b’,’c’]), , (c) s=pd.Series([10,20,30],[‘a’,’b’,’c’]), (d) s=pd.Series(data=[10,20,30],[‘a’,’b’,’c’]), , Pr, ak, , 15. They are the programmers or computer experts with adequate knowledge of programming and coding who find, the loopholes present in a system and try to cover them and hence protect the system., , (a) Hackers, (b) Crackers, (c) Operators, (d) Admin, 16. The open source indian operating system is _________, , (a) Linux, (b) Android, (c) BOSS, , (d) Ubuntu, , 17. Empty attribute in dataframe gives _______ output in the form of true or false., , (a) tuple, (b) string, (c) boolean, (d) list, , rs, , 18. A _______ is a type of intellectual property consisting of a symbol, word, or words legally registered or established, by use as representing a company or product., , (a) Trademark , (b) Patent, , (c) Copyright holder , (d) Plagiarism, , ot, , he, , 19. Write the command to display Pid,Price from an existing dataframe named PRODUCT having 4 columns =[Pid,, Pname,Price,Qty]?, , (a) print (PRODUCT[[‘Pid’,’Price’]]), (b) print (PRODUCT[col=[‘Pid’,’Price’]]), , (c) print (PRODUCT[‘Pid’,’Price’]), (d) print (PRODUCT[‘Pid’,’Price’],axis=1), 20. Which of the following attribute can be used to change the name of index values in dataframe?, , (a) indexname, (b) newindex, (c) index, (d) reindex, , Br, , 21. Select correct option to show name of all rows in dataframe df., , (a) print(df.axes=0) , (b) print(df(axes=0)), , (c) print(df.axes[0]) , (d) print(df[axes=0]), , al, , 22. Which of the following is not the attribute of dataframe?, , (a) rows, (b) columns, (c) axes, , (d) dtype, , oy, , 23. Which of the following command is used to rename the column “Marks” to “Tmarks” in the existing dataframe df?, , (a) df.rename(columns={‘Marks’: ‘TMarks’},inplace=True), , (b) df.rename(columns={‘Marks’: ‘TMarks’}), , (c) df.rename({“Marks”:”TMarks”},axis=0), , (d) both (a) and (c) are correct, , G, , 24. Choose the correct statement delete the column name from datafram df using drop function, changes should take, effect in existing dataframe., , (a) df.drop(‘name’,0,inplace=True), (b) df.drop(‘name’,1), , (c) df.drop(‘name’,axis=0,inplace=True), (d) df.drop(‘name’,1,inplace=True), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 139
Page 147 :
as, ha, n, , 25. Choose the correct option to add new column Gender at position 2 (index value 1) to dataframe stud with values, [‘F’,’F’,’F’,’M’,’F’], , (A) stud.insert(1,’Gender’,[‘F’,’F’,’F’,’M’,’F’]), , (B) stud.insert(loc=1,column=’Gender’,value=[‘F’,’F’,’F’,’M’,’F’]), , (C) stud.insert(loc=1,field=’Gender’,values=[‘F’,’F’,’F’,’M’,’F’]), , (D) stud.insert(loc=1,column=’Gender’,values=[‘F’,’F’,’F’,’M’,’F’]), , (a) Only A is correct , (b) A and B are correct, , (c) B and C are corect , (d) A and D are correct, , SECTION - B, , Section B consists of 24 Questions (26 to 49). Attempt any 20 questions., , Pr, ak, , 26. Which command is correct to change the index value in series S?, , (a) S.reindex = [1, 2, 3, 4, 5] , (b) S.newindex = [1, 2, 3, 4, 5], , (c) S[index]= [1, 2, 3, 4, 5] , (d) S.index = [1, 2, 3, 4, 5], , rs, , 27. Which option is not correct to get the following output from the given series s?, , s=pd.Series([10,20,30,40,50]), output, 0, 10, 1, 20, 2, 30, , (a) print(s.iloc[0:3]) , (b) print(s.loc[0:3]), , (c) print(s[0:3]) , (d) print(s.head(3)), , 28. Write a small python code to drop a column “address” from dataframe stud using del., (a) del stud[col=“address”] , (c) del stud[“address”,axis=1] , , he, , , , , (b) del stud[column=“address”], (d) del stud[“address”], , ot, , 29. __________ is any identifier which is guaranteed to be unique among all objects and is used for identifying, various objects., , (a) Primary identifier , (b) Personal identifier, , (c) Private identifier , (d) Unique identifier, , Br, , 30. Observe the following figure., , RESULT, , 90, , G, , marks, , oy, , al, , 80, 70, 60, 50, 40, 30, 20, , A, , B, , , Identify the statement for writing ‘names’ in figure., , (a) p1.xlabel(“names”), (b) p1.labelx(“names”), , 140, , C, , D, , (c) p1.xhead(“names”), , E, , (d) p1.xtitle(“names”), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 148 :
32. The command used to set the label of y axis is _________, , (a) plt.yaxis(), (b) plt.labely(), (c) plt.ytitle(), , as, ha, n, , 31. Read the statements given below and identify the right option while draw a Line Chart., Statement A: In x axis, data must be in sorted manner (ascending or descending order), Statement B: In y axis, values must be of integer data type only, , (a) Statement A, B both are correct, , (b) Statement A, B both are incorrect, , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, , (d) plt.ylabel(), , 33. Sangeeta is confused about the open source web browser. Help her in choosing open source web browser for her, device., , (a) Linux, (b) Ubuntu, (c) MS Office, (d) Google Chrome, , 34. Consider the following statements with reference to cyber crime:, (i) Stealing away a brand new computer from a showroom., (ii) Getting in someone’s social networking account without his consent and posting pictures on his behalf to, harass him., (iii) Secretly copying files from server of a call centre and selling it to the other organisation., (iv) Viewing sites on a internet browser., , Pr, ak, , , , he, , the following series named Result., 90, 60, 34, 78, 25, 85, 32, , ot, , 35. Consider, Rohan, Aman, Divya, Jeet, Raj, Jyoti, Gagan, , rs, , Which out of the following comes under Cyber Crime?, , (a) Statements (i) and (ii). , (b) Statements (ii) and (iii)., , (c) Statements (iii) and (iv). , (d) Statements (ii) and (iv)., , Br, , Write the output of the command:, print(Result[-1:-5]), , al, , , (a) No output, (b) Gagan 32, (c) Aman, Divya 34 Divya, Raj, 25 Jeet, Aman 60 Raj, Divya, , 60, (d) Gagan, 34 Jyoti, 78 Raj, 25 Jeet, 34, , 32, 85, 25, 78, , G, , oy, , 36. Ravi received a mail form IRS department. On clicking “ClickHere”, he was taken to a site designed to imitate, an official-looking website, such as IRS.gov for uploading some important information on it. What do you think, he should do?, , (a) ignore it and dont give any response, , (b) reply back to them and share his personal information, , (c) delete the mail and hope they’ll leave him alone in future, , (d) go to the cyber police and do register the complaint, Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 141
Page 149 :
38. Which of the following is not a characteristic of Open Source Software?, , (a) Its source code is available for modification, , (b) It is owned by a company or an individual, , (c) It can be downloaded from internet, , (d) None of the above, , as, ha, n, , 37. From the following dataframe df, calculate the sum of sal and bonue of 1st row (index value 0) using loc, , ENam, Sal, Bonus, , 0, Kavita, 50000, 3000, , 1, Sudha, 60000, 4000, , 2, Garima, 55000, 5000, , (a) print(df.loc[0,’Sal’]+df.loc[0,’Bonus’]), (b) print(df.loc[1,’Sal’]+df.loc[0,’Bonus’]), , (c) print(df.loc[0,’Sal’]+df.loc[1,’Bonus’]), (d) print(df.loc[1,’Sal’]+df.loc[1,’Bonus’]), , [2011 SP], , Pr, ak, , 39. Difference between loc() and iloc().:, , (a) Both can be used in slicing of data from the Pandas DataFrame, , (b) Both can not be used in slicing of data from the Pandas DataFrame, , (c) Only loc( ) can be used in slicing of data from the Pandas DataFrame, , (d) Only iloc() can be used in slicing of data from the Pandas DataFrame, 40. Given the following two series P1 and P2, , P1, , Give the output of following command., , rs, , print(P1+P2), , ot, , he, , (a) C, 500.0, (b) A+C, 200.0, (c) A, D, 800.0 B+D, 600.0 B, E, 1100.0 C+E, 900.0 C, D+F, 1200.0 D, E+G, 1500.0 E, F, , (d) No output G, , A, B, NaN C, D, NaN, E, 500.0, 800.0, 1100.0, NaN, NaN, , 100, 200, 300, 400, 500, , P2, C, D, E, F, G, , 200, 400, 600, 800, 1000, , Br, , 41. Windows software come under_______ category., , (a) Proprietary , (b) FOSS, , (c) Freeware , (d) Shareware, 42. Consider the following dataframe df, First, , Second, , Third, , 0, , Chenab, , 5, , 7, , 6, , 1, , Ganges, , 10, , 5, , 4, , 2, , Jamuna, , 8, , 13, , 15, , 3, , Jhelum, , 12, , 9, , 12, , 4, , Ravi, , 5, , 11, , 10, , 5, , Setluj, , 10, , 5, , 3, , G, , oy, , al, , House, , 142, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 150 :
43. Write the output of the given command:, , , import pandas as pd, , , , print(s.iloc[2]), , s=pd.Series([10,20,30,40,50],[1,2,3,4,5]), , , , (a) 10, , (b) 20, , (c) 30, , 44. Consider the following dataframe Climate, MaxTemp, , MinTemp, , 2017, , 32, , 20, , 2018, , 33, , 22, , 2019, , 35, , 21, , 2020, , 34, , 23, , (d) 40, , Rainfall, , Pr, ak, , Year, , as, ha, n, , , Choose the correct statement to display the house names where the number of Second Prizes are in the range of, 12 to 20., , (a) df[‘Name’][(df[‘Second’]>=12) and (df[‘Second’]<=20)], , (b) df[Name][(df[‘Second’]>=12) & (df[‘Second’]<=20)], , (c) df[‘Name’][(df[‘Second’]>=12) & (df[‘Second’]<=20)], , (d) df[(df[‘Second’]>=12) & (df[‘Second’]<=20)], , 123, 140, 135, , 160, , (b) only (ii), (d) (i), (ii) and (iv), , he, , Choose the correct option:, , (a) both (i) and (ii) , , (c) (i), (ii) and (iii) , , rs, , , Which of the following statement/s will give the exact number of values in each column of the dataframe?, , (i) print(Climate.count()) , (ii) print(Climate.count(0)), (iii) print(Climate.count) , (iv) print(Climate.count(axis=’index’)), , ot, , 45. An organisation purchases new computers every year and dumps the old ones into the local dumping yard. Write the, name of the most appropriate category of waste that the organisation is creating every year, out of the following options:, , (a) Solid Waste, (b) Commercial Waste, (c) E-Waste, (d) Business Waste, , al, , Br, , 46. Consider the dataframe df, empno, name, , A1, 101, a, , A2, 102, b, , A3, 103, c, , A4, 104, d, , salary, 3000, 5000, 8000, 9000, , G, , oy, , , Choose the correct option to display the following output, empno, salary, , A1, 101, 3000, , A4, 104, 9000, , (a) print(df.loc[[‘A1’:’A4’],[‘empno’,’salary’]]), , (b) print(df.loc[‘A1’:’A4’,[‘empno’,’salary’]]), , (c) print(df.loc[‘A1’,’A4’,[‘empno’,’salary’]]), , (d) print(df.loc[[‘A1’,’A4’],[‘empno’,’salary’]]), Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 143
Page 151 :
47. Consider the dataframe “EMP”, Basic, , Da, , Hra, , E1, , Sanya, , 9500, , 3000, , 2000, , E2, , Krish, , 7000, , 5000, , 1900, , E3, , Rishav, , 9650, , 1500, , E4, , Deepak, , 7500, , 2000, , E5, , Kriti, , 9200, , 1800, , 2100, , 2700, 500, , Choose command to change the naame ‘Rishav’ to ‘Rishab’, (a) EMP.loc[2,0]=’Rishab’ , (b) EMP.change[‘E3’,’Name’]=’Rishab’, (c) EMP.rename[2,0]=’Rishab’ #or, (d) EMP.rename[‘Rishav’]=’Rishab’, , Pr, ak, , 48. Consider the following data frame name df, , roll, name, marks, 0, 1, aman, 25.0, 1, 2, bhavna, NaN, 2, 3, rahul, 60.0, Write the output of the given command:, print(df.shape), , , , as, ha, n, , , , , Name, , (a) (3,3), , (b) (3,2), , (c) (2,3), , (d) (2,2), , ot, , he, , rs, , 49. Read the statements given below. Identify the right option from the following for attributes in dataframe., Statement A: The shape attribute returns the number of rows and number of columns available in dataframe., Staement B: The shape attribute return the values in form of list., , (a) Both statements are correct., , (b) Both statements are incorrect., , (c) Statement A is correct, but Statement B is incorrect, , (d) Statement A is incorrect, but Statement B is correct, , SECTION - C, , Br, , Section C consists of 6 Questions (50 to 55). Attempt any 5 questions., , Mr. Rajat is working as data analyst in Company, and he has provided some data. On which he wants to do some operations, but he is facing some problem, help him:, DataFrame :Faculty, AGE, , 0, , Moksha, , 30, , Biology, , A, , 1, , Malini, , 35, , Maths, , A, , 2, , Akshit, , 43, , English, , B, , 3, , Nishant, , 27, , Maths, , B, , oy, , al, , FNAME, , DEPARTMENT, , GRADE, , G, , 50. Which of the following command(s) will display the information whose grade is “A”?, , (i) print(Faculty[Faculty.Grade= =”A”]), (ii) print(Faculty[Faculty[‘Grade’]= =’A’]), , (iii) print(Faculty[‘Grade’]= =’A’), (iv) print(Faculty.Grade= =’A’), , (a) only (i), (b) (i) and (ii), (c) (ii) and (iii), (d) (iii) and (iv), , 144, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)
Page 152 :
as, ha, n, , 51. Which of the following command(s) is used to add new row at the end of dataframe with values, (‘Ankur’,30,’Computer’,’A’)?, , (i) Faculty.insert(‘Ankur’,30,’Computer’,’A’), , (ii) Faculty.loc[4]=[‘Ankur’,30,’Computer’,’A’], , (iii) Faculty.row(‘Ankur’,30,’Computer’,’A’), , (iv) Faculty=Faculty.append({‘Fname’:Ankur,’Age’:30,’Department’:’Computer’,’Grade’:’A’},ignore_index=True), , (a) (i) only, (b) (i) and (iii), (c) (i) and (iv), (d) (ii) and (iv), 52. Select the correct option to delete the row whose index value is 1, , (i) Faculty=Faculty.drop(df.index[1]), (ii) Faculty=Faculty.drop(1), , (iii) Faculty=Faculty.drop(1,axis=0), (iv) Faculty= Faculty.drop(1,0), , (a) only (i) is correct , (b) (i) and (ii) are correct, , (c) (i), (ii) and (iii) are correct , (d) all are correct, , 54. Choose the correct option to change the name of index 0 to new name ‘x’., (a) Faculty.indexname({0:’x’},inplace=True), (b) Faculty.rowname({0:’x’},inplace=True), (c) Faculty.newname({0:’x’},inplace=True), (d) Faculty.rename({0:’x’},inplace=True), , (b) print(Faculty.columns), (d) print(Faculty.col.name), , he, , 55. He wants to show name of columns., , (a) print(Faculty.axes[0]) , , (c) print(Faculty.colname) , , rs, , , , , , , Pr, ak, , 53. Which of the following command is used to display the grade of Fname Akshit?, , (a) print(Faculty.loc[2,3]) , (b) print(Fauclty.iloc[2,3]), , (c) print(Fauclty.iloc[2,4]) , (d) print(Fauclty.iloc[3,4]), , ANSWERS, , 21. (c), 31. (b), 41. (a), , 22. (a), 32. (d), 42. (c), , 4. (a), 14. (d), , 5. (c), 15. (a), , 6. (b), 16. (c), , 7. (c), 17. (c), , 8. (c), 18. (a), , 9. (c), 19. (a), , 10. (a), 20. (c), , 23. (a), 33. (d), 43. (c), , 24. (d), 34. (b), 44. (d), , 25. (a), 35. (a), 45. (c), , 26. (d), 36. (d), 46. (d), , 27. (b), 37. (a), 47. (a), , 28. (d), 38. (b), 48. (a), , 29. (d), 39. (a), 49. (c), , 30. (a), 40. (c), 50. (b), , 52. (d), , 53. (b), , 54. (d), , 55. (b), , G, , oy, , al, , 51. (d), , 3. (b), 13. (c), , ot, , 2. (c), 12. (c), , Br, , 1. (a), 11. (b), , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I), , 145
Page 153 :
G, , oy, , al, , Br, , ot, , he, , rs, , Pr, ak, , as, ha, n, , Notes, , 146, , Score Plus Question Bank and CBSE Sample Paper with Model Test Papers in Informatics Practices-12 (Term I)