Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

COMPUTER SCIENCE-12th

As per latest syllabus, guidelines and sample paper


issued by CBSE

Hints & Solutions


SECTION – A
1. False 2. (c), //
3. (d), dict_values(['R', 'T', 'Y', 'B', 'V']) 4. (c), Both (ii) and (iv)
5. (a), 9 6. (c), file = open('Notes.txt', 'w')
7. (a), Primary 8. (b), Statement 2

9. (b), Cardinality 10. (a), Referential Integrity

11. (d), 14 12. (a), Insert Into


13. (b), Advanced Research Project Agency Network
14. (d), 3125 15. (a), 'HELLO WORLD' False 6 False
16. (a), Fetchall ()
17. (a), Both A and R are true and R is the correct explanation for A
18. (a), Both A and R are true and R is the correct explanation for A

SECTION – B

19. def updation ( A = 20) :

A + = 25 // Line 2 [: was not required]


print ('A=' A)
A = 30
Updation ( )
print ('A=', A) // Line 6 [, was missing]
Note : Both line 2 and line 6 has found error.
20. ARPANET : Advanced Research Project Agency Network
POP : Post Office Protocol
OR
Wired medium cables can be twisted pair, Co-axial cable and Fiber optics.

1
2 DEEPAK CBSE Sample Papers
21. (a) "Hello, World!"
(d) dict_values(['R', 'T', 'Y', 'B', 'V'])
22. A foreign key is a set of attributes in a table that refers to the primary key of another table. The foreign key links
these two tables. The foreign key constraint is used to prevent actions that would destroy links between tables. A
foreign key is a field (or collection of fields) in one table, that refers to the primary key in another table.
For example, a person table contain the column Person id, Last name, First name, Age and an order table contains
the column Order id, Order number and Person id. Person id is primary key in person table and Order id is primary
key in order table. But both tables contain one common field i.e. Person id. So Person id column can be used as
foreign key, if we combine both tables.
23. (a) (i) A Peer to Peer network contains equal ranking for each computer, each system can double up as a client as
well as a non-dedicated server.
(ii) A network hub is a node that broadcasts data to every computer or Ethernet-based device.
(b) A router is a networking device that forwards data packets between computer networks. Routers perform the
traffic directing functions on the Internet. A router can link ethernet to a mainframe. A router is different from a
bridge in way that former uses logical addresses and the latter uses physical addresses.
24. The output will be
P*rt**t*sm
OR
The output will be
45 89 75
25. DDL and DML both are differentiated categories of SQL command.
Data Definition Language (DDL) – It allows one to perform various operations on the database such as CREATE,
ALTER, and DELETE objects.
Data Manipulation Language(DML) – It allows one to access and manipulate data. It helps one to insert, update,
delete and retrieve data from the database.
OR
The list of identifiers used in a function call is called actual parameter (s) whereas the list of parameters used in
the function definition is called formal parameter.
Example :
def area (side) : # Line 1
return side * side;
print (area (5)) # Line 2

SECTION – C
26. (a) SELECT * FROM(
SELECT employee_name, salary, DENSE_RANK()
OVER(ORDER BY salary DESC)r FROM Employee) WHERE r = &n:
To find 3rd highest salary set n = 3
(b) (i) Deepak
(ii) 4
(iii) 004
(iv) 004 Fatima 92
COMPUTER SCIENCE |CLASS-12th | 3
27. def funCalc(a, b) :
return a+b, a–b, a*b, a/b, a%b
#__main__
num1= int (input (“Enter number 1 : ”) )
num2= int (input (“Enter number 2 : ”) )
add, sub, mult, div, mod= funCalc (num1, num2)
print (“Sum of given numbers : ”, add)
print (“Subtraction of given numbers : ”, sub)
print (“Product of given numbers : ”, mult)
print (“Division of given numbers : ”, div)
print (“Modulo of given numbers : ”, mod)

Output of above program is as shown below :


Enter number 1 : 13
Enter number 2 : 7
Sum of given numbers : 20
Subtraction of given numbers : 6
Product of given numbers : 91
Division of given numbers : 1.857142857
Modulo of given numbers : 6
OR
def octaltoothers ( n ) :
print (“Passed octal number :”, n )
numString = str (n)
dec = int (numString, 8)
print (“Numer in Decimal : ” , dec) )
print (“Numer in Binary : ”, bin (dec)
print (“Numer in Hexadecimal : ” , hex (dec) )
num1 = int (input (“Enter an octal number : ”) )
octaltoothers (num1)
Please recall that bin( ) and hex ( ) do not return numbers but return the string-representations of equivalent numbers in binary
and hexadecimal number system respectively.
28. (a) (i) Inner join : Inner Join in SQL is the most common type of join. It is used to return all the rows from multiple tables
where the join condition is satisfied.
(ii) Left Join : Left Join in SQL is used to return all the rows from the left table but only the matching rows from the right table
where the join condition is fulfilled.
(iii) Right Join : Right Join in SQL is used to return all the rows from the right table but only the matching rows from the left
table where the join condition is fulfilled.
(iv) Full Join : Full join returns all the records when there is a match in any of the tables. Therefore, it returns all the rows
from the left-hand side table and all the rows from the right-hand side table.
(b) Number, Decimal, Integer and Float type of numeric data type is possible in SQL.
4 DEEPAK CBSE Sample Papers

29. def divlist(nlist):


for number in nlist:
if number % 3 == 0:
print(number, end = ' ')
print()
num = [ 40, 45, 4 , 89, 75, 12, 56 ]
divlist(num)
30. PROGRAM for PUSH

R={"SCIENCE":101, "ENGLISH":102, "MATH":103,"COMPUTER":104, "SST":105}


def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in R:
if R[k]>=103:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break

Or
class Stack:
def __init__(self):
self.stack = []

def add(self, dataval):


# Use list append method to add element
if dataval not in self.stack:
self.stack.append(dataval)
return True
else:
return False
COMPUTER SCIENCE |CLASS-12th | 5

# Use list pop method to remove element


def remove(self):
if len(self.stack) <= 0:
return ("No element in the Stack")
else:
return self.stack.pop()

AStack = Stack()
AStack.add("Mon")
AStack.add("Tue")
AStack.add("Wed")
AStack.add("Thu")
print(AStack.remove())
print(AStack.remove())

SECTION – D
31. (a) Most suitable place to install the server is HR center, as this center has maximum number of computers.
(b)

(c) Switch
(d) Repeater may be placed when the distance between 2 buildings is more than 70 meter.
(e) WAN, as the given distance is more than the range of LAN and MAN.
32. (a) def VCount():
phr = 'Easy Coding'
vowel = 'aeiouAEIOU'
count = 0
for ch in phr:
if ch in 'aeiouAEIOU':
count = count + 1
else:
6 DEEPAK CBSE Sample Papers
pass
print(count)
VCount()
The above program will display the output 4
(b) (i) The above code will print the statement.
Total retrieved rows in resultset : 10.
(ii) Fetchall() will return all the rows from the resultset in the form of a tuple.
OR
(a) def Swap():
phr = 'rISE eveRY TimE'
for ch in phr:
if ch.isupper():
print(ch.lower(),end ='')
else:
print(ch.upper(),end='')
The above program will be display the output
Rise EVEry tIMe
(b) import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="sandeep",
password="123456",
database="School"
)
mycursor = mydb.cursor()
sql = “SELECT * FROM School WHERE grade =‘A’ ”
mycursor.execute(sql)
myresult = mycursor.fetchall()
for x in myresult :
print(x)
33. (i) def calcSum (x, y) :
s=x+y
return s
num1 = float (input (“Enter first number : ”) )
num2 = float (input (“Enter Second number : ”) )
sum = calcSum (num1, num2)
print (“Sum of two given numbers is”, sum)
(ii) def LWCount():
fob = open('MyPoem.txt','r')
txt = fob.read().split()
print(len(txt))
fob.close()
LWCount()
The output will be 7.
COMPUTER SCIENCE |CLASS-12th | 7
OR
(i) Literals are the data item which have a fixed value. String literal are always written in quotes (single or double)
(or triple quotes).
(a) Single Line String : Which quotes should be start and end same line are known as single literals.
(b) Multiline string : It took multiple lines to complete a statement. Multiple line string use \ (backslash) at the
end of each line.
(ii) Slice is a sub part of a string. In python string, we can obtain a sub-part by using t [n : m] where n, m is the
starting and ending position of a sub string and t is string.
For example :
'Welcome Sir' [2, 5] will give lcom.
34. (i) INSERT INTO student VALUES (777,‘‘Rahul Kumar’’, 12,‘‘A’’, 5500);
(ii) SELECT name FROM student WHERE class = 10;
(iii) SELECT name, class FROM student;
OR
(iii) SELECT * from student
where Name = ‘Nandini’ ;

35. (i) csv


(ii) 'a'
(iii) (a) reader
(b) close()
OR
(iii) (a) ['12001', 'Dam']
['13001', 'Hilly Transport']
(b) comma separated values
KKK

You might also like