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

12_computer_science_sp_10_with_solution

class 12 cs

Uploaded by

advit.amit123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

12_computer_science_sp_10_with_solution

class 12 cs

Uploaded by

advit.amit123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Class 12 - Computer Science

Sample Paper - 10 (2023-24)

Maximum Marks: 70
Time Allowed: : 3 hours

General Instructions:

Please check this question paper contains 35 questions.


The paper is divided into 4 Sections- A, B, C, D and E.
Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.

Section A
1. State true or false:
A given object may appear in a list more than once.
a) True
b) False
2. Aggregate functions are also known as
a) group functions
b) Add function
c) group method
d) sum function
3. Which method returns the next row from the result set as tuple?
a) fetchone()
b) rowcount
c) fetchall()
d) fetchmany()
4. are used to pass the value of a variable to a function.
a) Objects
b) Arguments
c) Parentheses
d) Classes
5. Protective covering that protects the optical fiber from outside environment is known as
a) Core
b) Jacket
c) Buffer
d) Cladding
6. To read the next line of the file from a file object infi, we use
a) infi.read()
b) infi.readlines()
c) infi.readline()
d) infi.read(all)
7. To reflect the changes made in the database permanently, you need to run <connection>. method.
a) done()
b) reflect()
c) commit()
d) final()
8. Which of the following join gives the intersection of two tables?
a) Inner join
b) Outer join
c) Equi join
d) None of these
9. Which of the following statement is incorrect in the context of pickled binary files?
a) pickle module is used for reading and writing objects in binary files.
b) dump() of the pickle module is used to write objects.
c) load() of the pickle module is used to read objects.
d) csv module is used for reading and writing objects in binary files.
10. Which of the following is the use of function in python?
a) Functions don't provide better modularity for your application
b) Functions are reusable pieces of programs
c) you can't also create your own functions
d) All of these
11. Which of the following is/are linear data structure(s)?
a) Stack
b) Array
c) All of these
d) Queue
12. What is the area of memory called, which stores the parameters and local variables of a function call?
a) an array
b) storage area
c) a stack
d) a heap
13. State true or false:
The cloud is a generic term used for Internet.
a) True
b) False
14. Which index number is used to represent last character of string?
a) 0
b) -1
c) n - 1
d) 1
15. Fill in the blanks:
SQL is running in all .
16. Which type of transmission media is the least expensive to manufacture?
a) Twisted pair cable
b) CAT cable
c) Coaxial
d) Fibre optic
17. Assertion (A): In Python, we need to specify the type of variable.
Reason (R): Python is a infer language and smart enough to get variable type.
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): In the case of w+, it overwrites the previous file if one exists.
Reason (R): In the case r+, it doesn't overwrite the previous file if one exists.
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.
Section B
19. Answer:
1. i. What is carrier wave? What is a modulated wave?
ii. Write two characteristics of Wi-Fi.
2. OR
i. Give one advantage and one disadvantage of optical fiber cable and coaxial cable used in communication.
20. Write Python code to create a table faculty with the following fields.
Id, LastName, FirstName, Locationid, phone, rank, startdate
Rank should be one of the following
ASSO, FULL, ASST, INST
21. What are immutable and mutable types? List immutable and mutable types of Python.

OR

Find the output of the following code:

first = 25
second = 30
for i in range (1, 3, 1):
print("Output 1 = ", first -3, "&" , second +5)
print("Output 2 = " , second +1,"&", first -5)

22. Answer:
1. Can one DB-API be used for all database types?
2. What does cursor.fetchall( ) method do?
23. Write a program that prints a table on two columns - table that helps converting miles into kilometres.

OR

Write a program printing a table with two columns that help convert pounds in kilograms.
24. What are the advantages of saving data in binary form and text form?

OR
Considering the following definition of dictionary MULTIPLEX, write a method in python to search and display all the
content in a pickled file CINEMA.DAT, where MTYPE key of the dictionary is matching with the value 'Comedy'.
MULTIPLEX = {'MNO' : , 'MNAME' : , 'MTYPE' : }
25. What will be the output of the following code sinppet and why?
# module calculate.py
"""This module will be imported"""
def sum ():
"""Prints sum of 10 and 5"""
b=5
a = 10
print "sum =",a + b
return
def diff():
"""Prints difference of 20 and 5"""
a = 30
b=5
print "Difference =", a - b
return
print "This will print something"
greet = "Hello!"
#Fun.py
import calculate
print calculate.greet
Section C
26. Answer:
1. Find the errors in following code and write the correct code.
s = [11, 13, 15]
for n in arange(len(s)):
tot = tot + s(n)
print(tot)
i. Underline the corrections.
ii. Write the reason! error next to it in the comment form.
2. Find the output of the given code.

list1 = ['P', 'R', 'O', 'G', 'R', 'A', 'M']


for i in range(len(list1)) :
print(list1[i])

27. Write a function that takes a sorted list and a number as an argument. Search for the number in the sorted list using
binary search.
28. What are DDL and DML?

OR

Write a query to display the number of employees with same job.


29. poemBTH.txt
God made the Earth;
Man made confining countries
And their fancy-frozen boundaries.
But with unfound boundLess Love
I behold the border Land of my India
Expanding into the world.
Holi mother of religions, Lotus
scenic beauty, and sages!
Consider the file poemBTH.txt and predict the output of the following code fragment. What exactly is the following
code fragment doing?
f = open("poemBTH.txt", "r")
n1 = 0
for line in f :
n1 += 1
print(n1)
30. Find the errors in code given below:
i. def minus(total, decrement)
output = total - decrement
print(output)
return (output)
ii. define check()
N = input ('Enter N:')
i=3
answer = 1 + i * * 4/N
Return answer
iii. def alpha(n, string = 'xyz', k = 10) :
return beta(string)
return n
def beta (string)
return string == str(n)
print(alpha("Valentine's Day"):)
print(beta (string = 'true'))
print(alpha(n=5, "Good-bye") :)
Section D
31. Write a program to implement a stack for these book details (book no., book name). That is, now each item node of the
stack contains two types of information - a book no. and its name. Just implement Push and display operations.
32. Give output for following SQL queries as per given table(s) :

Table : Books

Book_Id Book_Name Author_Name Publishers Price Type Qty.

F0001 The Tears William Hopkins First publ. 750 Fiction 10


F0002 Thunderbolts : Anna Roberts i Fist Publ. 700 Fiction 5

T0001 My first C++ Brian and Brooke EPB 250 Text 10


T0002 C++ Brainworks A.W. Rossaine TDH 325 Text 5

C0001 Fast cook Lata Kapoor EPB 350 Cookery 8


Table : Issued

Book_Id Quantity_Issued

F0001 3
T0001 1

C0001 5
i. SELECT COUNT (DISTINCT Publishers) FROM Books.
ii. SELECT SUM(Price) FROM Books WHERE Quantity > 5.
iii. SELECT Book_Name, Author_Name FROM Books WHERE Price < 500.
iv. SELECT COUNT (*) FROM Books.
Section E
33. Granuda Consultants are setting up a secured network for their office campus at Faridabad for their day to day office and
web-based activities. They are planning to have connectivity between 3 buildings and the head office situated in Kolkata.
Answer the questions (i) to (iv) after going through the building positions on the campus and other details, which are
given below:

Distances between various buildings:


Building "RAVI" to Building "JAMUNA" 120 m
Building "RAVI" to Building "GANGA" 50 m

Building "GANGA" to Building "JAMUNA" 65 m


Faridabad Campus to Head Office 1460 KM

Number of Computers
Building "RAVI" 25

Building "JAMUNA" 150


Building "GANGA" 51
Head Office 10
i. Suggest the most suitable place (i.e.r block) to house the server of this organization. Also, give a reason to justify
your suggested location.
ii. What type of network will be formed if all buildings are connected?
iii. Suggest the placement of the following devices with justification:
a. Switch
b. Repeater
iv. The organization is planning to provide a high-speed link with its head office situated in the KOLKATA using a
wired connection. Which of the following cables will be most suitable for this job?
a. Optical Fibre
b. Co-axial Cable
c. Ethernet Cable
34. Consider the following tables CARDEN and CUSTOMER and answer (b) and (c) parts of this question:

Table: CARDEN

Ccode CarName Make Colour Capacity 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

Table: CUSTOMER

Code Cname Ccode


1001 Hemant Sahu 501

1002 Raj Lai 509


1003 Feroza Shah 503

1004 Ketan Dhal 502


a. Give a suitable example of a table with sample data and illustrate Primary and Alternate Keys in it.
b. Write SQL commands for the following statements:
a. To display the names of all the silver-colored cars.
b. To display names of car, make and capacity of cars in descending order of their sitting capacity.
c. To display the highest charges at which a vehicle can be hired from CARDEN.
d. To display the customer name and the corresponding name of the cars hired by them.
c. Give the output of the following SQL queries:
i. SELECT COUNT(DISTINCT Make)FROM CARDEN;
ii. SELECT MAX(Charges), MIN(Charges) FROM CARDEN;
iii. SELECT COUNT(*), Make FROM CARDEN;
iv. SELECT CarName FROM CARDEN WHERE Capacity=4;

OR

Consider the following tables GAMES and PLAYER and answer the following parts of this question :

Table: GAMES

GCode GameName Type Number PrizeMoney ScheduleDate


101 Carom Board Indoor 2 5000 23-Jan-2004
102 Badminton Outdoor 2 12000 12-Dec-2003

103 Table Tennis Indoor 4 8000 14-Feb-2004


105 Chess Indoor 2 9000 01-Jan-2004

108 Lawn Tennis Outdoor 4 25000 19-Mar-2004


Table : PLAYER

PCode Name GCode

1 Nabi Ahmad 101


2 Ravi Sahai 108

3 Jatin 101
4 Nazneen 103

Give the output of the following SQL queries :


i. SELECT COUNT (DISTINCT Number) FROM GAMES ;
ii. SELECT MAX(ScheduleDate), MIN(ScheduleDate) FROM GAMES ;
iii. SELECT Name, GameName FROM GAMES G, PLAYER P
WHERE G.GCode = P.GCode AND G.PrizeMoney > 10000 ;
iv. SELECT DISTINCT GCode FROM PLAYER;
35. Answer:
1. i. MySQL provides some command-line programs and GUI programs. Name some of these.
ii. Give output for following SQL queries as per given table(s):

Table: WORKERS

W_ID FIRSTNAME LASTNAME ADDRESS CITY

102 Sam Tones 33 Elm St. Paris


105 Sarah Ackerman ‘ 440 U.S. 110 New York

144 Manila Sengupta 24 Friends Street New Delhi


210 George Smith 83 First Street Howard

255 Mary Jones 842 Vine Ave. Losantiville


300 Robert Samuel 9 Fifth Cross Washington

335 Henry Williams 12 Moore Street Boston


403 Ronny Lee 121 Harrison St. New York
451 Pat Thompson 11 Red Road Paris

Table: DESIG

W_ID SALARY BENEFITS DESIGNATION

102 75000 15000 Manager


105 85000 25000 Director

144 70000 15000 Manager


210 75000 12500 Manager

255 50000 12000 Clerk


300 45000 10000 Clerk
335 40000 10000 Clerk

400 32000 7500 Salesman


451 28000 7500 Salesman
i. SELECT FIRSTNAME, SALARY
FROM WORKERS, DESIG
WHERE DESIGNATION = 'Manager' AND
EMPLOYEE.WJD = DESIG.W.ID;
ii. SELECT COUNT (DISTINCT DESIGNATION) FROM DESIG;
iii. SELECT DESIGNATION, SUM(SALARY)
FROM DESIG
GROUP BY DESIGNATION HAVING COUNT(*) < 3;
iv. SELECT SUM(BENEFITS)
FROM WORKERS
WHERE DESIGNATION = 'Salesman';
2. OR
i. The SQL SELECT provides clauses for sorting data and for summarizing results. Write the names of clauses
for these.
ii. Consider the following table WORKER. Write SQL commands for the following statements.

Table: WORKER

ECODE NAME DESIG PLEVEL DOJ DOB


11 Radhe Shyam Supervisor P001 13-Sep-2004 23-Aug-1981

12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987


13 Fizza Operator P003 14-Jun-2009 14-Oct-1983

15 Ameen Ahmed Mechanic P002 21-Aug-2006 13-Mar-1984


18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983
i. To display the details of all WORKERS in descending order of DOB.
ii. To display NAME and DESIG of those WORKERS, whose PLEVEL is either P001 or P002.
iii. To display the content of all the WORKERS table, whose DOB is in between '19-JAN-1984' and ‘18-
JAN-1987’.
iv. To add a new row with the following :
19, 'Daya Kishore', 'Operator', 'P003', '19-Jun-2008', '11-Jul-1984'
Class 12 - Computer Science
Sample Paper - 10 (2023-24)

Solution

Section A
1. (a) True
Explanation: True, A given object may appear in a list more than once
2. (a) group functions
Explanation: group functions
3. (a) fetchone()
Explanation: fetchone()
4. (b) Arguments
Explanation: Arguments
5. (c) Buffer
Explanation: Core is the part through which light travels.
Cladding covers the core and reflects light back to it.
Buffer is the fiber protection.
Jacket is not in the context.
6. (c) infi.readline()
Explanation: readline() function reads a line from the file pointer position.
7. (c) commit()
Explanation: commit()
8. (a) Inner join
Explanation: Inner join
9. (d) csv module is used for reading and writing objects in binary files.
Explanation: csv module is used for reading and writing objects in binary files.
10. (b) Functions are reusable pieces of programs
Explanation: Functions are reusable pieces of programs. They allow you to give a name to a block of statements,
allowing you to run that block using the specified name anywhere in your program and any number of times.
11. (c) All of these
Explanation: All of these
12. (c) a stack
Explanation: Stack stores the parameters and local variables of a function call.
13. (a) True
Explanation: True
14. (b) -1
Explanation: -1
15. 1. servers
16. (a) Twisted pair cable
Explanation: Twisted pair cable is the least expensive transmission media.
17. (d) A is false but R is true.
Explanation: In Python, we don't need to specify the type of variable because Python is a infer, dynamically typed
language, and smart enough to get variable type.
18. (b) Both A and R are true but R is not the correct explanation of A.
Explanation: w+ mode opens the file to write and read both. It is different from r+ mode in the sense that it overwrites
the previous file if one exists whereas r+ doesn't overwrite the previously written file. r+ mode creates a new file if no
file exists.
Section B
19. Answer:
1. i. The high frequency wave whose characteristics are altered to superimpose message information, is the
carrier wave and after altering the characteristics, the new resultant wave is called the modulated wave.
ii. Characteristics of Wi-Fi
i. It is a wireless solution for getting connected to the Internet.
ii. It is for short range.
2. OR
i. Optical Fiber Cable:
Advantage: It is free of electrical noise and interference.
Disadvantage: It is an expensive communication medium.
Coaxial cable:
Advantage: It provides a cheap means of transporting multi-channel television signals around metropolitan
areas.
Disadvantage: When using coaxial cables over long distances, signal loss is a disadvantage.
20. import MySQLdb
db=MySQLdb.connect("localhost", "Fact", "Faculty24", "Instd")
cursor=db.cursor()
cursor.execute("DROP TABLE IF EXISTS FACULTY")
sql="""Create Table Faculty(Id Number(3) PRIMARY KEY, LastName CHAR(20) NOT NULL , FirstName
CHAR(30) NOT NULL , locationid Number(6) , phone char(10) , rank char(4) check (rank IN('ASSO', 'FULL',
'ASST', 'INST')), startdate DATE)"""
cursor.execute(sql)
db.close()
21. The immutable types are those that can’t be changed after it is created. In Python, the following types are immutable:
integers, floating-point numbers, Booleans, strings, tuples.
The mutable types are those whose values can be changed in place. Only three types are mutable in Python, these
are lists, dictionaries, and sets.

OR

Output
Output 1 = 22 & 35
Output 2 = 31 & 20
Output 1 = 22 & 35
Output 2 = 31 & 20
22. Answer:
1. No, You need to download separate DB-API for each database you need to access. It defines a standard interface for
Python database access modules.
2. It returns/fetches all (remaining) rows of a query result, in the form of a Python list.
23. for i in range(1, 10):
print(i, i * 1.6)

OR
for i in range(1, 10):
print(i, i * 0.454)
24. i. The binary files store the data in pure binary bytes form and hence can be used on any machine/hardware with
appropriate software. There are no internal conversions added to data such as newlines etc. Binary files require
appropriate software in order to be read and decoded. The machine takes less time to process binary files.
ii. A text file is a computer file that is structured as a sequence of lines of electronic text. The text files store the data in
human readable text format. These have some internal conversions like newlines(\n) etc. Text files are human
readable but are not portable enough.

OR

def Search():
file = open ('CINEMA.DAT', 'rb')
try:
while True:
MULTIPLEX = pickle.load(file)
if MULTIPLEX['MTYPE']=="Comedy":
print(MULTIPLEX)
except EOFError:
file.close()
25. Output of the code is:
This will print something.
Hello!
When we import module, its main program is executed. Therefore, first the statement print "This will print something" is
executed and then print calculate.greet is executed. The function sum() and diff() are not called from Fun.py file, so they
are not executed in the code.
Section C
26. Answer:
1. s = [11, 13, 15]
tot = 0 # tot must be defined before being used
for n in range(len(s)): # built-in function is range() not arange()
tot = tot + s[n] #incorrect indentation and
# s is a list; to access its elements
# square brackets are used
2. P
R
O
G
R
A
M
27. def binary_search(sorted_list, number):
low = 0
high = len(sorted_list)
found = False
while (low < high) and found = False:
mid = int(low+high/2)
if sorted_list[mid] == number:
print ("Number found at",mid)
found = True
break
elif sorted_list[mid] == number:
low = mid + 1
else:
high = mid -1
if low >= high:
print ("Number not found")
max_range = input("Enter Count of numbers:")
numlist = []
for i in range(0, max_range):
numlist_append(input("Enter number : "))
numlist.sort()
print ("Our list : ", numlist)
number = input("Enter the number")
binary_search(numlist, number)
28. Both DDL and DML are SQL components.
Data Definition Language (DDL) statements are used to create the structure of a table, modify and remove the existing
table. Some of the DDL statements are CREATE TABLE, ALTER TABLE and DROP TABLE
Data Manipulation Language (DML) statements are used to access and manipulate data in existing tables. The common
DML statements are SELECT, UPDATE, DELETE and INSERT.

OR

mysql> SELECT job_id, COUNT(*)FROM employees GROUP BY job_id;


29. The output of the given code will be 7 as the given code is counting the number of lines in the file being read. The 'for
loop' increases the value of n1 for every line in the file and then, the value of n1 is printed as the output.
30. i. Syntax error. Colon ( : ) missing in the end of function header. Colon should be added to end of function header.
ii. Syntax error. Keyword to define a function is def ( not define).
Also, colon ( : ) missing in the end of function header.
Return is not a valid statement. It should be return.
iii. No error in function alpha's definition.
Multiple return statements are syntactically legal. But in the above code, the second return statement is unreachable.
You can return multiple values by using return value1, value2.
In function beta()'s definition, Colon (:) missing in the end of function header.
In main part, the colons at the end of first and third print( ) statements is invalid (not enclosed in quotes)
In third print( ) statement, in the function call of alpha( ), positional argument follows keyword argument, which is a
syntax error.
Section D
31. " " "
Stack: implemented as a list
top: integer having a position of a topmost element in Stack
"""
def cls( ):
print("\n"* 100)
def is Empty(stk) :
if stk== [ ] :
return True
else :
return False
def Push(stk, item) :
stk.append(item)
top = len(stk) - 1
def Display(stk) :
if isEmpty(stk) :
print ("Stack empty”)
else :
top = len(stk) - 1
print(stk[top], "<-top")
for a in range(top-1, -1, -1 ) :
print(stk[a])
# main
Stack = [] # initially stack is empty
top = None
while True :
cls()
print ("STACK OPERATIONS")
print("1. Push operation")
print("2. Display stack")
print("3. Exit")
ch = int(input("Enter your choice (1-5) :"))
if ch == 1 :
bno = int(input("Enter Book no. to be inserted :"))
bname = input ("Enter Book name to be inserted :")
item = [bno, bname] # creating a list from the input items.
PushfStack, item)
input()
elif ch == 2 :
Display(Stack)
input( )
elif ch == 3 :
break
else :
print("Invalid choice!")
input()
32. i. COUNT (DISTINCT Publishers)
3
ii. SUM(Price)
1350

iii. Book_Name Author_Name


My first C++ Brian and Brooke
C++Brainworks A.W. Rossaine

Fast cook Lata Kapoor


iv. COUNT (*)
5
Section E
33. i. The most suitable place to house the server is in building JAMUNA because it has the maximum number of
computers.
ii. WAN
iii. a. A switch would be needed in all the building, to interconnect the group of cables from the different computers in
each building.
b. Repeaters may be skipped as per above layout, (because the distance is less than 100 m) however if building
RAVI and building JAMUNA are directly connected, we can place a repeater there as the distance between these
two buildings is more than 100 m.
iv. a. Optical Fiber
34. a. Primary Key of CARDEN = Ccode CARDEN Alternate Key = CarName: Primary key of Customer = Code
Alternate Key of Customer = Cname 2
b. i. SELECT CarName FROM CARDEN WHERE Color = "SILVER";
ii. SELECT CarName, Make, Capacity FROM CARDEN ORDER BY Capacity DESC;
iii. SELECT MAX(Charges) FROM CARDEN;
iv. SELECT Cname, CarName From CUSTOMER CARDEN, WHERE CUSTOMER. Ccode = CARDEN. Ccode;
c. i. 4

ii. MAX(Charges) MIN(Charges)

35 12
iii. 5
iv. SX4
C Class

OR

i. 2

ii. MAX(ScheduleDate) MIN(ScheduleDate)


19-Mar-2004 12-Dec-2003
iii. Ravi Sahai Lawn Tennis
iv. DISTINCT GCode
101
108
103
35. Answer:
1. i. Command line programms: mysqldump and mysqladmin
GUI programs: MySQL Administrator and MySQL QueryBrowser

ii. i. FIRSTNAME SALARY

Sam 75000
Manila 70000

George 75000
ii. COUNT(DISTINCT DESIGNATION)
4

iii. DESIGNATION SUM(SALARY)


Director 85000

Salesman 60000
iv. Error in question - there are no Benefits and Designation columns in table WORKERS. If we assume
and change the table as DESIG for this query, output will be 15000.
2. OR
i. The ORDER BY clause of SQL SELECT statement allows to sort the data of result set. The GROUP BY
clause of SQL SELECT statement allows to create summarized results of grouped data from table.
ii. i. SELECT * FROM
WORKER ORDER BY DOB DESC;
ii. SELECT NAME, DESIG
FROM WORKER
WHERE PLEVEL IN ('P001', 'P002') ;
iii. SELECT * FROM WORKER
WHERE DOB BETWEEN '19-JAN-1984' AND '18-JAN-1987' ;
iv. INSERT INTO WORKER
VALUES(19, 'Daya Kishore', 'Operator' , 'P003' , '19-Jun-2008' , '11-Jul-1984') ;

You might also like