0% found this document useful (0 votes)
7 views5 pages

CS - Self Assessment Paper-5-Solution

This document contains solutions for a self-assessment paper in Computer Science, covering various topics such as Python programming, SQL, and computer networks. It includes multiple-choice questions with explanations, programming tasks, and common errors made by students. The solutions are structured in sections and provide insights into key concepts and coding practices.

Uploaded by

pratimashaw090
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

CS - Self Assessment Paper-5-Solution

This document contains solutions for a self-assessment paper in Computer Science, covering various topics such as Python programming, SQL, and computer networks. It includes multiple-choice questions with explanations, programming tasks, and common errors made by students. The solutions are structured in sections and provide insights into key concepts and coding practices.

Uploaded by

pratimashaw090
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SOLUTIONS

Self Assessment Paper-5


COMPUTER SCIENCE

Section – A 9. Option (A) is correct.


Explanation: The Python lists are containers that
are used to store a list of values of any type. A list
1. True 1
is a standard data type of Python that can store a
2. Option (A) is correct. sequence of values belonging to any type. The
Explanation: Overflow is the condition in which values that make up a list are called its elements,
there is no memory left to accommodate a new item and they can be of any type which means list can
in a fixed size stack. 1 contain values of mixed data types. The lists are
enclosed within square brackets. 1
3. Option (C) is correct.
Explanation: There are two looping constructs in
10. Option (D) is correct.
Python - for and while. 1 Explanation: executemany() is like simple iteration
that provides a repetitive execution of INSERT and
4. Option (B) is correct. UPDATE across multiple rows 1
Explanation: F.readlines() will read the contents of
11. Option (D) is correct.
the text file as a list, where each element of the list is
a line of the file. Now for loop will iterate over each
Explanation: Each line of a text file is terminated a
element of this list(each line of the text file) and split special character called EOL (End of line) when a
it into words and store as elements of list S (here text editor or a program interpreter encounters the
each word of the line forms an element of the list ASCII equivalent of the EOL character 1
S). print statement will print length of this list. So in 12. Option (A) is correct.
first iteration length of first line i.e 3 will be printed

Explanation: The INNER JOIN keyword will create
and in second iteration length of second line 4 will
the result-set by combining all rows from both the
be printed. 1
tables where the condition satisfies i.e value of the
5. Option (B) is correct.
common field will be same. 1
Explanation: if a==b: will check if a is equal to b.

If statement allows branch depending upon the 13. Option (C) is correct.
value or state of variables. If the condition evaluates
Explanation: A router is a device that provides Wi-
true, an action is followed otherwise, the action is Fi and is typically connected to a modem.
ignored. 1 It sends information from the internet to personal
6. Option (A) is correct. devices like computers, phones, and tablets. These
Explanation: In Python, dictionary is an unordered internet-connected devices in your home make up
collection of data values that stored the key: value your Local Area Network (LAN). 1
pair instead of single value as an element. Keys of
a dictionary must be unique and of immutable data
14. Option (C) is correct.
Explanation: The square brackets [ ] are used to
types such as strings, type etc.
enclose the items of the list 1
Syntax
dictionary name = {key 1 : value 1, key 2 : value 2,
15. Option (D) is correct.
Explanation: If an aggregate function is executed
...} 1
against a column that contains nulls, then the
7. Option (A) is correct. function ignores it. This prevents unknown or
Explanation: Functions defined in math module are inapplicable values from affecting the result of the
used to perform mathematical calculations such as aggregate function. 1
sqrt(),cos(), etc. 1
16. Option (C) is correct.
8. Option (D) is correct. Explanation: The SQL MIN() function is used to
Explanation: A COMMIT means that the changes return the minimum value of an expression in
made in the current transaction are made a SELECT statement. E.g. SELECT MIN(per) AS
permanent and become visible to other sessions. 1 “Lowest Percentage” FROM student. The above
2 OSWAAL CBSE Sample Question Papers, COMPUTER SCIENCE, Class-XII

statement will return the minimum value of 21. (a) Greater than 10. 2
percentage from column PER in STUDENT table. 1 (b) 10
17. Option (D) is correct.

Explanation: Using append(), only one element at Commonly Made Error
a time can be added. For adding more than one
element, extend() method can be used, this can Sometimes students forget the correct execution
of if statement.
also be used to add elements of another list to the
existing one.
The extend( ) function accepts a list as an argument
Answering Tip
and puts the elements of the list at the end of the
Students should remember the correct working
sequence .
and execution of all conditional and iterative
Example: statements.
>>> a = [10,20,30,40,50]
22. The hierarchical model was developed by IBM in
>>>a.extend([60,70,80])
1968. The data is organised in a tree structure where
>>>a the nodes represent the records and the branches
[10,20,30,40,50,60,70,80] 1 of the tree represent the fields. Since the data is
18. Option (B) is correct. organized in a tree structure, the parent node has
the links to its child nodes.

Explanation: A list can have elements of different

If we want to search a record, we have to traverse
data types, such as integer, float, string, tuple or
the tree from the root through all its parent nodes
even another list. A list is very useful to group
to reach the specific record. Thus, searching for a
together elements of mixed data types.
record is very time consuming 2
Elements of a list are enclosed in square brackets
23. (a) Refresh (F5 key) (1 mark for correct answer)
and are separated by comma. Like string indices,
(b) Web hosting is the service that makes our website
list indices also start from 0. 1
available to be viewed by others on the Internet.

A web host provides space on its server, so that
Section – B other computers around the world can access our
website by means of a network or modem.
19. for i in range(10): (1 marks for correct answer)
_b=20–i 24. True 2
print(b) 2 OR
20. The world wide web (WWW) is a network of online 10.0 # 10.0
content that is formatted in HTML and accessed via 10.0 $ 20
HTTP. The term www refers to all the interlinked 2.0 # 2.0
HTML pages that can be accessed over the Internet. 1.0 # 1.0

The world wide web is an example of client and 1.0 $ 2.0
server technology. The Internet uses software
known as the web browser that requests documents 25. A Candidate Key can be any column or a
combination of columns that can qualify as
located on the web. The request is made by the
unique key in database. There can be multiple
browser to the internet host server containing the
Candidate Keys in one table where as A Primary
document. The browser acts like a host server the
Key is a column or a combination of columns
information and thus, is called the server. 2
that uniquely identify a record.
OR
Only one Candidate Key can be Primary Key.

A computer network is a set of computers sharing
 (2 marks for correct difference)
resources located on or provided by network nodes.
OR
The computers use common communication
protocols over digital interconnections to Degree: It is the total number of attributes in the
table.
communicate with each other.

XML – exensible Cardinality: It is the total number of tuples in
the table (2 marks for correct difference)
Markup
 [CBSE Marking Scheme, 2019-20]
Language
Solutions 3

Section – C (iv) COUNT (*)


2 5000
SUM (AMOUNT)
3

26.
(a) CREATE DATABASE MYEARTH; 29. def prime(n):
CREATE TABLE CITY for i in range (2,n/2):
if 0 n%i==0:
(
print(n,"is not prime")
CITYCODE CHAR (5) PRIMARY KEY,
return 3
CITYNAME CHAR (30),
SIZE INT,
30.
status=[]
def Push_element(cust):
AVGTEMP ITN,
if cust[2]=="Goa":
POPULATIONATE INT,
L1=[cust[0],cust[1]]
POPULATION INT;
status.append(L1)
(1 mark correctly creating the table)
def Pop_element ():
(b) (i) 29
num=len(status)
(ii) 01-Jan-2021
while len(status)!=0:
(iii) T006 Console Table 17-Nov-2019 1500 12
(iv) 10-Mar-2020 dele=status.pop()
17-Nov-2019 print(dele)
(½ mark for each correct output) num=num-1
[CBSE Marking Scheme, 2021-22] else:
print("Stack Empty")
27. def CountFirstDigit(): (1.5 marks for correct push_element() and 1.5 marks for
count=0 correct pop_element())
with open(‘Story.txt’,‘r’) as f: OR
while True: def COUNTLINES():
line=f.readline() file=open('Hello.TXT','r')
if not line:
lines = file.readlines()
break
count=0
if line[0].isdigit():
count = count+1 for w in lines:
if count==0: if w[0]=="AN" or w[0]=="an":
print (“no line starts count=count+1
with a digit”) print("Total lines starting with
else: 'AN'", count)
print (“count=”,count) file.close()
(3 marks for correct answer) (1 mark for each correct 1st & 2nd function definition)
OR (1 marks for correct 3rd function definition)
def reverse():
file=open("Poem.txt","r")
text=file.readlines()
Section – D
file.close()
line=len(text) 31.
(i) Block C , It has maximum number of
for i in range (line-1,-1,-1): computers.
print(text[i])  (1 mark for correct answer )
28. (a) DEGREE =5  [CBSE Marking Scheme, 2020]
CARDINALITY=6 (ii) LAN. Because network spans over a
(b) (i) ANO ANAME building. (1 mark for correct answer )
103 Ali Reza  [CBSE Marking Scheme, 2020]
105 Simran Kaur (iii) Star topology
(ii) DISTINCT ANO
101
102 Block A
103 Block D
Block C
Note: Values may be written in any order
(iii) ANO Count(*) MIN (AMOUNT)
101 2 2500 Block B
103 2 1000
 (1 mark for correct answer )
4 OSWAAL CBSE Sample Question Papers, COMPUTER SCIENCE, Class-XII

(iv) Ethernet Cable if SORTEDLIST[mid]==number:


(v)  Ethernet cables are used to provide an print ("Number found at",mid)
internet connection and connect devices to a found=True
local network.
break
 (1 mark for each correct answer)
elif SORTEDLIST[mid]<number:
32. (a) Output
1 20 P$ low=mid+1
4 30 P$R$ else:
9 60 P$R$S$ high=mid -1
(b) import MySQLdb if low >= high:
db=MySQLdb.connect(‘localhost’, ‘salesman1’, print ("Number not found")
‘sale1’, ‘Sales’)
maxrange = input("Enter Count of
cursor=db.cursor(prepared=TRUE) numbers: ")
sql_query=”””INSERT INTO Orders (ORDNUMB, numlist =[]
CUSTNO, ORDDTE) VALUES (‘%s’, ‘%s’, ‘%s’)”””
for i in range(0, maxrange):
rec_inst=[(‘12489’, ‘124’, ’01-03-98’), (‘12491’,
‘311’, ’10-03-98’), (‘12495’, ‘315’, ’31-03-98’), numlist.append(input("?"))
(‘12498’, ‘522’, ’10-04-98’)] numlist.sort()
try: print ("Sorted list",numlist)
cursor.executemany(sql_query, rec_inst) number = input("Enter the number")
print(cursor.rowcount, “Records inserted binary_search(numlist,number)
successfully”) OR
db.commit() (i) It is a convenient way to deal with large quantities
except: of data.
db.rollback() (ii) To avoid input of data multiple times during
cursor.close() program execution.
db.close() (1 mark for correct db value) (1 mark for (1 mark for each correct need)
correct sql_query)
PROGRAM
 (1 mark for correct try & except)
def athletics( ):
OR
file1 = open (“sports.dat”,’r’)
(a) (‘Python’,)
file2 = open (“Athletics.dat”,’w’)
1
3 (2 marks) rec = file1.readlne ()
(b) import MySQLdb while rec! = “ “:
db=MySQLdb.connect(‘localhost’, ‘Admin’, sport = rec.split(`n`)
‘SalA345’, ‘sales’) if sport[0] == “Athletics”:
cursor=db.cursor() file2.write (rec)
sql=”””UPDATE OrderDetails set file2.write (`\n’)
NUMBORD=NUMBORD+5 where QUOTPRIC
else:
<’%d’ OR NUMBORD> ‘%d’”””
check_value = (100,3) pass
try: rec = file1.readlne ()
db.execute(sql, check_value) file1.close()
db.commit() file2.close()
except: return (5 marks for Correct program)
db.rollback()
db.close() (1 mark for correct db value)
 (1 mark for correct insert_query) Commonly Made Error
 (1 mark for correct try & except)
Indentation is missing while programming by
33.
def binary_search(SORTEDLIST, number): some students.
low=0
high=len(SORTEDLIST) Answering Tip
found=False
while(low<high) and found==False: Indentation must be taken care of and should
mid=(int)(low+high)/2 be checked on completion of the code.
Solutions 5

Section – E OR
(iii) (a) SELECT DISTINCT DESIGNATION FROM
ADMIN; (1 mark)
34. (i) (i)CODE is primary key (b) SELECT TEACHERNAME, CODE, DESIGNATION
[1 mark for correct answer] FROM SCHOOL, ADMIN WHERE SCHOOL.
(ii) TEACHERNAME is alternative key CODE = ADMIN.CODE AND GENDER = MALE;
(1 mark for correct answer) (1 mark for each correct output)
(iii) (a) SELECT TEACHERNAME, PERIODS FROM
SCHOOL WHERE PERIODS >25;
35. (i) csv
(b) SELECT * FROM SCHOOL ORDER BY (ii) “Student.csv”, "w"
EXPERIENCE DESC; (2 marks) (iii) writer(fh). (1×4=4)
qqq

You might also like