0% found this document useful (0 votes)
336 views

CS Sample Paper 2

Here are the functions to perform the requested actions: (i) To add a new column to a table - ALTER TABLE table_name ADD column_name data_type; (ii) To get the sum of all values in a column of a table - SELECT SUM(column_name) FROM table_name; 28. Write a Python program to create a class Student with attributes name and roll. Create an object and display the name and roll of the student. 29. Write a Python program to demonstrate inheritance. Create two classes: Person and Student. Person should have attributes name and age. Student should inherit Person and have additional attributes roll and marks. Create an object of Student class and print name

Uploaded by

SpreadSheets
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)
336 views

CS Sample Paper 2

Here are the functions to perform the requested actions: (i) To add a new column to a table - ALTER TABLE table_name ADD column_name data_type; (ii) To get the sum of all values in a column of a table - SELECT SUM(column_name) FROM table_name; 28. Write a Python program to create a class Student with attributes name and roll. Create an object and display the name and roll of the student. 29. Write a Python program to demonstrate inheritance. Create two classes: Person and Student. Person should have attributes name and age. Student should inherit Person and have additional attributes roll and marks. Create an object of Student class and print name

Uploaded by

SpreadSheets
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/ 8

Page 1 Sample Paper 2 Computer Science Class 12

Sample Paper 2
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.

Section A
1. Given L= [2,3,4,5,6]. The output of print(L[–2]) is
(a) 6 (b) Error
(c) 5 (d) 3

2. The method used to get the position of file pointer is


(a) tell() (b) get()
(c) seek() (d) pos()

3. This function is used to calculate total occurrence of given elements of list.


(a) len() (b) sum()
(c) count() (d) extend()

4. You can repeat the elements of the tuple using which operator?
(a) * (b) +
(c) ** (d) %

5. The rule of referential integrity is based on...........


(a) Primary key (b) Foreign key
(c) Alternate key (d) None of these

6. Which method returns the next row from the result set as tuple?
(a) fetchone () (b) fetchmany ()
(c) fetchall () (d) rowcount

7. Which of the following command displays the attributes of a table along with their types and sizes?
(a) Alter (b) Show structure
(c) Show create table (d) View structure

8. The............command adds records to a table.


(a) ADD (b) APPEND
(c) ADDRECORD (d) INSERT
Install NODIA App to See the Solutions.
Click Here To Install
Page 2 Sample Paper 2 Computer Science Class 12

9. In a............topology, the nodes are connected by separate cables.


(a) Star (b) Bus
(c) Tree (d) Mesh

10. Given a list Lst= [45,100,20,30,50]. What will be the output of Lst[: :]?
(a) [45,100,20,30,50] (b) [ ]
(c) Error (d) [45]

11. State True or False


“Given a dictionary Studict. The statement Studict.items() displays the keys of the item only.”

12. Which module is to be imported to use the floor() function?


(a) statistics (b) matplotlib
(c) random (d) math

13. Which function is used to convert string into tuple?


(a) string() (b) tup()
(c) tuple() (d) str_tuple()

14. A file can be opened both for reading and writing using............mode.
(a) r (b) r+
(c) a (d) None of these

15. The..........clause can be used as an alternative to multiple OR.


(a) IN (b) BETWEEN
(c) NOT (d) range

16. The purpose of the primary key in a database is to


(a) unlock the database
(b) provide a map of the data
(c) uniquely identify a record
(d) establish constraints on database operations

Directions : (Q.Nos.-17 and 18) are Assertion and Reason based Questions.

17. Assertion (A) To use the randint() function , the random module needs to be included in the program.
Reason (R) Some functions are present in modules and to use them the respective module needs to be imported.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is true but R is false.
(d) A is false but R is true.

18. Assertion (A) The contents of a Binary file are not directly interpretable.
Reason (R) Modes in which binary files can be opened are suffixed with ‘b’ like : rb/wb etc.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(a) A is true but R is false.
(c) A is false but R is true.

Install NODIA App to See the Solutions.


Click Here To Install
Page 3 Sample Paper 2 Computer Science Class 12

Section - B
19. Find the error(s).
L1 = [7, 2, 3, 4] Statement 1
L2 = L1 + 2 Statement 2
L3 = L1 * 2 Statement 3
L = L1.pop(7) Statement 4
20. Name two switching techniques used to transfer data between two terminals (computers).
 o
Arrange the following network in ascending order of their area:
LAN, PAN, WAN, MAN

21. (a) Observe the code and write the output:


t = ‘HELLO’
t1 = tuple(t)
print(t1)
(b) Predict the output of the following code
x = (1, 2, 3)
y = (3, 4)
t = x + y
print(t)

22. Differentiate between an attribute and a tuple with an example.

23. (a) Write the hill forms of


(i) WVVW
(ii) TCP/IP
(b) List down the types of computer networks.

24. Identify the output of the following Python code.


D = {1: “One”, 2: “Two”, 3: “Three”}
L = [ ]
for K, V in D.items():
if V[0] = = “T”:
L.append (K)
print(L)
 o
Identify the output of the following Python statement.
lst1 = [10, 15, 20, 25, 30]
lst1.insert(3, 4)
lst1.insert(2, 3)
print (lst1[– 5])

25. Describe the following terms


(i) Domain
(ii) DB2
 o

Install NODIA App to See the Solutions.


Click Here To Install
Page 4 Sample Paper 2 Computer Science Class 12

Identify commands/functions for the following actions :


(i) To add a new column to a table.
(ii) To get the sum of all values in a column of a table.

Section - C

26. (a) Consider the tables CARS and SUPPLIER given below. What will be the output of the statement given?
TABLE: CARS
Ccode Car-Name Make Color Capa-city Cha-rges Scode
501 A-star Suzuki RED 3 14 1
503 Indigo Tata SILVER 3 12 2
502 Innova Toyota WHITE 7 15 2
509 SX4 Suzuki SILVER 4 14 2
510 C-Class Merc-edes RED 4 35 4

Table : SUPPLIER
Scode Sname
1 Great Suppliers
2 Himalayan Vehicles
3 Road Motors
4 Speed
SELECT CarName, Sname, Charges FROM CARS C, SUPPLIER S WHERE C.Scode= S. Scode
AND Charges > 15;
(b) Write the output for SQL queries (i) to (iv), which are based on the table CARDEN.
TABLE: CARDEN
Ccode CarName Make Color Capa-city Charges
501 A-star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
510 C-Class Mercedes RED 4 35
(i) SELECT COUNT(DISTINCT Make) FROM CARDEN;
(ii) SELECT COUNT(*) Make FROM CARDEN;
(iii) SELECT CarName FROM CARDEN WHERE Capacity = 4;
(iv) SELECT SUM (Charges) FROM CARDEN WHERE Color = “SILVER”;

27. Write a function Del() to delete the 4th word from a text file school.txt.
 o
Write a function countmy( ) in Python to read the text file “Data.txt” and count the number of times “my” occurs
in the file.
For example If the file contents are:

Install NODIA App to See the Solutions.


Click Here To Install
Page 5 Sample Paper 2 Computer Science Class 12

My first book was. Me and My Family.


It gave me chance to be known to the world.
The output of the function should be
No. of times “my” occur : 2

28. (a) Write the output of the queries (i) to (iv) based on the table FURNITURE given below.
Table : FURNITURE
FID NAME DATE OF PURCHASE COST DISCOUNT
B001 Double Bed 03-JAN-2018 45000 10
T010 Dinning Table 10-MAR-2020 51000 5
B004 Single Bed 19-JUL-2021 22000 0
C003 Long back Chair 30-DEC-2016 12000 3
T006 Console Table 17-NOV-2019 15000 12
B006 Bunk bed 01-JAN-2021 28000 14
(i) SELECT SUM(DISCOUNT) FROM FURNITURE WHERE COST>15000;
(ii) SELECTMAX(DATEOFPURCHASE) FROM FURNITURE;
(iii) SELECT
* FROM FURNITURE WHERE DISCOUNT>5 AND FID LIKE “T%”;
(iv) SELECTDATEOFPURCHASE FROM FURNITURE WHERE NAME IN (“Dinning Table”, “Console
Table”);
(b) Write a command to remove all the records of the table “Garments” whose Readydate is after “20-Oct-2008”.

29. Write a user-defined function find-name (name), where name is an argument in Python to delete phone number from
a dictionary phone-book on the basis of the name, where name is the key.

30. Write Push (contents) and Pop (contents) methods in Python to add numbers and remove numbers considering them
to act as Push and Pop operations of stack.
 o
Write the Push operation of stack containing person names. Notice that the name should only accept characters,
spaces and period (.) except digits. Assume that Pname is a class instance attribute.

Section - D

31. Sony corporation has set up its 4 offices in the city of Srinagar, with its offices X, Z, Y, U:

Branch to Branch distance is given below:

Install NODIA App to See the Solutions.


Click Here To Install
Page 6 Sample Paper 2 Computer Science Class 12

X to Z 40 m
Z to Y 60 m
Y to X 135 m
X to U 70 m
Z to U 165 m
Z to U 80 m
Number of computers in each of the offices is as follows:
X 50
Z 130
Y 40
U 15
(i) Suggest a suitable cable layout of connectivity of the offices.
(ii) Suggest placement of server in the network with suitable reason.
(iii) Suggest placement of following devices in the network:
(a) Switch/Hub
(b) Repeater
(iv) Suggest a suitable topology for connecting the computers in each building.
(v) Write any one advantage of the topology suggested.

32. (a) Carefully observe the following Python code and answer the question that follow:
x = 5
def func2():
x = 3
global x
x = x + 1
print(x)
print(x)
On execution the above code, produces the following output:
6
3
Explain the output with respect to the scope of the variables.
(b) Write the code to create a table Product in database Inventory with following fields
Fields Datatype
PID varchar(5)
PName char(30)
Price float
Rank varchar(2)
Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : system
Password : hello
Database : Inventory
 o

Install NODIA App to See the Solutions.


Click Here To Install
Page 7 Sample Paper 2 Computer Science Class 12

(a) Find the output of the following program:


def calcresult ():
i=9
while i>1 :
if(i%2 = = 0):
x = i%2
i = i – 1
else:
i = i – 2
x = i
print(x**2)
(b) Which data will get added in table Company by following code?
import mysql.connector
con = mysql.connector.connect (
host = “localhost”,
user = “system”,
passwd = “hello”,
database = “connect”).
cur = con.cursor ( )
sql = “insert into Company (Name,
Dept, Salary) values (%s,
%s, %s)”
val = (“ABC”, “DBA”, 35000)
cur.execute (sql.val)
con.commit ( )
Consider :
host : localhost
UserName : system
Password : hello
Database ; connect

33. Does python create a file itself if the file doesn’t exist in the memory? Illustrate your answer with an example:
Write a program using following functions :
(a) inputStud() :To input details of as many students and add them to a csv file “college.csv” without removing the
previous records.
SrNo Studname City Percentage
(b) readCollege() : To open the file “college.csv” and display records whose city is “Kolkata”
 o
Write a statement to create a data.txt file with the following text.
Python file handling is very interesting and useful.
Write a python code using two functions as follows
(a) removerow( ) : To remove a record from the college file “College.csv” having following structure.
SrNo Studname City Percentage
(b) getCollege( ) : To read the records of the college file “College.csv” and display names of students whose names
start with a lowercase vowel.

Install NODIA App to See the Solutions.


Click Here To Install
Page 8 Sample Paper 2 Computer Science Class 12

Section - E

34. Consider the table APPLICANTS


TABLE: APPLICANTS
No NAME FEE GEN-DER C_ID JOINYEAR
1012 Amandeep 30000 M A01 2012
1102 Avisha 25000 F A02 2009
1103 Ekant 30000 M A02 2011
1049 Arun 30000 M A03 2009
1025 Amber 40000 M A02 2011
1106 Ela 40000 F A05 2010
1017 Nikita 35000 F A03 2012
1108 Arluna 30000 F A03 2012
2109 Shakti 35000 M A04 2011
1101 Kirat 25000 M A01 2012
(i) Which field qualifies to be the Primary key.
(ii) If all the records of Male applicants are deleted, what will be the cardinality of the table.
(iii) Write statements to
(a) Increase FEE of “M” (Male) applicatnts by 2000.
(b) Display details of “F” (Female) applicants in descending order of FEE.
 o
(Option for part (iii) only)
Write statements to
(a) Change width of column FEE to 20.
(b) Remove the column C_ID.

35. Given below is a code to open a text file and perform some operations on it. Answer questions with respect to the
code given
myfile=open(“detail.txt”, “r”)
s =.......... Line 2
print(s)
myfile.close( )
(i) In which mode is the file opend?
(ii) If the entire file is to be read, write a statement in place of Line 2.
(iii) What is the original code performing?

Install NODIA App to See the Solutions.


Click Here To Install

You might also like