Class 12 Computer Science Question Paper(Solved) | PDF | Markup Language | Xml
0% found this document useful (0 votes)
207 views

Class 12 Computer Science Question Paper(Solved)

Uploaded by

mayukhnandi0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
207 views

Class 12 Computer Science Question Paper(Solved)

Uploaded by

mayukhnandi0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Q.NO.

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.

24. If L1=[11,22,33,22,11,22,44,22, . . . ], and L2=[55,66,77, . . .], then (Answer using built- 2


in functions only)
(i)
a) Write a statement to count the occurrences of 44 in L1. L1.Count(44)
OR
b) Write a statement to find the index position of element 66 in List L2. L1.index(66)
(ii)
a) Write a statement to join all the elements of L2 at the end of L1. L3=L1+L2
OR
b) Write a statement to replicate tuple L1 for 2 times. L1*2

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.

(ii) a) What will the ALTER command do?


OR
b) What is the command used to count duplicate rows in a table?
Ans:
i)
a) WHERE Clause
• It is used to filter the records from the table based on a specific condition.
• It can be used without the ‘GROUP BY’ clause.
• It can be used with row operations.
• It can’t contain the aggregate functions.
• It can be used with the ‘SELECT’, ‘UPDATE’, and ‘DELETE’ statements.
• It is used before the ‘GROUP BY’ clause if required.
• It is used with a single row function such as ‘UPPER’, ‘LOWER’.
HAVING Clause
• It is used to filter out records from the groups based on a specific condition.
• It can’t be used without the ‘GROUP BY’ clause.
• It works with the column operation.
• It can contain the aggregate functions.
• It can only be used with the ‘SELECT’ statement.
• It is used after the ‘GROUP BY’ clause.
• It can be used with multiple row functions such as ‘SUM’, ‘COUNT’.
Following is the syntax:
SELECT column1, column2
FROM table1, table2
WHERE [ conditions ]
GROUP BY column1, column2
HAVING [ conditions ] ORDER
BY column1, column2
OR
b) The MYSQL GROUP BY Clause is used to collect data from multiple records and
group the result by one or more column. It is generally used in a SELECT statement.
You can also use some aggregate functions like COUNT, SUM, MIN, MAX, AVG etc. on
the grouped column.
Syntax:
SELECT expression1, expression2, ... expression_n,
aggregate_function (expression)
FROM tables [WHERE
conditions]
GROUP BY expression1, expression2, ... expression_n;
ii)
a) The SQL ALTER TABLE command is a part of Data Definition Language (DDL) and
modifies the structure of a table. The ALTER TABLE command can add or delete
columns, create or destroy indexes, change the type of existing columns, or rename
columns or the table itself.
The ALTER TABLE command can also change characteristics of a table such as the
storage engine used for the table.
Syntax
Following is the basic syntax of an ALTER TABLE command − ALTER
TABLE table_name [alter_option ...];
Where, the alter_option depends on the type of operation to be performed on a table.

28. a) Expand the following terms: XML, SMTP 2


b) Give the difference between XML and HTML.
OR
a) Define the term baud with respect to networks.
b) How is http different from https?
Ans:
(i) eXtensible Markup Language, Simple Mail Transfer Protocol
(ii) HTML( Hyper text mark Up language)
• We use pre-defined tags
• Static web development language – only focuses on how data looks
• It use for only displaying data, cannot transport data
• Not case sensitive
XML (Extensible Markup Language)
• we can define our own tags and use them
• Dynamic web development language – as it is used for transporting and storing data
• Case sensitive
OR
(i) Baud is the number bits carrying in one second.
(ii) https (Hyper Text Transfer Protocol Secure) is the protocol that uses SSL (Secure
Socket Layer) to encrypt data being transmitted over the Internet. Therefore, https
helps in secure browsing while http does not.
SECTION-C 3x3=
9
29. def countwords(): 3
f = open('python.txt','r')
data = f.read()
words = data.split()
c=0
for i in words:
if i[0].isupper():
c+= 1
print(c)
f.close()

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 = " ")

31. [2, 26, 23, 18] 3


OR
(4, 6, 8, 7, 5, 3)
SECTION-D 4x4=
16
32. 4

OR

(iv) SELECT * FROM ACTIVITY ORDER BY SCHEDULEDATE DESC;

33. import csv 4


def insert():
f = open('watch.csv','a',newline='')
ClockID = input("Enter Clock ID = ")
ClockName = input("Enter Clock Name = ")
YearofManf = int(input("Enter Year of Manufacture = "))
price = float(input("Enter Price = "))
L = [ClockID, ClockName, YearofManf, price]
data = csv.writer(fout)
data.writerow(L)
f.close()

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()

34. i. Select distinct Qty from garment; 4


ii. Select sum(Qty) from garment group by CCode having count(*)>1;
iii. Select GNAME, CNAME, RATE from garment g, cloth c where g.ccode=c.ccode and
Qty>100;
iv. Select avg(Rate) from garment where rate between 1000 and 2000;
OR
SELECT * FROM GARMENT, CLOTH;
35. 4

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

You might also like