Subject: Computer Science
Class XII
Time Allowed: 3 hours
Max. Marks: 70
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 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 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.
SECTION A
1. State True or False
“Variable declaration is implicit in Python.”
Ans. True
2. Which of the following is an invalid datatype in Python?
(a) Set (b) None (c) Integer (d) Real
3. Given the following dictionaries
Which statement will merge the contents of both dictionaries?
a. dict_exam.update(dict_result)
b. dict_exam + dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)
4. Consider the given expression:
not True and False or True
Which of the following will be correct output if the given expression is evaluated?
(a) True (b) False (c) NONE (d) NULL
5. Select the correct output of the code:
(a) Year. 0. at All the best
(b) Year 0. at All the best
(c) Year. 022. at All the best
(d) Year. 0. at all the best
6. Which of the following mode in file opening statement results or generates an error if the file does not exist?
(a) a+ (b) r+ (c) w+ (d) None of the above
7. Fill in the blank:
______ command is used to remove primary key from the table in SQL
(a) update (b) remove (c) alter (d) drop
8. Which of the following commands will delete the table from MYSQL database?
(a) DELETE TABLE (b) DROP TABLE (c) REMOVE TABLE (d) ALTER TABLE
9. Which of the following statement(s) would give an error after executing the following code?
(a) Statement 3 (b) Statement 4 (c) Statement 5 (d) Statement 4 and 5
10. Fill in the blank:
_________ is a non-key attribute, whose values are derived from the primary key of some other table.
(a) Primary Key (b) Foreign Key (c) Candidate Key (d) Alternate Key
11. The correct syntax of seek() is:
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
12. Fill in the blank:
The SELECT statement when combined with __________ clause, returns records without repetition.
(a) DESCRIBE (b) UNIQUE (c) DISTINCT (d) NULL
13. Fill in the blank:
______is a communication methodology designed to deliver both voice and multimedia communications over Internet protocol.
(a) VoIP (b) SMTP (c) PPP (d) HTTP
14. What will the following expression be evaluated to in Python?
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
15. Which function is used to display the total number of records from table in a database?
(a) sum(*) (b) total(*) (c) count(*) (d) return(*)
16. To establish a connection between Python and SQL database, connect() is used. Which of the following arguments may not necessarily be given while calling connect() ?
(a) host (b) database (c) user (d) password
17. Assertion (A): – If the arguments in function call statement match the number and order of arguments as defined in the function definition, such arguments are called positional arguments.
Reason (R): – During a function call, the argument list first contains default argument(s) followed by positional argument(s).
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks like a text file.
Reason (R): The information is organized with one record on each line and each field is separated by comma.
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
SECTION B
20. Rao has written a code to input a number and check whether it is prime or not. His code is having errors. Rewrite the correct code and underline the corrections made.
Ans.
21. Write two points of difference between Circuit Switching and Packet Switching.
Ans.
Circuit Switching | Packet Switching |
Circuit switching is the method of switching which is used for establishing a dedicated communication path between the sender and the receiver. | Packet switching is the method of switching where no dedicated path is established from the source to the destination. |
Data is processed and transmitted at the source only. | Data is processed and transmitted, not only at the source but at each switching station. |
It is more reliable. | It is less reliable. |
OR
Write two points of difference between XML and HTML.
Ans. XML (Extensible Markup Langauge)
· XML tags are not predefined, they are user defined
· XML stores and transfers data.
· Dynamic in nature
HTML (Hypertext Markup Langauge)
· HTML tags are pre-defined and it is a markup language
· HTML is about displaying data.
· Static in nature
21. (a) Given is a Python string declaration:
Ans. @20 otnmx SC@
(b) Write the output of the code given below:
Ans. dict_items([(‘name’, ‘Aman’), (‘age’, 27), (‘address’, ‘Delhi’)])
22. Explain the use of ‘Foreign Key’ in a Relational Database Management System. Give example to support your answer.
Ans. A foreign key is used to set or represent a relationship between two relations ( or tables) in a database. Its value is derived from the primary key attribute of another relation.
TRAINER
TID | TNAME | CITY | HIREDATE | SALARY |
101 | Ritu | Nagpur | 1998-10-15 | 56700 |
102 | Navin | Goa | 1994-12-24 | 80000 |
103 | Murugan | Chandigarh | 2001-12-21 | 82000 |
104 | Jyothi | Guwahati | 2002-12-25 | 68000 |
105 | Chanu | Mumbai | 1996-01-12 | 95000 |
106 | Arbaaz | Delhi | 2001-12-1256700 | 69000 |
COURSE
CID | CNAME | FEES | STARTDATE | TID |
C201 | Deepa | 12000 | 2018-07-02 | 101 |
C202 | Sindhu | 15000 | 2018-07-15 | 103 |
C203 | Neeraj | 10000 | 2018-10-01 | 102 |
C204 | Prakash | 9000 | 2018-09-15 | 104 |
C205 | Nikhat | 20000 | 2018-08-01 | 101 |
For example: In the tables TRAINER and COURSE given below, TID is primary key in TRAINER table but foreign key in COURSE table.
23. (a) Write the full forms of the following:
(i) SMTP
(ii) PPP
Ans. (i) SMTP: Simple Mail Transfer Protocol
(ii) PPP: Point to Point Protocol
(b) What is the use of TELNET?
Ans. TELNET is used to access a remote computer / network.
24. Predict the output of the Python code given below:
Ans: 22 # 40 # 9 # 13 #
OR
Predict the output of the Python code given below:
Ans. (22,44,66)
25. Differentiate between count() and count(*) functions in SQL with appropriate example.
Ans. COUNT(*) returns the count of all rows in the table, whereas COUNT () is used with Column_Name passed as argument and counts the number of non-NULL values in a column that is given as argument.
Example: Table: EMPL
EMPNO | ENAME | JOB | SAL | DEPTNO |
8369 | SMITH | CLERK | 2985 | 10 |
8499 | ANYA | NULL | 9870 | 20 |
8566 | AMIR | SALESMAN | 8760 | 30 |
8698 | BINA | MANAGER | 5643 | 20 |
8912 | SUR | NULL | 3000 | 10 |
e.g. SELECT COUNT (*) FROM EMPL;
Output
Count (*) |
5 |
e.g. SELECT COUNT (*) FROM EMPL;
Count (JOB) |
3 |
Since JOB has 2 NULL values
OR
Categorize the following commands as DDL or DML: INSERT, UPDATE, ALTER, DROP
Ans. DDL- ALTER, DROP
DML – INSERT, UPDATE
SECTION C
26. (a) Consider the following tables – Bank_Account and Branch:
What will be the output of the following statement?
SELECT * FROM Bank_Account NATURAL JOIN Branch;
Ans.
(b) Write the output of the queries (i) to (iv) based on the table, TECH_COURSE given below:
(i) SELECT DISTINCT TID FROM TECH_COURSE;
Ans.
(ii) SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID HAVING COUNT(TID)>1;
Ans.
(iii) SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY CNAME;
Ans.
(iv) SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000 AND 17000;
Ans. 15500.00
27. Write a method COUNTLINES() in Python to read lines from text file ‘TESTFILE.TXT’ and display the lines which are not starting with any vowel.
Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The COUNTLINES() function should display the output as:
The number of lines not starting with any vowel – 1
Ans.
OR
Write a function ETCount() in Python, which should read each character of a text file “TESTFILE.TXT” and then count and display the count of occurrence of alphabets E and T individually (including small cases e and t too).
Example:
If the file content is as follows:
Today is a pleasant day.
It might rain today.
It is mentioned on weather sites
The ETCount() function should display the output as:
E or e: 6
T or t : 9
Ans.
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and Placement given below:
(i) SELECT Department, avg(salary) FROM Teacher GROUP BY Department;
Ans.
(ii) SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM Teacher;
Ans.
(iii) SELECT Name, Salary, T.Department, Place FROM Teacher T, Placement P WHERE T.Department = P.Department AND Salary>20000;
Ans.
(iv) SELECT Name, Place FROM Teacher T, Placement P WHERE Gender =’F’ AND T.Department=P.Department;
Ans.
(b) Write the command to view all tables in a database.
Ans. SHOW TABLES;
29. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the function. The function returns another list named ‘indexList’ that stores the indices of all Non-Zero Elements of L.
For example:
If L contains [12,4,0,11,0,56]
The indexList will have – [0,1,3,5]
Ans.
30. A list contains following record of a customer:
[Customer_name, Phone_number, City]Write the following user defined functions to perform given operations on the stack named ‘status’:
(i) Push_element() – To Push an object containing name and Phone number of customers who live in Goa to the stack
(ii) Pop_element() – To Pop the objects from the stack and display them. Also, display “Stack Empty” when there are no elements in the stack.
For example:
If the lists of customer details are:
[“Gurdas”, “99999999999”,”Goa”] [“Julee”, “8888888888”,”Mumbai”] [“Murugan”,”77777777777”,”Cochin”] [“Ashmit”, “1010101010”,”Goa”]The stack should contain
[“Ashmit”,”1010101010”] [“Gurdas”,”9999999999”]The output should be:
[“Ashmit”,”1010101010”] [“Gurdas”,”9999999999”]Stack Empty
Ans.
OR
Write a function in Python, Push(SItem) where , SItem is a dictionary containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who have price greater than 75. Also display the count of elements pushed into the stack.
For example:
If the dictionary contains the following data:
Ditem={“Pen”:106,”Pencil”:59,”Notebook”:80,”Eraser”:25}
The stack should contain
Notebook
Pen
The output should be:
The count of elements in the stack is 2
Ans.
SECTION D
31. MakeInIndia Corporation, an Uttarakhand based IT training company, is planning to set up training centres in various cities in next 2 years. Their first campus is coming up in Kashipur district. At Kashipur campus, they are planning to have 3 different blocks for App development, Web designing and Movie editing. Each block has number of computers, which are required to be connected in a network for communication, data and resource sharing. As a network consultant of this company, you have to suggest the best network related solutions for them for issues/problems raised in question nos. (i) to (v), keeping in mind the distances between various blocks/locations and other given parameters.
Distance between various blocks/locations:
(i) Suggest the most appropriate block/location to house the SERVER in the Kashipur campus (out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
Ans. Movie editing block is the most appropriate to house the server as it has the maximum number of computers.
(ii) Suggest a device/software to be installed in the Kashipur Campus to take care of data security.
Ans. Firewall
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to economically connect various blocks within the Kashipur Campus.
Ans. Ethernet Cable
(iv) Suggest the placement of the following devices with appropriate reasons:
a. Switch / Hub
b. Repeater
Ans. Switch/hub will be placed in all blocks to have connectivity within the block.
Repeater is not required between the blocks as the distances are less than 100 mts.
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution between Kashipur Campus and Mussoorie Campus.
Ans. Protocol: VoIP
32. (a) Write the output of the code given below:
Ans. 105#6#
(b) The code given below inserts the following record in the table Student:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python and MYSQL:
· Username is root
· Password is tiger
· The table exists in a MYSQL database named school.
· The details (RollNo, Name, Clas and Marks) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Student.
Statement 3- to add the record permanently in the database
Ans. Statement 1:
con1.cursor()
Statement 2:
mycursor.execute(querry)
Statement 3:
con1.commit()
OR
(a) Predict the output of the code given below:
Ans. sELCcME&Cc
(b) The code given below reads the following record from the table named student and displays only those records who have marks greater than 75:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python and MYSQL:
· Username is root
· Password is tiger
· The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those students whose marks are greater than 75.
Statement 3- to read the complete result of the query (records whose marks are greater than 75) into the object named data, from the table student in the database.
Ans. Statement 1:
con1.cursor()
Statement 2:
mycursor.execute(“select * from student where Marks>75”)
Statement 3:
mycursor.fetchall()
33. What is the advantage of using a csv file for permanent storage? Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’. Each record consists of a list with field elements as empid, name and mobile to store employee id, employee name and employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSV file named ‘record.csv’.
Ans. Advantage of a csv file:
· It is human readable – can be opened in Excel and Notepad applications
· It is just like text file
OR
Give any one point of difference between a binary file and a csv file. Write a Program in Python that defines and calls the following user defined functions:
(i) add() – To accept and add data of an employee to a CSV file ‘furdata.csv’. Each record consists of a list with field elements as fid, fname and fprice to store furniture id, furniture name and furniture price respectively.
(ii) search()- To display the records of the furniture whose price is more than 10000.
Ans. Difference between binary file and csv file: (Any one difference may be given)
Binary file:
· Extension is .dat
· Not human readable
· Stores data in the form of 0s and 1s
CSV file
· Extension is .csv
· Human readable
· Stores data like a text file
SECTION E
34. Navdeep creates a table RESULT with a set of records to maintain the marks secured by students in Sem 1, Sem2, Sem3 and their division. After creation of the table, he has entered data of 7 students in the table.
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primary key.
Ans. ROLL_NO
(ii) If two columns are added and 2 rows are deleted from the table result, what will be the new degree and cardinality of the above table?
Ans. New Degree: 8
New Cardinality: 5
(iii) Write the statements to:
a. Insert the following record into the table Roll No- 108, Name- Aadit, Sem1- 470, Sem2-444, Sem3- 475, Div – I.
b. Increase the SEM2 marks of the students by 3% whose name begins with ‘N’.
Ans. a. INSERT INTO RESULT VALUES (108, ‘Aadit’, 470, 444, 475, ‘I’);
b. UPDATE RESULT SET SEM2=SEM2+ (SEM2*0.03) WHERE SNAME LIKE “N%”;
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of students securing IV division.
b. Add a column REMARKS in the table with datatype as varchar with 50 characters
Ans. a. DELETE FROM RESULT WHERE DIV=’IV’;
b. ALTER TABLE RESULT ADD (REMARKS VARCHAR(50));
35. Aman is a Python programmer. He has written a code and created a binary file record.dat with employeeid, ename and salary. The file contains 10 records.
He now has to update a record based on the employee id entered by the user and update the salary. The updated record is then to be written in the file temp.dat. The records which are not to be updated also have to be written to the file temp.dat. If the employee id is not found, an appropriate message should to be displayed.
As a Python expert, help him to complete the following code based on the requirement given above:
(i) Which module should be imported in the program? (Statement 1)
Ans. pickle
(ii) Write the correct statement required to open a temporary file named temp.dat. (Statement 2)
Ans. fout=open(‘temp.dat’, ‘wb’)
(iii) Which statement should Aman fill in Statement 3 to read the data from the binary file, record.dat and in Statement 4 to write the updated data in the file, temp.dat?
Ans. Statement 3: pickle.load(fin)
Statement 4: pickle.dump(rec,fout)