NVS Preboard Marking Scheme - CS - 12
NVS Preboard Marking Scheme - CS - 12
SECTION A
1 Which of the following is valid arithmetic operator in Python: 1M
(i) // (ii) ? (iii) < (iv) and
Ans: (i)
2 Sushma gets the current date and time as a string x. Its value is 1M
"2021-10-30 12:49:44.216062".
Sushma prints the value of x[11:16] and gets "12:49". Which of these will
contain the date in yyyy-mm-dd format?
a. x[0:9]
b. x[0:10]
c. x[1:10]
d. x[1:11]
Ans: b
3 Which of these Python data structures cannot have duplicate items and does not 1M
support ordering?
a. list
b. tuple
c. dictionary
d. set
Ans: c
4 Consider a list a=[34,35,26,78,90,[12,13,14],[5,6,7],29,45] 1M
What is the output of a[-4][-2]?
a.90
b.5
c.13
d.12
Ans: c
5 Consider a list b=[90,85,89,78,3,5] 1M
b.insert(-1,7)
print(b)
a. [90,85,89,78,3,5,7]
b. [90,85,89,78,3,7,5]
c. [90,7,85,89,78,3,5]
d. [7,90,85,89,78,3,5]
Ans: b
6 Which output lines of the following program will print the same results? 1M
tup1 = (10, 20, 30, 40, 50, 60, 70, 80, 90)
print(tup1[5:-1]) # 1
print(tup1[5]) # 2
print(tup1[5:]) # 3
print(tup1[-4:8]) # 4
a. (1) and (2)
b. (1) and (4)
c. (2) and (3)
d. (1), (3) and (4)
Ans: b
7 Ms. Hetvee is working on a string program. She wants to display last four 1M
characters of a string object named s. Which of the following is statement is true?
a. s[4:]
b. s[:4]
c. s[-4:]
d. s[:-4]
Ans: c
8 Which of the following mode in file opening statement results or 1M
generates an error if the file does not exist?
(a) a+ (b) r+ (c) w+ (d) None of the above
Ans: b
9 A file customer.txt has been created. Now Which of the following function(s) can 1 M
be used to open the file in only reading mode?
Ans d
11 The RDBMS terminology for a row is 1M
(a) Tuple (b) relation (c) attribute (d) degree
Ans: a
12 1M
Ans: c
13 What does the ALTER TABLE clause do? 1M
a) The SQL ALTER TABLE clause modifies a table definition by altering,
adding, or deleting table columns and/or constraints
b) The SQL ALTER TABLE clause is used to insert data into database table
c) THE SQL ALTER TABLE deletes data from database table
d) The SQL ALTER TABLE clause is used to delete a database table
Ans: a
14 Which of the following command is used to change the rows that already exist in 1M
a table?
a) Insert.
b) Union.
c) Update.
d) Select
Ans: c
15 Fill in the blank: 1M
_________ is a non-key attribute, whose values are derived from the
primary key of some other table.
(a) Primary Key
(b) Foreign Key
(c) Candidate Key
(d) Alternate Key
Ans: b
16 FTP stand for_____________________ 1M
a)Foreign Transfer protocol b)Fiber Tech Protocol c)Fiber Transfer Protocol
d)File Transfer Protocol
Ans: d
Q17 and 18 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
17 Assertion A :An existing file is opened in the write mode the previous data will 1M
be erased.
Reasoning R: When the existing file is opened in write mode the file object will
be positioned at the end of the file.
Ans: c
ANS :
S.NO
. Star Topology Bus Topology
Ans:
L=[]
L1 = [20, 18, 16, 14, 12, 10, 8, 6]
(1 mark each for correct output)
22 Define the term cardinality and degree. 2M
Ans: Cardinality refers to the number of tuples/rows in a table whereas,
Degree refers to the number of attributes/columns in a table.
23 (a) Write the full forms of the following: 2M
(i) ARPANET (ii) SMTP
Advanced Research Projects Agency Network ( ½ mark )
SIMPLE MAIL TRANSFER PROTOCOL ( ½ mark )
(1 mark)
Ans: pYTHOnN#@
OR
Ans: (22,44,66)
( ½ mark for each correct digit , ½ mark for enclosing in parenthesis)
Table: Company
ITEMID COMPANYNAME
15 JACK JILL
16 AKAS FOOD
17 FOODIES
19 SIP N BITE
(b) Write the output of the queries (i) to (iv) based on the table, TECH_COURSE
given below:
ENO NAME DOJ DOB GENDER DCODE
Table:DEPT
Ans:
1. COUNT(*) DCODE
2 10
2. DISTINCT DEPARTMENT
AGRICULTURE
MINES
TPP
MECHANICAL
3. NAME DEPARTMENT
-
MISKA AGRICULTURE
AKSHAY MINES
4. MAX(DOJ) MIN(DOB)
2021/07/01 1997/11/15
(1/2 mark for each output)
27 Write a function in Python to read lines from a text file "notes.txt", to find and 3M
display the occurrence of the word "the".
Source Code
def count_words():
file = open("notes.txt","r")
count = 0
data = file.read()
words = data.split()
for word in words:
if word =="the" or word =="The":
count += 1
print(count)
file.close()
count_words()
( ½ mark for correctly opening and closing the file
½ for read()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)
OR
Write a function display_words() in python to read lines from a text file
"story.txt", and display those words, which are less than 4 characters.
Source Code
def display_words():
file = open("poem.txt","r")
data = file.read()
words = data.split()
for word in words:
if len(word) < 4:
print(word, end=" ")
file.close()
display_words()
( ½ mark for correctly opening and closing the file
½ for read()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)
28 Consider the table given below: Table Faculty
TEACHER PHONE
NAME ADDRESS STATE
ID NUMBER
TABLE: COURSE
COURSEID SUBJECT TEACHERID FEE
i. With reference to the above given tables, write commands in SQL for (i)
and (ii) and output for (iii) :
o (i) select courseid, teacherid, name, phonenumber from course c,
faculty f where c.teacherid=f.teacherid and address like
Ans:
i.
courseid Teacherid Name Phoneno
1002 T004 Minaxi 9012547863
ii. No Records
iii.
Courseid Subject Teacherid Name Phonenumber
Computer Avinash 9825741256
1001 T001
Science
iv. Query ok 2 records updated.
Using of any correct code giving the same result is also accepted
1. Push the keys (name of the student) of the dictionary into a stack, where
the corresponding value (marks) is greater than 70.
2. Pop and display the content of the stack.
Ans:
def push(stk,item):
stk.append(item)
def Pop(stk):
if stk==[]:
return None
else:
return stk.pop()
stk=[]
d={"Ramesh":58, "Umesh":78, "Vishal":90, "Khushi":60, "Ishika":95}
for i in d:
if d[i]>70:
push(stk,i)
while True:
if stk!=[]:
print(Pop(stk),end=" ")
else:
break
OR
Ans:
def AddPlayer(player):
pn=input("enter player name:")
player.append(pn)
def DeletePlayer(player):
if player==[]:
print("No player found")
else:
return player.pop()
SECTION D
31 G.R.K International Inc. is planning to connect its Bengaluru Office Setup with 5M
its Head Office in Delhi. The Bengaluru Office G.R.K. international Inc. is
spread across and area of approx. 1 square kilometer, consisting of 3 blocks
Human Resources, Academics and Administration.
You as a network expert have to suggest answers to the four queries (i) to (iv)
raised by them.
Notes : Keep the distance between blocks and number of computers in each block
in mind, while providing them the solutions.
1. Suggest the most suitable block in the Bengaluru Office Setup, to
host the server.
Give a suitable reason with your suggestion.
2. Suggest the cable layout among the various blocks within the
Bengaluru Office Setup for connecting the Blocks.
3. Suggest a suitable networking device to be installed in each of the
blocks essentially required for connecting computers inside the
blocks with fast and efficient connectivity.
4. Suggest the most suitable media to provide secure, fast and reliable
data connectivity between Delhi Head Office and the Bengaluru
Office Setup. 1M
5. Suggest a device/software to be installed in the Begaluru Campus
to take care of data security.
Ans:
1M
1M
1M
3. Switch /Hub
4. Satellite link
5. Firewall
32 What are the possible outcome(s) executed from the following code? Also, 5
specify the maximum and import random.
PICK=random.randint (0,3)
CITY= ["DELHI", "MUMBAI", "CHENNAI", "KOLKATA"];
for I in CITY :
for J in range (1, PICK)
print (I, end = " ")
print ()
(i) (ii)
DELHIDELHI DELHI
MUMBAIMUMBAI DELHIMUMBAI
CHENNAICHENNAI DELHIMUMBAICEHNNAI
KOLKATAKOLKATA
(iii) (iv)
DELHI DELHI
MUMBAI MUMBAIMUMBAI
CHENNAI KOLKATAKOLKATAKOLKATA
KOLKATA
b. A resultset is extracted from the Customer table using the cursor object (that
has been already created) by giving the following statement.
Rec_Data=cursor.fetchall()
(a) How many records of the table will be returned by fetchall() method? 1M
(b) What will be the datatype of Rec_Data object after the given command is
executed?
Ans. (a) In case the table has records then all the records will be returned as a list 1M
of tuples, otherwise it will return an empty list.
(b) List of tuples
OR
Ans: 15
Consider the table : IPL2022 in which Tina wants to fetch rows. For this she
wrote a program in which some code is missing. Help her to complete the
following code.
import ______________ as ms #line1
cn=ms.connect(host='localhost',user='root',passwd='root',database='IPL') 2M
cr=_______________ #line2
cr._______("seleect * from IPL2022") #line3
r=cr.fetchall()
for i in r:
print(i)
cn.close()
Answer:
1M
import mysql.connector as ms #line1
cn=ms.connect(host='localhost',user='root',passwd='root',database='IPL') 1M
cr=cn.cursor() #line2 1M
cr.execute("seleect * from IPL2022") #line3
r=cr.fetchall()
for i in r:
print(i)
cn.close()
33 5
separated by comma. It should have header row and then take in input from the (3+2
user for all following rows. The format of the file should be as shown if user )M
enters 2 records.
Roll.No,Name,Marks
20,ronit,67
56,nihir,69
Ans: 3M
import csv
w1=csv.writer(f1,delimiter = ",")
w1.writerow(['Roll.No', 'Name', 'Marks'])
while True:
print ("Enter 1 to continue adding, 0 to exit")
op = int(input("Enter Option"))
if (op == 1):
rollno = int(input("Enter Roll No"))
name = input("Enter Name")
marks = int(input("Enter Marks"))
wlist = [rollno,name,marks]
w1.writerow(wlist)
elif op == 0:
break;
f1.close()
b. Ans.
2M
writer.writerow(row): Write the row parameter to the
formatted according to delimiter defined in writer function
e.g.
import csv
f1.close()
f1.close()
OR
a.
only those students who scored more than 80 marks. Records stored in students is 3M
in format : Rollno, Name, Marks.
Ans:
import csv
f=open("student.csv","r")
d=csv.reader(f)
next(f)
print("Students Scored More than 80")
print()
for i in d:
if int(i[2])>80:
print("Roll Number =", i[0]) 2M
print("Name =", i[1])
print("Marks=", i[2])
f.close( )
b. What is full form of CSV? Write two advantages.
Ans: CSV (Comma Separated Values)
Advantages of CSV:
CSV is faster to handle
CSV is smaller in size and is easy to generate
CSV is human readable and easy to edit manually
CSV is simple to implement and parse
CSV is processed by almost all existing applications
SECTION E
34 Consider the following tables Supplier and Consumer. Write SQL commands for 4M
the statements (a) to (d).
(a) To display the C_ID, Supplier name, Supplier Address, Consumer Name and
Consumer Address for every Consumer
(b) To display Consumer details in ascending order of CName
(c) To display number of Consumers from each city
Ans:
a. Select C_ID, S.SupplierName, S.SupplierAddress, C.CName,
C.CAddress from Supplier S, Consumer C where 1M
C.SupplierID=S.SupplierID;
b. Select * from Consumer order by CName; 1M
c. select Ccity, count(*) from Consumer group by Ccity; 1M
d. Select * from Supplier where SupplierCit 1M
OR
a) Observe the following table Product and answer the parts(i) and(ii)
accordingly
Table: Product
(i) Write the names of most appropriate columns, which can be considered as
candidate keys.
(ii) What is the degree and cardinality of the above table?
1M
ANS :
b) Table Employee has 4 records and Table Dept has 3 records in it. Mr. Jain
wants to display all information stored in both of these related tables. He
forgot to specify equi-join condition in the query. How many rows will
get displayed on execution of this query?
ANS : 12 ROWS because it generates a cross join as the output
1M
35 4M
i.A user defined function CreateFile() is created to input data for a
record and add to Book.dat .
ii. A function CountRec(Author) is created in Python which accepts the
Author name as parameter and count and return number of books by the
given Author are stored in the binary file
Observe and complete the following code based on the requirement given above: