COMPUTER SCIENCE (083)
HOME TEST 2 CLASS XII
Time allowed: 3 hours Maximum Marks: 70
General Instructions:
(i) This question paper contains five sections, Section A to E.
(ii) All questions are compulsory.
(iii) Section A have 18 questions carrying 01 mark each.
(iv) Section B has 07 Very Short Answer type questions carrying 02 marks each. 5
(v) Section C has 05 Short Answer type questions carrying 03 marks each.
(vi) Section D has 03 Long Answer type questions carrying 05 marks each.
(vii) Section E has 02 questions carrying 04 marks each. One internal choice is
given in
Q35 against part c only.
(viii) All programming questions are to be answered using Python Language only.
Q No. Marks
Section-A (21 x 1 = 21 Marks)
Which of the following statements is true?
1. (A) The standard exceptions are automatically imported into Python
programs
(B) All raised standard exceptions must be handled in Python 1
(C) When there is a deviation from the rules of a programming language, a
semantic error is thrown
(D) If any exception is thrown in try block, else block is executed
Select the correct output of the following code :
2.
s=“I#N#F#O#R#M#A#T#I#C#S”
L=list(s.split(‘#’)) 1
print(L)
1
(A) [I#N#F#O#R#M#A#T#I#C#S]
(B) [‘I’, ‘N’, ‘F’, ‘O’, ‘R’, ‘M’, ‘A’, ‘T’, ‘I’, ‘C’, ‘S’]
(C) [‘I N F O R M A T I C S’]
(D) [‘INFORMATICS’]
Evaluate the expression given below if A=16 and B=15.
3.
A % B // A 1
(A) 1 ( B) 0.0 (C) 0 ( D) 1.0
What will be the output of the following code?
4. D1={1: “One”,2: “Two”, 3: “C”}
D2={4: “Four”,5: “Five”}
D1.update(D2)
print (D1) 1
(A) {4:’Four’,5: ‘Five’}
(B) Method update() doesn’t exist for dictionary
(C) {1: “One”,2: “Two”, 3: “C”}
(D) {1: “One”,2: “Two”, 3: “C”,4: ‘Four’,5: ‘Five’}
Predict the output of following python code.
5. SS="PYTHON"
print( SS[:3:])
(A) THON 1
(B) PYT
(C) PYTH
(D) HON
Choose the correct output of following code:
6. Tup=(100)
print(Tup*3)
1
(A) (300,) (B) (100,100,100) (C) Syntax Error (D) 300
Given the following dictionaries
7. Dict1={‘Tuple’:’immutable’,’List’:’mutable’,’Dictionary’:’mutable’,’String’
:’immutable’}
Which of the following will delete key:value pair for key=‘Dictionary’ in the
above mentioned dictionary?
1
(A) del Dict1[‘Dictinary’]
(B) Dict1[‘Dictionary’].delete( )
(C)delete (Dict1.[“Dictionary”])
(D)del(Dict1.[‘Dictionary’])
A Python List is declared as
8.
Stud_Name = ['Aditya', 'aman', 'Aditi','abhay']
What will be the value of min(Stud_Name)?
1
(A) abhay
(B) Aditya
(C) Aditi
2
(D) aman
The SELECT statement when combined with ………….clause,return records
9. without repletion.
(A) NULL
(B)UNIQUE
1
(C)DESCRIBE
(D) DISTINCT
The sysntax of seek( ) method in Python is :-
10.
File.object.seek(offset [, reference point])
In the above syntax the offset refers to :-
1
(A) Specifying Initial position of the file pointer.
(B) Specifying number of bytes.
(C) Specifying file opening mode.
(D) None of the above
Every syntax error is an exception but every exception cannot be a
11. syntax error." Justify the statement. 1
Study the following program and select the possible output(s) from the
12. options (i) to (iv) following it.
import random
Ar=[20,30,40,50,60,70]
From = random.randint(1,3)
To = random.randint(2,4)
for K in range(From,To+1):
1
print(Ar[K],end="%")
(i) 10%40%70%
(ii) 30%40%50%
(iii) 50%60%70%
(iv) 40%50%60%
Which command is used to add a new constraint in existing table in SQL.
13.
(A) insert into
(B) alter table 1
(C) add into
(D) create table
Consider the following statement:
14.
SELECT * FROM PRODUCT ORDER BY RATE………, ITEM_NAME ………
Which of the following option should be used to display the rate from greater
1
to smaller and name in alphabetical order?
(A) ASC, DESC
(B) DESC, ASC
3
(C) Descending, Ascending
(D) Ascending, Descending
Which of the following aggregate function ignore NULL value?
15. A)COUNT
(B)MAX 1
(C)AVERAGE
(D)ALL OF THESE
Which of the following is invalid method for fetching the records from
16.
database within Python
(A)fetchone()
(B)fetchall()
1
(C)fetchmany()
(D)fetchmulti()
The function of a repeater is to take a weak signals and ……………… it.
17.
(A) Restore
(B) Regenerate 1
(C) Reroute
(D) Drop
…………….Protocol is used to send the email to another email user.
18. (A) FTP
(B)POP 1
(C) IMAP
(D) SMTP
Fill in the blank:
19. ___________ is the protocol used to send emails to the e-mail server and _________
is the protocol used to download mail to the client computer from the server.
(A) SMTP,POP 1
(B) HTTP,POP
(C) FTP,TELNET
(D) HTTP,IMAP
Q20 and Q21 are Assertion(A) and Reason(R) based questions. Mark the
correct choice as:
(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
Assertion(A): A variable not declared inside a function can still be used
20. inside the function if it is declared at a higher scope level.
Reason(A): Python resolves a name using LEGB rule where it checks in Local
1
(L), Enclosing (E), Global (G) and Built-in scopes (B), in the given order.
4
Assertion(A): A database can have only one table in MySql.
21. Reasoning(R): When a piece of data is stored in multiple places in the 1
databases, then the scenario is called data redundancy.
Section-B ( 7 x 2=14 Marks)
22 Explain the difference between implicit and explicit type conversion.
Given the following Python expressions, identify whether the conversion is
implicit or explicit. 2
A) a = 6+5.8 B) b = int(8.5)
C) c = str(100) D) d = 8/4
23 Give two examples for each of the following: 2
i) Logical errors ii) Run-time errors
24 If L1=[5,3,7,1,3,9,2,3] and L2=[‘apple’,’banana’,’cherry’....] then
(Answer using built-in functions only)
I)
A) Write a statement to count the occurrences of 3 in L1.
OR 2
B) Write the statement to find the maximum element in list L1.
II)
A) Write a statement to extend L1 by appending all elements from L2.
OR
B) Write a statement to sort the elements of L2 in alphabetical order.
25 Identify the correct output of the following code. Also write the minimum and
maximum possible values of the variable b.
import random
a = ”Intelligent”
b = random.randint(1,6) 2
for i in range (b,len(a)):
if i%2==0:
print(a[i],end=’*’)
(a) t*l*i*e*t* (b) t*l*g*n*
( c) n*e*l*g*n (d) l*i*n*t
26 The code provided below is intended to calculate the square of each element
in a list. However, there are syntax and logical errors in the code. Rewrite it
after removing all errors. Underline the corrections made.
def square_elements(1st)
result = [] 2
for i in 1st
result.append(i**2)
return result
print(“Squared elements:”square_elements[1,2,3,4])
27 I)
A)What constraint should be applied to a table column so that each value is 2
unique and not null but it is not the primary key?
OR
5
B) What constraint should be applied on a table column so that it acts as a
foreign key referencing another table?
II)
A) Write an SQL command to remove the UNIQUE constraint from a column
EMPLOYEE_EMAIL in the table EMPLOYEE.
OR
B) Write an SQL command to make the column EMPLOYEE_EMAIL UNIQUE in
an already existing table named EMPLOYEE.
28 A) What is the difference between bit rate and baud rate?
OR 2
B) Explain the term VoIP and describe its main use.
Section-C ( 3 x 3 = 9 Marks)
29 Write a function in python to read lines from file “THEORY.txt” and display all
those words, which has five characters in it.
OR 3
Write a function filter(oldfile, newfile) that copies all the lines of a text file
“source.txt” onto “target.txt” except those lines which starts with “@” sign.
30 Raj is a Python programmer working of Data structure Stack to store name of
visitors, he has implemented the code for PUSH and POP, but both
functions are not producing the correct result. Help Raj in identifying the
error(s) and also write the Correct code for specific line number:
def PUSH(VISITOR,name):
name.append(VISITOR) #Line 1
top = len(VISITOR)-1 #Line 2
def POP(VISITOR):
if len(VISITOR)==1: #Line 3
return "Sorry! No Visitor to delete " #Line 4
else:
val = VISITOR.pop(1) #Line 5
if len(VISITOR)==1: #Line 6 3
top=None #Line 7
else:
top=len(VISITOR) #Line 8
return val
(OR)
Raj is a Python programmer working of Data structure Queue to store name
of REQUESTNO, he has implemented the code for ENQUEUE and DEQUEUE,
for insert and delete operation in Queue resp. But both functions are not
producing the correct result. Help Raj in identifying the Line Number where
code is incorrect and also write the Correct code for same Line Number.
def Enqueue(REQUESTNO,item):
REQUESTNO.add(item) #Line 1
if len(REQUESTNO)==1: #Line 2
6
front=rear=1 #Line 3
else:
rear=len(REQUESTNO)-1 #Line4
def Dequeue(REQUESTNO):
if REQUESTNO==0: #Line 5
print("Underflow") #Line 6
else:
val = REQUESTNO.pop(len(REQUESTNO)-1) #Line 7
if len(REQUESTNO)==0: #Line 8
front=None #Line 9
return val
31 Predict the output for the following
x = [1,2,3]
counter = 0
while counter < len(x):
print(x[counter] * '%')
for y in x:
print(y * '* ')
counter += 1
(OR) 3
Predict the output for the following
x ='apple, pear, peach, grapefruit'
y = x.split(', ')
for z in y:
if z < 'm':
print(str.lower(z))
else:
print(str.upper(z))
SECTION D (4 X 4 = 16 Marks)
32 Write SQL commands for (i) to (v) on the basis of table WORKERS
TABLE: WORKERS
N Name Age Departm Date of Basic Sex
o ent Join
1 anitha 45 AI 13/02/88 10500 F
4
2 nisha 54 AI 10/01/90 9500 F
3 yugan 43 DataScie 27/02/98 8500 M
nce
4 prakash 34 ECE 11/01/93 7500 M
7
5 ajay 51 Robotics 22/01/91 8500 M
6 renu 27 ECE 14/02/94 9000 F
7 usha 29 AI 10/02/93 8500 F
8 thaya 35 Robotics 02/02/89 10500 M
9 Varun 49 Robotics 03/01/88 9000 M
10 shri 22 DataScie 17/02/92 8000 F
nce
1. Write a query to change the Basic salary to 10500 of all those
teachers from COLLEGE, who joined the WORKERS after 01/02/89
and are above the age of 50.
2. Write a query to display Name, Age and Basic of all those from
WORKERS, who belong to DataScience and ECE department only.
3. Which command will be used to delete a row from table
WORKERS, in which NAME is Varun?
4. Insert the following data in the given table WORKERS
11, ‘saro, 50, ‘computer science, ‘18/05/93’, 12000, ‘M’
5. Identify the attribute best suitable to be declared as a primary key.
33 Write one point of difference between seek() and tell() functions in
file handling. Write a program in Python that
defines and calls the following user defined functions:
i. Add_Photo() : The function accepts and adds records of the photo
to a csv file photo.csv'. 4
Each record consists of a list with field elements as P_id, P_name
and Size to store photo ID,File name, and Size respectively.
ii. Count_photo() : To count and display number of photo, whose
Size is less than ₹ 628
34 Consider the following tables EMPLOYEE and DEPARTMENT and
answer (a) and (b) parts of this question.
Table: EMPLOYEE
TCode TName DCod Sal Age JoinDate
e
15 Sameer 23 7500 39 01-Apr- 4
2007
21 Ragu 01 8500 29 11-Nov-
2005
34 Ram 19 5250 43 03-Mar-
2010
46 Meena 03 6700 38 12-Jul-
2004
8
77 Kumar 03 6300 55 25-Nov-
2000
81 Rajesh 19 7450 48 11-Dec-
2008
89 Sanjai 01 9260 54 12-Jan-
2009
93 Pragya 23 3200 29 05-Aug-
2006
Table: DEPARTMENT
DCode DName HOD
01 ACCOUNTS Raj
03 HR Singh
23 RESEARCH Vijay
19 TRANSPORT Yogesh
a. Write SQL commands for the following statements:
i. To display all DName along with the DCode in descending order
of DCode.
ii. To display the average age of Employees in DCode as 103.
iii. To display the name of HOD of the Employee named "Sanjai"
iv. To display the details of all employees who have joined before
2007 from the EMPLOYEE table.
b. Give the output of the following SQL queries:
i. SELECT COUNT (DISTINCT DCode) FROM EMPLOYEE;
ii. SELECT MAX(JoinDate), MIN (JointDate) FROM EMPLOYEE;
iii. SELECT TName, HOD FROM EMPLOYEE E, DEPARTMENT D
WHERE E.DCode =D.DCode;
iv. SELECT COUNT (*) FROM EMPLOYEE WHERE Sal > 6000
AND Age > 30;
35 Consider the following table staff
ENo EName Job Hiredate Sal DeptNo
839 Roshan Manager 17/11/81 50000 10
698 Geethan Coach 01/5/81 26000 25
872 RajkumarAccountan 18/7/81 26500 20 4
t
560 Varun Engineer 1/2/84 10000 12
325 Vidhya S/w Eng. 27/5/82 55000 35
Write Python code to insert 2 records with suitable data in the above table
taking system date as Hiredate.
9
SECTION E (2 X5 = 10 Marks)
36 (i) What are the similarities and differences between a+ and w file modes in
Python.
(ii) A binary file “product.dat” has structure
[PNO, PNAME, BRAND_NAME, PRICE]
to maintain and manipulate Product details.
*Write a user defined function CreateFile() to input data for a record and add 5
it to “product.dat” file. The number of records to be entered until the user
chooses ‘Y’ / ‘Yes’.
*Write a function CountData(BRAND_NAME) in Python which accepts the
brand name as parameter and count and return the number of products by
the given brand are stored in the binary file “product.dat”.
37 Magnolia Infotech wants to set up their computer network in the Bangalore
based campus having four buildings. Each block has a number of computers
that are required to be connected for ease of communication, resource
sharing and data security. You are required to suggest the best answers to the
questions i) to v) keeping in mind the building layout on the campus.
i) Suggest the most appropriate block to host the Server. Also justify your
choice.
ii) Suggest the device that should be placed in the Server building so that they
10
can connect to the Internet Service Provider to avail Internet Services.
iii) Suggest the wired medium and draw the cable block to block layout to
economically connect the various blocks.
iv) Suggest the placement of Switches and Repeaters in the network with
justification.
v) Suggest the high-speed wired communication medium between Bangalore
Campus and Mysore campus to establish a data network.
11