Professional Documents
Culture Documents
12 - CS - Set 05 - Ak
12 - CS - Set 05 - Ak
General Instructions:
5. Section C, consi sts of 5 questions (26 to 30). Each question carries 3 Marks.
7. Section E, consists of3 questions (33 to 35). Each question carries 5 Marks.
Section A output of
p r i n t ( s [ 2 ] + s [ 8 ] + s [ l : 5 1 ) ?
(a) UPDATE
Sol:
(b) CHANGE
(cl) MODIFY
6. State True or False
Sol:
Digits are one of the parts of the Python character
Sol:
2. Which of the following operator cannot be used
(a) + (b) in
7. The clause to arrange the data of a colu11111 in
(c) * (cl) I
descending order is
Sol :
(a) DESC (b) GROUP BY
Sol:
3. Which of the following is a category of SQL
Sol :
(a) Keywords (b) Literals
Sol :
4. What is the output of the following code?
Sol:
(c) CSV files (cl) All of these
(a) nun1=7.5
Sol:
Page 2 Sample Paper 1 Computer Science Class 12
(a) Binary files 15. Which of the following functions will read lines of
(cl) reacllines( )
for 1 in range ( 1, 6, 1 ) :
if (value% mul - 0 ) :
Sol:
print (value* multiply)
(cl) reacllines( )
else
Sol :
Sol :
(c) 4,5,6,7
(b) 90
product.
12. The clause with the COUNT() function
(a) Both A and R are true and R is the correct
counts only the unique values in an attribute.
explanation for A.
(a) UNIQUE
(b) HAVING (b) Both A and R are true but R is not the
(b) SQL.connect library 18. Assertion (A) A file that is opened using the
(cl) Telnet
Sol:
Sol:
(b) Both A and Rare true but R is not the correct
as follows
(i) 'Workl' (ii) 'Hello'
Internet Intranet
or advertisement. proprietary.
Output
( i ) L [ 3 : 5 ] (ii) L I : · - 2J
or
Ll - [ 7, 2, 3, 4 J
Sol:
L2 - Ll + 2
L - L 1 . pop I 7 )
Tuple List
immutable. mutable.
(a) (i) [77, 10] (ii) [2, 10, 45, 10]
index range. 25. Explain the concept of candidate keys with the
Sol:
Sol :
trains.
Table : Item
101 CD 10
(i) Display passenger names 1
corresponding
In the Item table, INO and fName can be treated (iii) Display a cross join of the two tables.
or travelling by "Rajdhani".
which can be considered as (i) candidate keys and (a) SELECT T r . Pname, T . Tname FROM
A m t - Am t + Am t * 0 . 2 WHERE Class-
011 BRETT 105000 AUSTRALIA BAT
"AC";
LEE
below.
Write a program in Python to open the Binary
Sol:
1 R.ahul AC Tl 2500
import pickle
2 Sujit SL T2 4500
f=open ( " e m p . d a t " , "rb")
try:
4 Ankita AC T3 1800
lst-pickle.load(f)
lst[2J I
T2 Himgiri Exp
except EOFError:
break
Write the command to display the passenger
f .close ( I
names and the train names by which they are
or
travelling for all passengers travelling by "Mail"
Page 5 Sample Paper 1 Computer Science Class 12
Tenn.in us
The output will be:
ND48 ND50 S Tripathi 13, Bl D, New
The status file contents are
Mayur Delhi
Total lines in file are: 4
Vihar
Sol : Mumbai.
order of Reclvame.
blankspaces=total lines=O
each City.
are")
"KOLKATA".
if not aline:
break Sol :
else:
(a) (i) SELECT SenderName FROM SENDER
total lines=total lines+!
WHERE SenderCity - 'Mumbai';
aline=aline.rstrip()
(ii) SELECT RecID, SenderName,
for i in aline:
SenderAddress, RecName,
if i.isspace() ·
RecAddress
blankspaces=blankspaces+l
FROM RECIPIENT, SENDER WHERE
print("Total lines in file are:
RECIPIENT.SenderlD SENDER.
%d'' %total lines)
Sender I D ;
print("Total space in file are:
(iii) S E L E C T *FROM RECIPIENT ORDER
%d'' % blankspaces)
BY RecName;
fob. c l o s e I )
(iv) S E L E C T COUNT ( * ) AS "No. of
else:
Recipients", RecCity FROM
print("File does not exist")
RECIPIENT GROUP BY RecCity;
28. (a) Consider the following tables SENDER and (b) SELECT SenderName, RecName
L-append(b)
i-0
for a in L:
s-0 Section D
while a>O:
campus.
30. Write Push (contents) and Pop() methods in
As a network expert, you need to suggest the
Python to add numbers and remove numbers
network plan as per (i) to (v) to the authorities
considering them to act as Push and Pop
keeping in mind the distance and other given
operations of stack.
parameters.
Sol :
/ / Freshminds
def Push (contents):
University
if(len(stack) > - l i m i t ) ·
Kolkata
Admission
Ana Naga, II �c· 11
Campus
print("Stack O v e r fl o w ! " ) Office
else : Office
Block
stack.append (contents) 1 1 1 1
Science
print ("Stack after Push", stack)
Block 11
11
def Pop ( I :
else :
Office Block to Commerce Block 80 Ill
return stack.Pop( I
Science Block to Oornmerce Block 15 lll
or
Kolkata Admission Office to Ana Nagar 450 kin
Find the final contents of a stack on which the
Campus
2. Push(200)
Office Block 10
3. Push(50)
Science Block 140
4. Push(50)
Commerce Block 30
: " ) )
(iii) Suggest an efficient device from the following
a = x + y +
z
to be installed in each of the block to connect
mycon = mysql.connector.connect (
(iv) Suggest a suitable topology to connect the
h o s t = "local host",
computers in each building.
u s e r = "root",
(v) University is planning to connect its campus
passwd = "system",
in Kolkata which is 111ore than 100 kin. VVhich
database= "School")
type of network will be formed?
cursor= mycon.cursor( )
Sol :
d b = cursor .execute
LastName varchar(30),
Address varchar(50),
ContactNo varchar(20)
Office
Marks Float,
Block Science Block
Course char(20),
(ii) The most suitable place to house the server , 'Best', 'Bad', 'Worst', 'Average'))))
and increases efficiency of network. (a) Differentiate between a logical error and
(iii) (b) Switch is the device to be installed in each syntax error. Also, give suitable examples of
(iv) Star topology, as it is the best in efficiency. (b) What is the use of fetchone() method? Write
(v) vVAN (Wide Area Net,vork) will be formed. an example code to fetch a single record from
a database.
32. (a) Underline the syntax errors in the following
Note:
program
Database : PythonDB
x = int ( i n p u t ( " E n t e r first number:))
Table : Student
y = i n t ( i n p u t ( " E n t e r second n u m b e r : " ) )
Host : localhost
z = int(input("Enter third n u mb e r : " )
UsedlD : root
a = x+ b+ z
Password : arihant
print ("Result = ", b)
Student with the following fields (a) Differences between logical error and syntax
First.Name
Logical Error Syntax Error
Last Name
Address
. .
Sol: code IS syntactically the code IS not
wl = csv.writer(f2)
It produces the output, It does not produce
for row in rl :
but undesired. any output.
wl.writerow(row)
- a if by ( a = = b); if by mistake
(c -
* b); f2.close()
(b) fetchone() returns the next row from the rl - csv.reader(fl, delimiter=
c o n = mysql.connector.connect wl.writerow(row)
u s e r = "root", f 2 . close ( )
- "PythonDB") convertcsv ( )
cursor= con.cursor() or
RollNo, Address, Percentage from program to perform the following using functions
Student") as follows :
(b) copyselected() :
33. Which module is used to operate on CSV file?
The CSV file "marks.csv" which has name,
Write a python program with following functions
class and marks separated by comma. Write
Sol :
csv" which has data for all branches. Write
A file old. csv has come with separator ' : " but import csv
your system can only read ' ; ' Write a program def copytocsv() ·
writer= csv.writer(file)
Sol :
with open ( ' m a r k s . c s v ' ) as csvfile:
To read and write in CSV files we need to import
data= csv.reader(csvfile)
csv module.
for row in data:
Program:
writer.writeraw(row[O],
import csv
row [ 1 J J )
def addcsv() ·
file. close ( )
fl - open("old.csv", 'r')
def copyselected() ·
f2 - open("updated.csv", 'a',
fi l e = open ( ' c l a s s . c s v ' , 'w'
'
newline= "\n")
newline= "\n")
rl - csv.reader(fl)
wl - csv.writer(file)
Page 9 Sample Paper 1 Computer Science Class 12
copytocsv ( I f .close ( I
Section E Sol :
(i) words
34. Consider the following table Person
(ii) words[D]
10
END
3 Pettersen Keri Storgt 20 Stavanger
column?
be its degree?
have a address.
following :
Sol :
Person;
or
(a) floatydecimal/double
35. The code given below reads a text file and displays
f=open("emp.txt")
count=O