Students must start practicing the questions from CBSE Sample Papers for Class 12 Informatics Practices with Solutions Set 1 are designed as per the revised syllabus.
CBSE Sample Papers for Class 12 Informatics Practices Set 1 with Solutions
Time Allowed: 3 hours
Maximum Marks: 70
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each,
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 02 questions carrying 04 marks each.
7. Section E has 03 questions carrying 05 marks each.
8. All programming questions are to be answered using Python Language only.
Section – A
Question 1.
A ……………. is a device that connects the organisation’s network with the outside world of the Internet.
(i) Hub
(ii) Modem
(iii) Gateway
(iv) Repeater
Answer:
(iii) Gateway
Explanation: A gateway is a device that connects two dissimilar networks. It is actually a node on in a network that* serves as an entrance to another network. In enterprises, it acts as a proxy server, a firewall to prevent unauthorized access to and from the private network, a router which uses headers and forwarding tables and a switch which provides path for the movement of the packets in and out of the gateway.
Question 2.
When e-waste such as electronic circuit boards are burnt for disposal, the elements contained in them create a harmful chemical called ………….. which causes skin diseases, allergies and an increased risk of lung cancer.
(i) Hydrogen
(ii) Beryllium
(iii) Chlorine
(iv) Oxygen
Answer:
(ii) Beryllium
Explanation: Electrical and electronic equipments contain metallic and non- metallic elements, alloys and compounds. When these equipment reach the end of their lifecycle these are generally either dumped into landfills or burnt. When dumped into land fill, chemical components of these equipment pollute the soil. When burnt many of these substances produce harmful gases .Beryllium is also released as it has very high melting point and it also doesn’t gets oxidized.
Question 3.
Copyright, Patent and Trademark comes under:
(i) Intellectual Property Right
(ii) Individual Property Right
(iii) Industrial Property Right
(iv) None of these
Answer:
(i) Intellectual Property Right
Explanation: Any form of creation be it music, art, painting, sculpture, poem, article or any other creative piece such as a software, an interface etc which is a result of someone’s hard work and intellect is that individual’s intellectual property. Any unauthorized access and use of such piece of creation is a violation to the intellectual property rights. Many laws and regulations have been enforced to check such violations. Copyright, patent and trademark are some such regulations.
Copyright gives the owner of such information right to decide the extent of use of his creation.
Patent grants an inventor sole rights to his invention. Trademark is a sign or symbol representing a product or service that distinguishes it clearly from others. It is used to identify that product or service. Thus it makes its owner stand out from others and hence safeguards the intellectual property.
Question 4.
Predict the output of the following query:
SELECT MOD (9,0);
(i) 0
(ii) Null
(iii) NaN
(iv) 9
Answer:
(ii) Null
Explanation: Mod ( ) is used to find the remainder of the division of two numbers. Its syntax is MOD(x,y) when x is divided by y.
Here 9 is being divided by 0 which is not possible hence the answer will be Null.
Question 5.
Which of the following SQL functions does not belong to the Math functions category?
(i) POWER ()
(ii) ROUND ()
(iii) LENGTH ()
(iv) MOD ()
Answer:
(iii) LENGTH ()
Explanation:
power( ) calculates power of a number i.e.
Round( ) is used to round off a value.
Mod( ) is used to find the remainder of a division, i.e remainder of a/b.
Length( ) is used to find length of a field or string. It doesn’t involve any arithmetical operation or numeric operand, hence it is not a mathematical function.
Question 6.
…………… is not a FOSS tool.
(i) Libre Office
(ii) Mozilla Firefox
(iii) Google Chrome
(iv) Python
Answer:
(iii) Google Chrome
Explanation: FOSS stands for Free and Open Source Software. It refers a software which is both free and open source. Mozilla Firefox, Libre office and Python are free and open source, google chrome is also free but not open source.
Question 7.
CSV stands for:
(i) Column Separated Value
(ii) Class Separated Value .
(iii) Comma Separated Value
(iv) None of the above
Answer:
(iii) Comma Separated Value
Explanation: CSV text files are delimited text files that contain individual data separated by a comma.
Question 8.
Raj, a Database Administrator, needs to display the average pay of workers from those departments which have more than five employees. He is experiencing a problem while running the following query:
SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT(*) > 5 GROUP BY DEPT;
Which of the following is a correct query to perform the given task?
(i) SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT(*) > 5 GROUP BY DEPT;
(ii) SELECT DEPT, AVG(SAL) FROM EMP HAVING COUNT(*) > 5 GROUP BY DEPT;
(iii) SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPT WHERE COUNT(*) > 5;
(iv) SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPT HAVING COUNT(*) > 5;
Answer:
(iv) SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPT HAVING COUNT(*) > 5;
Explanation: WHERE clause is used to put condition on individual rows and HAVING clause is used to put condition on groups. Here we need to put condition on groups of departments so first we will form groups and then use the HAVING clause.
Question 9.
Predict the output of the following query:
SELECT LCASE (MONTHNAME (‘2023-03-05’));
(i) May
(ii) March
(iii) may
(iv) march
Answer:
(iv) march
Explanation: MONTHNAME () will give the month of the given argument i.e. March. Now the LCASE() function will convert this to lowercase i.e march.
Question 10.
Which of the following command will show the last 3 rows from a Pandas Series named NP?
(i) NR.Tail ( )
(ii) NR.tail (3)
(iii) NP.TAIL(3)
(iv) All of the above
Answer:
(ii) NR.tail (3)
Explanation: tail() function is used to extract specified number of elements from the end of a series. Here we need to extract last three rows of NP series. Hence NPtail(3).
Question 11.
With reference to SQL, identify the invalid data type.
(i) Date
(ii) integer
(iii) Year
(iv) Month
Answer:
(iv) Month
Explanation:
SQL provides following datatypes
STRING Types
- CHAR(size)
- VARCHAR(size)
- TEXT(size)
Numeric Types
- INT(size)
- FLOAT(size,d)
- DEC
DATE and TIME types
- DATE( )
- TIME( )
- YEAR( )
Question 12.
In Python Pandas, while performing mathematical operations on series, index matching is implemented and all missing values are filled in with by default.
(i) Null
(ii) Blank
(iii) Nan
(iv) Zero
Answer:
(iii) Nan
Explanation: When mathematical operations are performed on a Pandas Series, the operations are performed only on the matching indexes. The non available values are filled with NaN(Not a Number).
Question 13.
By restricting the server and encrypting the data, a software company’s server is unethically accessed in order to obtain sensitive information. The attacker blackmails the company to pay money for getting access to the data, and threatens to publish sensitive information unless price is paid. This kind of attack is known as:
(i) Phishing
(ii) Identity Theft
(iii) Plagiarism
(iv) Ransomware
Answer:
(iv) Ransomware
Explanation: All these are types of cybercrime. Phishing refers to an attempt by the cyber criminals to pose as a legitimate or trustworthy source and make the user give . in his /her personal information. Identity theft refers to an attack; in which the criminal uses someone’s personal information such as name, login credentials, credit card details to pose as that person online for personal gains. Plagiarism refers to the act of using someone’s work, idea or words and present them as one’s own. Ransomware refers to the cyber attack when criminals gain access to . a system and captivate important files and data. In such cases the users of the system loose access to the data and have to pay the amount demanded by the attacker in lieu of getting back the access.
Question 14.
In SQL, the equivalent of UCASE ( ) is:
(i) UPPERCASE ( )
(ii) CAPITALCASE ( )
(iii) UPPER( )
(iv) TITLE ( )
Answer:
(iii) UPPER( )
Explanation: UCASE( ) in SQL is used to convert a string to upper case. UPPER( ) also converts a string to uppercase.
Question 15.
Collection of hyper linked documents available on the internet is known as ………….
(i) Website
(ii) Webpage
(iii) Web Server
(iv) Web Hosting
Answer:
(i) Website
Explanation: A website is a collection of electronic documents linked with each other through hyperlinks.
Question 16.
…………….. is a non-profit organization that aims to build a publicly accessible global platform where a range of creative and academic work is shared freely.
(i) Creative Cost
(ii) Critical Commons
(iii) Creative Commons
(iv) Creative Common
Answer:
(iii) Creative Commons
Explanation: Creative Commons (CC) is an intern¬ationally active non-profit organisation that provides free licences for creators to use when making their work available to the public. These licences help the creator to give permission for others to use the work in advance under certain conditions.
Question 17.
Assertion (A): MODEM stands for modulator-demodulator.
Reason (R): It is a computer hardware device that converts data from a digital format to analog and vice versa.
(i) Both (A) and (R) are true and(R) is the correct explanation of (A)
(ii) Both (A) and (R) are true but(R) is not the correct explanation of (A)
(iii) (A) is true, but (R) is false
(iv) (A) is false, but (R) is true
Answer:
(i) Both (A) and (R) are true and(R) is the correct explanation of (A)
Explanation: when digital data is transmitted over telephone lines it needs to be converted to analog signals (Modulation). Similarly at the receiving end the analog data received must be converted back to the digital form to be used with digital devices(Demodulation). For this purpose a special device is used. This device is called MODEM as it modulates as well as demodulates the data.
Question 18.
Assertion (A): To use the Pandas library in a Python program, one must import it.
Reason (R): The only alias name that can be used with the Pandas library is pd.’
(i) Both (A) and (R) are true and(R) is the correct explanation of (A)
(ii) Both (A) and (R) are true but(R) is not the correct explanation of (A) .
(iii) (A) is true, but (R) is false
(iv) (A) is false, but (R) is true
Answer:
(iii) (A) is true, but (R) is false
Explanation: To use Pandas library in a Python program it needs to be imported. A library in Python can be imported using import statement, the syntax for which is import<library name> as <alias>. This alias name can be any valid identifier. Therefore when Pandas library is imported any alias name can be used.
Section – B
Question 19.
Briefly explain the basic concepts of a web server and web hosting.
Answer:
Web server: A web server is used to store anc! deliver the contents of a website to clients such as a browser that request it. A web server can be software or hardware. 2 Web hosting: It is a service that allows to put a website or a web page onto the Internet, and make it a part of the World Wide Web.
OR
URL: It stands for Uniform Resource Locatoi. It provides the location and mechanism (protocol) to access the resources over the internet.
URL is sometimes also called a web address. It not only contains the domain name, but other information as well that completes a web address.
Examples:
https://www.cbse.nic.in, https://www.mhrd.gov. in, http://www.ncert.nic.in, http://www.airindia.in, etc.
Explanation: Web Server- Internet operates on Client Server architecture. In this type of architecture there is a host that provides services to its clients. In WWW any computer that stores the web pages or documents, that can be requested by a client are known as Web servers or Web hosts. The service that these computers provide is known as web hosting.
OR
Every web site on the WWW has a unique address called URL. A typical URL is of the form: type://address/path. Here type is the type of the server on which the file or the page is located, address is the address of the server or the host and path is the location of the file on the server.
In the given examples https://www.cbse.nic.in https specifies that the server is a http server, www.cbse.nic. in is the domain or address of the web server.
OR
Rati is doing a course in networking. She is unable to understand the concept of URL. Help her by explaining it with the help of suitable example.
Answer:
Question 20.
The python code written below has syntactical errors. Rewrite the correct code and underline the corrections made.
Import pandas as pd
df ={“Technology”: [“Programming”,”Robotics”, “3D Printing”],”Time(in months)”: [4,4,3]}
df= Pd.dataframe(df)
Print(df)
Answer:
import pandas as pd
df = {” Technology”:[“Pogramming” .”Robotics”,”3D Printing”],”Time(in months)”, [1,4, 3]}
df = pd.Data Frame(df)
print (df)
Explanation: Python is a case sensitive language so uppercase and lowercase letters are treated differently, import, print and DataFrame are keywords. Using Import, Print and dataframe in place of import, print and DataFrame respectively will give errors.
Question 21.
Consider the given SQL string:
“12#All the Best!”
Write suitable SQL queries for the following:
(i) Returns the position of the first occurrence of the substring “the” in the given string.
(ii) To extract last five characters from the string.
Answer:
(i) SELECT INSTR(“12#All the Best!”, “the”);
(ii) SELECT RIGHT(“12#All the Best!”, 5);
Explanation:
(i) INSTR(str, substr)retums the first occurrence of ‘substr’ in ‘str’.
(ii) RIGHT(str, n) returns n characters from the right of the ‘str’.
Question 22.
Predict the output of the given Python code:
import pandas as pd
list1=[-10,-20,-30]
ser = pd. Series(listl*2)
print(ser)
Answer:
0-10
1-20
2-30
3-10
4-20
5-30
Explanation: * operator in Python when used with any series data type, works as replicator, i.e it repeats , that series the specified number of times. <Series>*n will repeat the <series> n times. Here the list listl will be repeated 2 times and then converted into a Pandas Series using Series() function.
Question 23.
Differentiate between the active digital footprint and passive digital footprints.
Answer:
Active Digital Footprints: Active digital footprints include data that we intentionally submit online. This would include emails we write, or responses or posts we make on different websites or mobile Apps, etc.
Passive Digital Footprints: The digital data trail we leave online unintentionally is called passive digital footprints. This includes the data generated when we visit a website, use a mobile App, browse Internet, etc.
Explanation: Any activity that we do online leaves some marks. This activity may be in the form of comment, posting a picture, browsing history etc. these marks are known as digital footprints and can be of two types Active digital footprints and passive digital footprints. The comments or posts or mails are our intentional activities and leave an active digital footprint whereas when we browse the internet, visit a web site or use a mobile app, although the activities are intentional but the data that is collected by these sites and apps is hidden from us. So this leaves a passive digital footprint.
Question 24.
Complete the given Python code to get the required output as: Rajasthan
import as pd
di = {‘Corbett’: ‘Uttarakhand’, ‘Sariska’ : ‘Rajasthan’, ‘Kanha’ : ‘Madhya Pradesh’, ‘Gix’ :’Gujarat’ }
NP = ____ Series (____)
print(NP[____])
Answer:
import pandas as pd
di = {‘Corbett’: ‘Uttarakhand’, ‘SariskaYRajasthan’, ‘Kanina’: ‘Madhya Pradesh’, ‘GirYGujarat’}
NP = pd.Series(di)
print(NP[‘Sariska’)
Explanation: This code creates a Pandas series so we need to import the pandas library first. Now to create a series from a dictionary the syntax is
<series name? = <pandas alias>. Series (<dictionary_name?)
To get the value stored at a particular index in a series the index name is to be specified along with the series name. The syntax is <Series_name>[<index>]
Question 25.
What are aggregate functions in SQL? Name any two.
Answer:
Aggregate functions: These are also called multiple row functions. These functions work on a set of records as a whole, and return a single value for each column of the records on which the function is applied.
Max( ), Min( ), Avg( ), Sum( ), Count( ) and Count(*) are few examples of multiple row functions.
Detailed Answer:
Explanation: Functions that return single values from groups of values are called aggregate functions. These are used to calculate summary values from a column of all the rows of a table or a subset of rows. These can be applied in general to any numeric values and some CHAR and DATE values. The table can be divided into groups using GROUP By clause.
Section – C
Question 26.
Based on the SQL table CAR_SALES, write suitable queries for the following:
(i) Display fuel wise average sales in the first quarter.
(ii) Display segment wise highest sales in the second quarter.
(iii) Display the records in the descending order of sales in the second quarter.
Answer:
(i) SELECT FUEL, AVG(QTl) FROM CAR.SALES GROUP BY FUEL;
(ii) SELECT SEGMENT, MAX(QT2) FROM CAR.SALES GROUP BY SEGMENT;
(iii) SELECT * FROM CAR.SALES ORDER BY QT2 DESC;
OR
(i) LEFT(SEGMENT,2)
Co
MU
SU
Sc
(ii) AVG SALE
13500.0000
6000.0000
(iii) TOT SALE
67000
Explanation: (i) In this query average sales for Quarter 1 are to be displayed based on each fuel type. So the data is grouped according to Fuel and then average sales is calculated using average function.
(ii) Here the data is to be grouped according to the segment so ‘GROUP BY Segment ‘ clause is used and to find the highest sa,ps in the second quarter max(QT2) clause is used.
(iii) In this query data is to be displayed in descending order of sales of quarter 2 so ‘OREDR BY QT2’
clause is used .To display in descending order DESC clause is used.
OR
Predict the output of the following queries based on the table CARSALES given above:
(i) SELECT LEFT(SEGMENT,2) FROM CAR_SALES WHERE FUEL= “PETROL”;
(ii) SELECT (QT2-QT1)/2 “AVG SALE” FROM CAR_SALES WHERE SEGMENT= ”
(iii) SELECT SUM(QT1) “TOT SALE” FROM CAR_SALES WHERE FUEL= “DIESEL”;
Answer:
(i) EFT( ) function is used to extract specified number of letters from CHAR or VARCHAR types of data. Here’LEFT(SEGMENT,2)’ will extract 2 characters from llit.- left of the column ‘SEGMENT’ lor I lie rows where fuel type is “Petrol”.
(ii) This query displays the half of the diIfereme of sales of quarter 2 and quarter 1 for the SEGMENT ‘SUV’.
The heading ol the output is displayed as “AVG SALE”(alias name given to the value obtained) as specified in the SELECT clause.
(iii) This query displays the total sales for (Juarterl lor the vehicles of FUEL type
DIESEL The alias given to the output is “TOT SALE”
Question 27.
Create a DataFrame in Python from the given list:
[[‘Di vya’,’HR’,95000],[‘Mamta’,’Marketing’,97000],[‘Payal’,’IT’,980000],
[‘Deepak’,’Sales’, 79000]]
Also give appropriate column headings as shown below:
Answer:
import pandas as pd #Statement1
df = [[“Divya”,” HR”, 95000], [“Mamta”, “Marketing”, 97000],
[“Payal”, “IT”, 980000], [“Deepak”, “Sales”, 79000]] #Statement 2
df = pd, DataFrame (df, columns = [“Name”, “Department”, “Salary”l]) #Statement3
print (df) # Statement 4
Explanation: Statement 1 is used to import the PANDAS library with alias pd.
#statement2 creates a nested list for the given data.
#statement3 creates a dataframe df using function DataFrame.
Syntax of DataFrame( ) function is <dataframe object> = pandas.DataFrame(<a 2D datastructure>, [columns = <column sequencer>], [index = cindex sequence>])
#statement4 prints the dataframe.
Question 28.
Write MySQL statements for the following:
(i) To create a database named FOOD.
(ii) To create a table named Nutrients based on the following specification:
Column Name | Data Type | Constraints |
Food_Item | Varchar(20) | Primary Key |
Calorie | Integer |
Answer:
(i) CREATE DATABASE FOOD;
(ii) CREATE TABLE NUTRIENTS
(NAME VARCHAR(20)
PRIMARY KEY,CALORIES INTEGER);
Explanation:
(i) To create a database CREATE DATABASE command is used.
(ii) To create a table CREATE TABLE <table name> command is used. To create a table its columns and their data types are to be specified. Also any constraints that need to be applied to the table should also be specified with this command. Before using create table command its parent data base should be opened.
Question 29.
Richa, recently started using her social media account. Within a few days, she befriends many people she knows and some that she does not know. After some time, she starts getting negative comments on her posts. She also finds that her pictures are being shared online without her permission.
Based on the given information, answer the questions given below.
(i) Identify the type of cybercrime she is a victim of.
(ii) Under which act, she can lodge a complaint to the relevant authorities?
(iii) Suggest her any two precautionary measures which she should take in future while being online to avoid any such situations.
Answer:
(i) She is a victim of Cyber Bullying.
(ii) Information Technology Act, 2000 (also known as IT Act).
(iii) a. Need to be careful while befriending unknown people on the internet,
b. Never share personal credentials like username and password with others.
Simran needs to be made aware of the following consequences:
(i) Eyestrain
(ii) Painful muscles and joints
(iii) Poor memory
(iv) Lack of sleep
(v) Back pain and neck pain
Explanation: (i) When technology such as internet, social media etc is used to embarrass, harass, defame or demean someone it is known as Cyber bullying and must be reported to either parents, elders and in more serious cases to the Police.
(ii) Cyber laws in India are enforced through Information Technology Act 2000, based on the United Nation’s commission for International Trade related laws.
(iii) To avoid Cyber Bullying we should follow some precautions such as:
(a) Never share our passwords with anyone.
(b) Never befriend any unknown person.
(c) Never share your personal details with anyone.
(d) Never share your location details with anyone .
(e) Report any such incident immediately to your elders or some one you trust. They will help you come out of this.
(f) If it doesn’t stop report to police or cyber cell.
OR
Mention any three health hazards associated with inappropriate and excessive use of gadgets.
Answer:
Health hazards of excessive use of technology and gadgets:
(i) Vision problems: Bright light and bad glare or flickering image can strain your eyes.
(ii) Headache: Because of increased muscle tension or pain in the neck at the base of the skull, headache is common problem with computer use.
(iii) Stress disorders: Prolonged computer use along with other factors like poor health, work pressure and job environment can make you susceptible to stress. Moreover, the longer you uphold the stress, the more susceptible you become to other health issues.
Question 30.
Consider the given Data Frame ‘Genre’:
Type | Code | |
0 | Fiction | F |
1 | Non Fiction | NF |
2 | Drama | D |
3 | Poetry | P |
Write suitable Python statements for the following:
(i) Add a column called Num_Copies with the following data: [300,290,450,760],
(ii) Add a new genre of type ‘Folk Tale’ having code as “FT” and 600 number of copies.
(iii) Rename the column ‘Code’ to ‘Book Code’.
Answer:
(i) Genre[“Num_Copies”] = [300,290,450,760] 3
(ii) Genre.Loc[4] = [“Folk Tale”,”FT”,600]
(iil) Genre=Genre.rename([“Code”:”Book_Code”}, axis=l)
OR
Genre = Genre.rename({“Code”:”Book_Code”}, axis=”columns”)
Explanation: (i) To add a column to an existing dataframe , the values of each row of that column are provided in the form of a list. The syntax is: <dataframe object>[<column name>] = <list of values>
(ii) To add a row to an existing dataframe following syntax is used.
<DF object>[<row name>,:] =<new value>
OR
<DF object>.loc[<row name>,:] =<newvalue>
(iii) To rename any axis of a dataframe the syntax is
<dataframe object> = <dataframe object>.rename({<oldname>:<newname>,[….]}, axis = <axis name>)
Section – D
Question 31.
Preeti manages database in a blockchain start-up. For business purposes, she created a table named BLOCKCHAIN. Assist her by writing the following queries: [4]
TABLE: BLOCKCHAIN
(i) Write a query to display the year of oldest transaction.
(ii) Write a query to display the month of most recent transaction.
(iii) Write a query to display all the transactions done in the month of May.
(iv) Write a query to count total number of transactions in the year 2022.
Answer:
(i) SELECT YEAR(MIN(TRANSACTION_DATE)) FROM BLOCKCHAIN;
(ii) SELECT MONTH(MAX(TRANSACTION DATE)) FROM BLOCKCHAIN;
(iii) SELECT ‘ FROM BLOCKCHAIN WHERE MONTHNAME (TRANSACTION_DATE)=’MAY’;
(iv) SELECT COUNT(ID) FROM BLOCKCHAIN WHERE YEARfTRANSACTION DATE)=2022;
Explanation: (i) The older dates in sql are treated to be smaller than the new one. So to get the date of oldest transaction min( ) function is used.
(ii) To select the most recent transaction date max( ) function is used. Month( ) returns the month from a date. So max( ) function is nested within the month( ) to get the month of the most recent transaction.
(iii) monthname( ) function returns the name of the month from a date. To get the transactions done in the month of MAY, monthname( ) function is used in WHERE clause.
(iv) count( ) function is used to count the number of records. Here we need to count the transactions in the year 2022 so in WHERE clause year( ) function is used to get the year of the transaction date.
Question 32.
Ekam, a Data Analyst with a multinational brand has designed the DataFrame df that contains the four quarter’s sales data of different stores as shown below: [4]
Answer the following questions:
(i) Predict the output of the following python statement:
a. print(df.size)
b. print(df[1:3])
(ii) Delete the last row from the DataFrame.
(iii) Write Python statement to add a new column Total_Sales which is the addition of all the 4 quarter sales.
OR
(Option for part iii only)
Write Python statement to export the Data Frame to a CSV file named data.csv stored at D: drive.
Answer:
(i) a. 15
b.
(ii) df=df.drop(2)
OR
df.ilrup(2,axis=0)
(iii) df[“total”]=df[“Qtr1”] + df[“Qtr2”] + df[“Qtr3”] + df[“Qtr4”]
OR
df.to csv(“D:\duta.csv”)
Explanation:
(i) (a) Size is an attribute of dataframe objects that returns an int representing the number of elements of this object. Which is 15 here.
(b) Slicing is the method to extract a subset from a dataframe. The syntax for slicing is <dataframe object> [start row index :end row index]
The rows from ‘start row index’ till ‘end row index’ excluding the row at ‘end row index’ are extracted from the dataframe.
(ii) The syntax to delete a row or column is <dataframe object>.drop(<row/column> index>, axis). This will delete the specified row/column depending upon the axis (0 for row and 1 for column).
OR
<dataframe objectl>=<dataframe objectx drop(<rowindex>). This will return a dataframe object after deleting a row from the dataframe.
(iii) To add a new column syntax is:
<dataframe object>[<column name>] = <List of values>
Now to add sales of all the four quarters df[“qtr1”]+ df[“qtr2”]+df[“qtr3”]+df[“qtr4”] is used.
Df[“qtr1”] accesses the value at qtrl of a row. Similarly for other quarters. All the values are added to get the total sales and the result is inserted in the new column.
OR
Df.to_csv(“D:\data.csv”)
Section – E
Question 33.
Write suitable SQL queries for the following:
(i) To calculate the exponent for 3 raised to the power of 4.
(ii) To display current date and time.
(iii) To round off the value -34.4567 to 2 decimal place.
(iv) To remove all the probable leading and trailing spaces from the column userid of the table named user.
(v) To display the length of the string ‘FIFA World Cup’.
Answer:
(i) SELECT POWER(3,4);
(ii) SELECT NOW( );
(iii) SELECT ROUND(-34.4567, 2);
(iv) SELECT TRIM(USERID) FROM USER;
(v) SELECT LENGTH(“FIFA World Cup”);
OR
(i) INSERT INTO EXAM VALUES(6.’Khush(‘,’CS’.85);
(ii) UPDATE EXAM SET subject= “Informatics Practices” where subject = “IP”;
(iii) DELETE FROM EXAM WHERE marks<30;
(iv) ALTER TABLE EXAM ADD COLUMN grade varchar(2);
(v) Select * from exam where subject=”lnformatics Practices”;
Explanation: (i) Power( ) function is used to calculate the value of base raised to the power. Syntax: * Power(base, power)
(ii) now( ) function returns the current date and time. It takes no arguments.
(iii) round( ) function is used to round off a number to specified number of decimal places.
Syntax: round(number, decimal places)
(iv) trim( ) function is used to remove all the leading and trailing blank spaces from a string.
Ltrim( ) function truncates the leading blank spaces and rtrim( ) function truncates the trailing blank spaces.
(v) length( ) function returns the length of a string.
OR
Kabir has created following table named exam:
Help him in writing SQL queries to the perform the following task:
(i) Insert a new record in the table having following values: [6, ‘Khushi’, ‘CS’, 85]
(ii) To change the value “IP” to “Informatics Practices” in subject column.
(iii) To remove the records of those students whose marks are less than 30.
(iv) To add a new column Grade of suitable data type.
(v) To display records of “Informatics Practices” subject.
Answer:
(i) to insert a new record in table ‘Insert Into’ command is used.
Syntax: INSERT INTO <table name> VALUES
(<value of each column separated by comma>)
This is a DML command.
(ii) to update values in a table UPDATE command is used.
Syntax: UPDATE <table name> SET <column name> = <value> Where <codition>
This is a DML command.
(iii) to delete rows from a table DELETE command is used.
Syntax: DELETE FROM <table name> WHERE <condition>
This is a DML command.
(iv) To add a new column we need to change the structure of the table. For this ALTER TABLE command is used with ADD.
Syntax: ALTER TABLE <table name> ADD ccolumn namexdata typex constraints>
This is a DDL command.
(v) To display records SELECT command is used.
Syntax: SELECT <columnl>, <column2>,… FROM <table name> WHERE <condition>
Question 34.
XYZ Media house campus is in Delhi and has 4 blocks named Z1, Z2, Z3 and Z4. The tables given below show the distance between different blocks and the number of computers in each block.
Block Z1 to Block Z2 | 80 metres |
Block Z1 to Block Z3 | 65 metres |
Block Z1 to Block Z4 | 90 metres |
Block Z2 to Block Z3 | 45 metres |
Block Z2 to Block Z4 | 120 metres |
Block Z3 to Block Z4 | 60 metres |
Black | Number of computers |
Z1 | 135 |
Z2 | 290 |
Z3 | 180 |
Z4 | 195 |
The company is planning to form a network by joining these blocks.
(i) Out of the four blocks on campus, suggest the location of the server that will provide the best connectivity. Explain your response.
(ii) For very fast and efficient connections between various blocks within the campus, suggest a suitable topology and draw the same.
(iii) Suggest the placement of the following devices with justification
(a) Repeater
(b) Hub/Switch
(iv) VoIP technology is to be used which allows one to make voice calls using a broadband internet connection. Expand the term VoIP
(v) The XYZ Media House intends to link its Mumbai and Delhi centres. Out of LAN, MAN, or WAN, what kind of network will be created? Justify your answer.
Answer:
(i) as it has maximum number of computers.
(ii) For very fast and efficient connections between various blocks within the campus suitable topology: Star Topology
(iii) Repeater: To be placed between Block Z2 to Z4 as distance between them is more than 100 metres.
Huh/Swilch: To be placed in each block as each block has many computers that needs to be included to form a network.
(iv) Voice Over Internet Protocol
(v) WAN as distance between Delhi and Mumbai is more than 40kms.
Explanation:
(i) The block with maximum number of computers is elected to install the server so that the minimum number of systems are at a larger distance and the connectivity is better.
(ii) In star topology all the nodes are connected to a central computer directly, therefore the transmission is very fast and effective.
(iii) A repeater is a device that amplifies a signal being transmitted. It is used in long network lines where data is to be transmitted to a distance greater than that rated.
A hub is used to connect several computers together while a switch is used to divide the network into sub segments and is responsible for forwarding data packets. These devices are placed at every location where we need to segment the network. Here it is placed in each block to divide network into different sub-networks at each block level.
(iv) VoIP is the protocol used to establish a connection and transfer data in the form of audio signals over internet just as in a phone call. This technology is used to make voice calls over internet. VoIP is : Voice over internet protocol.
(v) LAN network is suited for connections within a building or small premises.
MAN networks are formed for connectivity within the bounds of a city.
WAN networks connect devices across cities, countries and continents.
Question 35.
The heights of 10 students of eighth grade are given below:
Height_cms=[145,141,142,142,143,144,141,140,143,144]
Write suitable Python code to generate a histogram based on the given data, along with an appropriate chart title and both axis labels.
Also give suitable python statement to save this chart.
OR
Write suitable Python code to create ‘Favourite Hobby’ Bar Chart as shown below:
Also give suitable python statement to save this chart.
Answer:
Import matplotlib.pyplot as pit #Statement 1 Helght_cms = [145,141,142,142,143,143,141,140,143, 144]
# Statement 2 | |
plt.hist(Height_cms) | # Statement 3 |
plt.title(Height Chart”) | # Statement 4 |
plt.xlabel(“Height in cms”) | # Statement 5 |
plt.ylabel(“Number of People”) | # Statement 6 |
plt.show( ) | #Statement 7 |
OR
import matplotlib.pyplot as plt | # Statement 1 |
hobby =(‘Dance’, ‘Music’, Painting’, ‘Playing Sports’) | # Statement 2 |
users = [300, 400, 100, 500] | # Statement 3 |
plt.bar(hobby, users) | # Statement 4 |
plt.title(“Favourite Hobby”) | # Statement 5 |
plt.ylabel(“Number of people”) | # Statement 6 |
plt.xlabel(“Hobbies”) | # Statement 7 |
plt.show( ) | # Statement 8 |
plt.savefig(“hobhies.jpg”)
Explanation: Pyplot interface of Matplotlib library is used in Python for data visualization. (# statement 1)
The data to be plotted is taken as a list. (# statement 2) To plot a histogram hist() function is used. It takes data series a s argument. ( # statement 3)
To give title to the plot title( ) function of pyplot is used. (# statement 4)
To give label to x axes xlabel( ) function of pyplot is used. (# statement 5)
To give label to y axes ylabel( ) function of pyplot is used. (# statement 6)
To display the plot show( ) function of pyplot is used. (# statement 7)
To save the chart savefig( ) function of pyplot is used. Its syntax is <pyplot alias>. savefig(<file name>)
OR
Pyplot interface of Matplotlib library is used in Python for data visualization. (# statement 1)
The data to be plotted on x axis is taken as the tuple ‘hobby’. (# statement 2)
The data to be plotted on y axis is taken as the list ‘users’. (# statement 3)
To plot a bar chart bar( ) function is used. It takes two data series as argument. First is the data to be plotted on x-axis and second is the data to be plotted on y axis.
(# statement 4)
To give title to the plot title( ) function of pyplot is used. (# statement 5)
To give label to y axes ylabel( ) function of pyplot is used. (# statement 6)
To give label to x axes xlabel( ) function of pyplot is used. (# statement 7)
To display the plot show( ) function of pyplot is used. (# statement 8)
To save the chart savefig( ) function of pyplot is used. Its syntax is <pyplot alias>. savefig(<file name>)