Class 12 Computer Science Question Paper(Solved)
Class 12 Computer Science Question Paper(Solved)
QUESTION MARKS
SECTION-A 21 x 1 =
21
1. State True or False: 1
“In a Python loops can also have else clause”.
True
2. What is the maximum width of numeric value in data type int of MySQL. 1
a) 10 digits b) 11 digits c) 9 digits d) 12 digits
3. What will be the output of the following Python code? 1
T1=(1,2,[1,2],3)
T1[2][1]=3.5
print(T1)
a) (1,2,[3.5,2],3) b) (1,2,[1,3.5],3) c) (1,2,[1,2],3.5) d) Error Message
4. What will be the output of the following expression if the value of a=0, b=1 and c=2? 1
print(a and b or not c )
a) True b) False c) 1 d) 0
5. What should be the output of the following code? 1
String = “India will be a global player in the digital economy”
Str1= String.title()
Str2=Str1.split()
print(Str2[len(Str2)-1:-3:-1])
(a) [‘Digital’,’Economy’] b) [‘The’,’Digital’,’Economy’]
c) [‘economy’,’digital’] d) [‘Economy’,’Digital’]
6. What will be the output of the following Python code snippet? 1
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
a) True b) False c) Error d) None
7. What will be the output of following code if 1
a = “abcde”
a [1:1 ] == a [1:2]
print(type (a[1:1]) == type (a[1:2]))
Ans:
True
8. Which of the following statement is not true regarding opening modes of a file? 1
a) When you open a file for reading, if the file does not exist, an error occurs.
b) When you open a file for writing, if the file does not exist, an error does not occur.
c) When you open a file for appending content, if the file does not exist, an error does
not occur.
d) When you open a file for writing, if the file exists, new content added to the end
of the file.
9. In MYSQL database, if a table, Student has degree 2 and cardinality 3, and another 1
table, Address has degree 5 and cardinality 6, what will be the degree and cardinality
of the Cartesian product of student and address?
a) 6,18 b) 7,18 c) 10,9 d) 12,15
10. Write the missing statement to complete the following code: 1
file = open("DATA.txt", "r")
L= #to read first 5 characters from the file
Print(L)
file.close()
Ans: L=file.read(5)
11. State True or False: 1
“try, finally, except is the correct order of blocks in exception handling.”
False
12. Consider the code given below: 1
b=5
def myfun(a):
# missing statement.
b=b*a
myfun(14)
print(b)
Which of the following statements should be given in the blank for # Missing
statement, if the output produced is 70?
a) global a b) global b=70 c) global b d) global a=70
13. Which of the following keywords will you use in the following query to display the 1
unique values of the column dept_name?
SELECT --------------------- dept_name FROM Company;
a) All b) key c) Distinct d) Name
14. Which of the following query is incorrect? Assume table EMPLOYEE with attributes 1
EMPCODE, NAME, SALARY and CITY.
a) SELECT COUNT(*) FROM EMPLOYEE;
b) SELECT COUNT(NAME) FROM EMPLOYEE;
c) SELECT AVG(SALARY) FROM EMPLOYEE;
d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE;
15. Which among the following list of operators has the highest precedence? 1
+,-,**,%,/,<>,and, or, +=
a) += b) ** c) and d) %
16. The clause is used for pattern matching in MySQL queries. 1
a) ALL b) DESC c) MATCH d) LIKE
17. Praveen wants to transfer files and photos from laptop to his mobile. He uses 1
Bluetooth Technology to connect two devices. Which type of network will be formed
in this case.
a) PAN b) LAN c) MAN d) WAN
18. Radio-Waves, microwaves and infrared waves are types of . 1
a) Wireless transmission b) Guided medium
c) Wired transmission d) Unguided transmission
19. Fill in the blank: 1
In case of switching, message is sent in stored and forward
manner from sender to receiver.
Ans: Message
Q20 and 21 are ASSERTION AND REASONING 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
20. Assertion (A):- A parameter having a default in function header becomes optional in 1
function call.
Reasoning (R):- A function call may or may not have values for default arguments.
Ans: (a)
21. Assertion (A):- A unique value that identifies each row uniquely is the primary key. 1
Reasoning (R):- Only one column can be made the primary key.
Ans: (c)
SECTION – B
22. What is an expression and a statement in Python? 2
Ans:
• Expression
An expression is a unit of code that produces a value. It can be as simple as a single
variable or value, or more complex. For example, any string is an expression because it
represents the value of the string.
• Statement
A statement is a larger unit of code that performs an action or makes something
happen. For example, the line of code let amount = $2000 is a statement because it
assigns $2000 to amount.
23. If a is (5,5,6), what is the difference (if any) between a*3 and (a,a,a) ? 2
Ans:
a * 3 ⇒ [1, 2, 3, 1, 2, 3, 1, 2, 3]
[a, a, a] ⇒ [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
So, a * 3 repeats the elements of the list whereas [a, a, a] creates nested list.
25. What possible outputs are expected to be displayed on the screen at the time of 2
execution of the program from the following code?
import random
temp=[10,20,30,40,50,60]
c=random.randint(0,4)
for i in range(0, c):
print(temp[i],”#”)
a) 10#20# b) 10#20#30#40#50# c) 10#20#30# d) 50#60#
26. Observe the following Python code very carefully and rewrite it after removing all 2
syntactical errors with each correction underlined.
Ans:
def factorial(N):
fact=1
while N>0:
fact*=N
N=N-1
print("Factorial", fact)
#main
factorial(5)
27. i) 2
a) Differentiate between WHERE and HAVING clause used in MySQL with appropriate
example.
OR
b) Explain the use of GROUP BY clause in MySQL with an appropriate example.
OR
def ALCount():
f = open('STORY.txt','r')
data = f.readlines()
count_a = 0
count_l = 0
for i in data:
if i[0] in 'aA':
count_a+= 1
elif i[0] in 'lL':
count_l+=1
print('A or a:',count_a)
print('L or l:',count_l)
f.close()
30. stack=[] 3
def push(dict1):
for i in dict1:
if dict1[i] < 85000:
stack.append(i)
def pop(stack):
while len(stack)!=0:
print(stack.pop(),end = " ")
OR
record=[]
def push(nl):
for i in nl:
if i[2] == 'Delhi':
stack.append(i)
print(record)
return(record)
def pop(record):
while len(record)!=0:
print(record.pop(),end = " ")
OR
def delete():
clockid = input("Enter Clock ID to be removed = ")
found = False
f1 = open('watch.csv','r')
data = csv.reader(f1)
L = list(data)
for i in data:
if i[0]==clockid:
found=True
print("Record to be removed is:")
print(i)
L.Remove(i)
break
if found==False:
print("Record not found")
else:
f2 = open('watch.csv','w',newline='')
W = csv.writer(fout)
W.writerows(L)
f2.close()
print("Record Successfully Removed")
f1.close()
SECTION E 2X5
=10
36. (a) Text files: • Extension is .txt • Data is stored in ASCII format that is human readable 2+3=5
• Has EOL character that terminates each line of data stored in the text files Binary
Files • Extension is .dat • Data is stored in binary form (0s and 1s), that is not human
readable.
(b)
37. 5