0% found this document useful (0 votes)
25 views9 pages

Cs SQP 5.1

The document is a sample question paper for Computer Science Class 12, consisting of 35 questions divided into five sections with varying marks. It includes questions on Python programming, SQL commands, and concepts related to databases and networking. The paper is designed for the academic year 2023-24 and has specific instructions for answering programming questions using Python only.

Uploaded by

Adu
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)
25 views9 pages

Cs SQP 5.1

The document is a sample question paper for Computer Science Class 12, consisting of 35 questions divided into five sections with varying marks. It includes questions on Python programming, SQL commands, and concepts related to databases and networking. The paper is designed for the academic year 2023-24 and has specific instructions for answering programming questions using Python only.

Uploaded by

Adu
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/ 9

Page 1 Sample Paper 1 Computer Science Class 12

Sample Paper 5 Solutions


Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

5. Given : s= “ComputerExam”. What will be the


Section A output of
print(s[2]+s[8]+s[1:51)?
1. _____command modifies or change the existing (a) mEOMUU (b) mEompu
records in a table. (c) mEomPU (d) MEompu
(a) UPDATE
Sol :
(b) CHANGE
(c) ALTER (b) mEompu
(d) MODIFY
6. State True or False
Sol : Digits are one of the parts of the Python character
(a) UPDATE set
Sol :
2. Which of the following operator cannot be used
with string data type? True
(a) + (b) in
(c) * (d) / 7. The clause to arrange the data of a column in
descending order is
Sol : (a) DESC (b) GROUP BY
(d) / (c) LIKE (d) ASC
Sol :
3. Which of the following is a category of SQL
commands? (a) DESC
(a) DDL (b) TCL
(c) DML (d) All of these 8. Which of the following are the most obvious kind
of constants?
Sol : (a) Keywords (b) Literals
(d) All of these (c) Variables (d) Identifiers
Sol :
4. What is the output of the following code?
num = 4 + float (7)/int (2.0) (b) Literals
print (“num =”, num)
(a) num = 7.5 (b) 7.5 9. Which of the following types of files will need the
(c) num : 7.5 (d) Error pickle module for working on it ?
(a) Binary files (b) Text files
Sol : (c) CSV files (d) All of these
(a) num=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
a text file as list elements.
10. In the following code, which lines will give error? (a) read( )
(Assume the lines are numbered starting from 1.)
(b) get()
mul=3
value=10 (c) readline( )
for i in range (1, 6, 1): (d) readlines( )
if (value % mul = 0): Sol :
print (value * multiply)
else (d) readlines( )
print (value + multiply)
16. Which of the following will be the output of the
(a) 4,5
statement given below?
(b) 4,5,6
print([12,34,56,78,90].pop())
(c) 4,5,6,7
(a) 78 (b) 90
(d) No errors
(c) 12 (d) 12,34,56,78,90
Sol :
Sol :
(c) 4,5,6,7
(b) 90
11. There can be____foreign keys in a relation.
Direction (Q.Nos. 17-18) are Assertion and
(a) 2 (b) 3
Reason based questions.
(c) 1 (d) Multiple
Sol : 17. Assertion (A) In a cross join the number of records
in the output will be the maximum.
(d) Multiple
Reason (R) A cross join is also called a Cartesian
12. The_____clause with the COUNT() function product.
counts only the unique values in an attribute. (a) Both A and R are true and R is the correct
(a) UNIQUE explanation for A.
(b) HAVING (b) Both A and R are true but R is not the
(c) DISTINCT correct explanation for A.
(d) LIKE (c) A is true but R is false.
Sol : (d) A is false but R is true.
(c) DISTINCT Sol :

13. User can write Python script using (b) Both A and R are true but R is not the correct
(a) MySQL.connector library explanation for A.

(b) SQL.connect library 18. Assertion (A) A file that is opened using the
(c) MySQL.connect library open() function may not specify the mode of
opening it.
(d) None of these Reason (R) If the mode is not specified , the read
mode is used by default..
Sol :
(a) Both A and R are true and R is the correct
(a) MySQL.connector library explanation for A.
14. _____is a protocol used for remote login. (b) Both A and R are true but R is not the
(a) HTIT correct explanation for A.
(b) PPP (c) A is true but R is false.
(c) IRCP (d) A is false but R is true.
(d) Telnet
Sol :
Sol :
(b) Both A and R are true but R is not the correct
(d) Telnet explanation for A.
Page 3 Sample Paper 1 Computer Science Class 12

Section B 23. (a) Write the full forms of :


(i) POP (ii) HTTP
(b) Differentiate between the terms Internet and
19. Observe the given list and find the answer of
Intranet.
questions that follows.
list1 = [23, 45, 63, ‘Hello’, 20 Sol :
‘World’, 15, 18] (a) (i) Post Office Protocol.
(i) list1[–3] (ii) list1[3] (ii) HyperText Transfer Protocol
Sol : (b) Differences between Internet and Intranet are
as follows
(i) ‘World’ (ii) ‘Hello’
Internet Intranet
20. What is the advantage of using switch over hub?
Access by an individual Access by only
Sol : with dial-up access. authorised employees.
Switch provides a dedicated line at full bandwidth Information on Information on
between two devices but hub doesn’t provide a Internet could be Intranet could be
dedicated line. Hub share the bandwidth. general, public and specific, corporate and
or advertisement. proprietary.
Write some benefits of networking.
24. Predict the output
Sol :
dic = {‘a’:1, ‘b’:2, ‘c’:3, ‘d’:4}
Some of the benefits of networking are print(dic)
(i) File sharing if ‘a’ in dic :
(ii) Hardware sharing del dic[‘a’]
(iii) Application sharing print(dic)
(iv) User communication
Sol :
(v) Access to remote database
Output
21. (a) Find the output {‘d’ : 4, ‘a’ : 1, ‘c’ : 3, ‘b’ : 2}
L = [10, 19, 45, 77, 10, 22, 2] {‘d’ : 4, ‘c’ : 3, ‘b’ : 2}
(i) L [3 : 5] (ii) L [: : –2] or
(b) Find the error(s). Distinguish between tuple and list.
L1 = [7, 2, 3, 4]
L2 = L1 + 2 Sol :
L3 = L1 * 2 Differences between tuple and list are as follows
L = L1.pop(7) Tuple List
Sol : Elements of a tuple are Elements of a list are
immutable. mutable.
(a) (i) [77, 10] (ii) [2, 10, 45, 10]
Tuple is declared in List is declared in square
(b) Error 1 L2 = L1 + 2 because + operator
parenthesis 0. brackets .
cannot add list with other type as number or
Tuples cannot be changed Lists can be changed after
string. after creation. creation.
Error 2 L = L1.pop(7) parentheses puts index
Iterating over the elements Iterating over the elements
value instead of element. In the given list, of a tuple is fast. of a list is slow.
maximum index value is 3 and 7 is out of
index range. 25. Explain the concept of candidate keys with the
help of an appropriate example.
22. What do you understand by RDMS?
Sol :
Sol :
A candidate key is a set of one or more fields that
A Relational Database Management System identifies each record uniquely in a table. There
(RDBMS) is a database management system. It can be multiple candidate keys in one table and
is developed by Dr. E.F. Codd, of IBM’s SAN one of them will become the primary key.
Jose Research Laboratory. e.g.
Page 4 Sample Paper 1 Computer Science Class 12

Table : Item trains.


(b) Considering the tables Train and Travel given
INO IName Qty
above write commands for the following :
101 CD 10 (i) Display passenger names , corresponding
102 Pen 5 train names and amounts for records
where amount >5000.
103 Pencil 2
(ii) Increase amount of passengers by 20%
104 Eraser 3 who are travelling by ‘AC”
In the Item table, INO and IName can be treated (iii) Display a cross join of the two tables.
as the candidate keys. (iv) Remove records of passengers who are
or travelling by “Rajdhani”.
Observe the following table carefully and write
Sol :
the names of the most appropriate columns,
which can be considered as (i) candidate keys and (a) SELECT Tr.Pname, T.Tname FROM
(ii) primary key. Travel Tr, Train T WHERE Tr.TId =
Table: Product
T.TId AND Tname LIKE “%Mail”;
(b) (i) SELECT T1.Pname,T2. Tname,
CID CNAME AMOUNT COUNTRY ITEM
T1.Amt FROM Travel T1, Train
101 ALLE 100000 JMEKA SHOES T2 WHERE T1 .TId= T2. TId AND
111 BEN 20000 FRANCE HELMET Amt>5000;
110 RIKI 25000 AMERICA BAG (ii) UPDATE Travel SET
Amt=Amt+Amt*0.2 WHERE Class=
011 BRETT 105000 AUSTRALIA BAT
LEE “AC”;
(iii) SELECT*FROM Travel,Train;
Sol : (iv) DELETE FROM Travel Tr, Train
(i) Candidate Keys CID, ITEM T WHERE Tr.TId = T.TId AND
(ii) Primary key CID T.Tname=“Rajdhani”;

27. A binary file “emp.dat” contains records of


employees as per following structure:
Section C Eno Ename Salary
1 Mr. Raj 85000
26. (a) Consider the tables Travel and Train given
h
below.
Write a program in Python to open the Binary
Table : Travel file “emp.dat” and display only those records
where the employee salary is greater than 75000.
Tcno Pname Class TId Amt
Sol :
1 Rahul AC T1 2500
import pickle
2 Sujit SL T2 4500
f=open(“emp.dat”, “rb”)
3 Ravi AC T1 6000 while True:
4 Ankita AC T3 1800 try:
1st=pickle.load(f)
if (lst[2]>75000):
Table : Train
print(“Employee No. :”, 1st[0])
TId Tname print(“Employee Name :”, 1st[1])
T1 Rajdhani print(“Employee Salary :”,
1st[2])
T2 Himgiri Exp except EOFError:
T3 Darjeeling Mail print(“No more records”)
break
Write the command to display the passenger
f.close()
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

Write a program to read the content from a text ND50 T Prasad 122-K, SDA New Delhi
file “status.txt”, count and display the total
number of lines and blank spaces present in it. TABLE: RECIPIENT
e.g. if the “status.txt” file contains the following
RecID SenderlD RecName RecAddress RecCity
lines:
Welcome to your one-step solutions for all your KO05 ND01 R Bajpayee 5, Central Kolkata
Avenue
study, practice and assessment needs for various
competitive & recruitment examinations and ND08 MU02 S Mahajan 116, A Vihar New
Delhi
school segment. We have been working tirelessly
for over a decade to make sure that you have MU19 ND01 H Singh 2A, Andheri Mumbai
East
best in class study resources because you deserve
SUCCESS AND NOTHING LESS... MU32 MU15 P K Swamy B5, C S Mumbai
Terminus
The output will be:
The status file contents are ND48 ND50 S Tripathi 13, B1 D, New
Mayur Delhi
Total lines in file are: 4 Vihar
Total spaces in file are: 43
(i) To display the names of all Senders from
Sol : Mumbai.
import os (ii) To display the RecID, SenderName,
tfile=‘status.txt’ SenderAddress, RecName, RecAddress
if os.path.isfile(tfile): for every Recipient.
fob=open(tfile, ‘r’) (iii) To display Recipient details in ascending
blankspaces=total_lines=0 order of RecName.
print(“The status file contents (iv) To display number of Recipients from
are”). each City.
print(“_____”) (b) Display the Sender name and corresponding
while True: Recipient name from the tables where sender
aline=fob.readline() is from “NEW DELHI” and recipient is from
if not aline: “KOLKATA”.
break Sol :
else:
(a) (i) SELECT SenderName FROM SENDER
total_lines=total_lines+1
WHERE SenderCity = ‘Mumbai’;
aline=aline.rstrip()
(ii) SELECT RecID, SenderName,
for i in aline:
SenderAddress, RecName,
if i.isspace():
RecAddress
blankspaces=blankspaces+1
FROM RECIPIENT, SENDER WHERE
print(“Total lines in file are:
RECIPIENT.SenderlD = SENDER.
%d” %total_lines)
SenderID;
print(“Total space in file are:
(iii) SELECT *FROM RECIPIENT ORDER
%d” % blankspaces)
BY RecName;
fob.close()
(iv) SELECT 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
RECIPINT. Write SQL commands for the FROM Sender S , Recipient R
statements (i) to (iv). WHERE S.SenderlD=R.SenderID AND
(SenderCity= “New Delhi” AND
TABLE: SENDER RecCity=“KOLKATA”);
SenderlD SenderName SenderAddress SenderCity
29. Write a user defined function change(L) to accept
ND01 R Jain 2, ABC Appts New Delhi
a list of numbers and replace the numbers in the
MU02 H Sinha 12, Newtown Mumbai
list with their sum of digits.
MU15 S Jha 27/A, Park Street Mumbai Example
Page 6 Sample Paper 1 Computer Science Class 12

Input : [32,142,215,26,7]
Output : [5, 7 , 8 , 8, 8,7]
Sol :
L= [ ]
n=int(input(“Enter number of
element”))
for i in range (1, n+1):
b=int(input(“Enter element:”))
L=append(b)
i=0
for a in L:
s=0 Section D
while a>0:
s+=a%10 31. Freshminds University of India is starting its first
a//=10 campus in Ana Nagar of South India with its
L[i]=s centre admission office in Kolkata. The university
i+=1 has three major blocks comprising of Office block,
print(L) Science block and Commerce block is in 5 km area
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 :
def Push (contents):
if(len(stack) >= limit):
print(“Stack Overflow!”)
else :
stack.append (contents)
print (“Stack after Push”, stack)
def Pop( ):
if (len (stack) <= 0):
print(“Stack Underflow!”) Expected wire distance between various locations.
return 0 Office Block to Science Block 90 m
else : Office Block to Commerce Block 80 m
return stack.Pop( )
Science Block to Commerce Block 15 m
or
Kolkata Admission Office to Ana Nagar 450 km
Find the final contents of a stack on which the
Campus
following operations are done.
Expected number of computers to be installed at
1. Push(100)
various locations in the university are as follows:
2. Push(200)
Office Block 10
3. Push(50)
Science Block 140
4. Push(50) Commerce Block 30
5. Pop() Kolkata Admission Office 8
6. Push() (i) Suggest the authorities, the cable layout
7. Pop(2) amongst various blocks inside university
campus for connecting the blocks.
8. Pop() (ii) Suggest the most suitable place (i.e. block)
to house the server for this university with a
Sol :
suitable reason.
Page 7 Sample Paper 1 Computer Science Class 12

(iii) Suggest an efficient device from the following :”))


to be installed in each of the block to connect a = x +y+ z
all the computers. print (“Result = ”, a)
(a) Modem (b) Switch (c) Gateway (b) import mysql.connector
(iv) Suggest a suitable topology to connect the mycon = mysql.connector.connect (
computers in each building. host = “local host”,
(v) University is planning to connect its campus user = “root”,
in Kolkata which is more than 100 km. Which passwd = “system”,
type of network will be formed? database = “School”)
cursor = mycon.cursor( )
Sol : db = cursor .execute
(i) (“CREATE TABLE Student(
Roll No Int( 5) Primary key,
FirstName varchar(30) NOT NULL,
LastName varchar(30),
Address varchar(50),
ContactNo varchar(20)
Marks Float,
Course char(20),
Rank char(10) check (Rank IN(‘Good’
(ii) The most suitable place to house the server ,‘Best’,‘Bad’,‘Worst’,‘Average’))))
is Science Block as it has maximum number mycon.close ( )
of computers. Thus, reducing the cabling cost or
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
of the blocks to connect all the computers. each in Python.
(iv) Star topology, as it is the best in efficiency. (b) What is the use of fetchone() method? Write
(v) WAN (Wide Area Network) 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(input(“Enter first number:))
Table : Student
Host : localhost
y = int(input(“Enter second number:”))
z = int(input(“Enter third number:”) UsedlD : root
Password : arihant
a = x+ b+ z
print (“Result = ”, b)
(b) Write the code to create the following table Sol :
Student with the following fields (a) Differences between logical error and syntax
RollNo error are as follows:
FirstName
Logical Error Syntax Error
LastName
Address
ContactNo It occurs because of It occurs when
Marks wrong implementation statements are wrongly
Course of logic. written violating rules
Rank of the programming
In the table, Rank should be Good, Best, language.
Bad, Worst, Average. With logical errors, the With syntax errors,
Sol : code is syntactically the code is not
correct and compiler syntactically correct
(a)
will not show any error and compiler will show
x = int(input(“Enter first number:”))
message. the error messages.
y = int(input(“Enter second number:”))
z = int(input(“Enter third number
Page 8 Sample Paper 1 Computer Science Class 12

w1 = csv.writer(f2)
It produces the output, It does not produce
for row in r1 :
but undesired. any output.
w1.writerow(row)
e.g. in place of e.g. in place of f1.close()
(c = a * b); if by (a == b); if by mistake f2.close()
mistake (a == b); is written, it def convertcsv():
(c = a + b); is written, will be a syntax error. f1 = open(“old.csv”,‘r’)
it will be a logical f2 = open(“converted.csv”, ‘w’,
error. newline = “\n”)
(b) fetchone() returns the next row from the r1 = csv.reader(f1, delimiter =
result set as tuple. If there are no more rows “:”)
to retrieve, None is returned. w1 = csv.writer(f2, delimiter =
e.g. To fetch only one record “;”)
import mysql.connector for row in r1:
con = mysql.connector.connect w1.writerow(row)
(host = “localhost”, f1.close()
user = “root”, f2.close()
passwd = “arihant”,database addcsv()
= “PythonDB”) convertcsv()
cursor = con.cursor() or
try: CSV files are opened with which argument
cursor.execute(“Select Name, to suppress EOL translation. Write a python
RollNo, Address, Percentage from program to perform the following using functions
Student”) as follows :
display = cursor.fetchone() (a) copytocsv() :
print(display) A CSV file “marks.csv” has name, class and
except: marks separated by comma. Write the Python
con.rollback() function to copy only the name and class to
con.close() another CSV file “class.csv”.
(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
: the Python function to copy only rows of
(a) addcsv(): students of class 2 to another CSV file “class.
File old.csv has come from branch in Pune csv”.
and it needs to be added to file “updated.
csv” which has data for all branches. Write Sol :
the code in the function to perform the same. newline= ‘ ’
(b) convertcsv() : Program:
A file old.csv has come with separator ‘:’ but import csv
your system can only read ‘;’ Write a program def copytocsv():
to convert to “converted.csv” file. Write the file = open(‘class.csv’,‘w’,
function to change the separator of the file. newline=“ ”)
Sol : writer = csv.writer(file)
with open(‘marks.csv’) 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[0],
import csv row[1]])
def addcsv(): file.close()
f1 = open(“old.csv”, ‘r’) def copyselected():
f2 = open(“updated.csv”, ‘a’, file = open(‘class.csv’, ‘w’,
newline = “\n”) newline= “\n”)
r1 = csv.reader(f1) w1 = csv.writer(file)
Page 9 Sample Paper 1 Computer Science Class 12

with open(‘marks.csv’) as csvfile: print(filedata)


data = csv. reader(csvfile) data=filedata.split(‘ ’)
for row in data: for.......... in data : #Blank1
if row[1]== ‘2’: if words[–1] in “aeiou” and ...in
writer.writerow(row) “AEIOU”: # Blank2
file.close() print(......... .) # Blank3
copytocsv() f.close()
copyselected() (i) Write the missing code for Blank1.
(ii) Write the missing code for Blank2.
(iii) Write the missing code for Blank3.
Section E Sol :
(i) words
34. Consider the following table Person
(ii) words[0]
P_Id LastName First Name Address City (iii) words
1 Hansen Ola Timoteivn Sandnes
10
2 Svendson Tove Borgvn 23 Sandnes
END
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Johan Bakken 2 Stavanger

(i) What should be the constraint(s) of the P_Id


column?
(ii) If 3 columns are added to the table , what will
be its degree?
(iii) Write statements to :
(a) Display the Unique Cities.
(b) Display Firstnames of people who do not
have a address.
or (Option for part (iii) only)
Write appropriate data types to store the
following :
(a) Amounts carrying values with decimal.
(b) Joining dates.
Sol :
(i) Primary key
(ii) 8, There are 5 columns + 3 = 8 columns.
Degree is number of columns.
(iii) (a) SELECT DISTINCT City FROM
Person;
(b) SELECT FirstName FROM Person
WHERE address IS NULL;
or
(a) float/decimal/double
(b) date/datetime

35. The code given below reads a text file and displays
those words that begin with an uppercase vowel
and end with a lowercase vowel . Some of the codes
are missing .Write codes to fill up the blanks.
f=open(“emp.txt”)
filedata=f.read()
count=0

You might also like