Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
75 views15 pages

12 Computer Science SP 08 With Solution

Uploaded by

advit.amit123
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)
75 views15 pages

12 Computer Science SP 08 With Solution

Uploaded by

advit.amit123
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/ 15

Class 12 - Computer Science

Sample Paper - 08 (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 string can be surrounded by three sets of single quotation marks or by three sets of double quotation marks.
a) True
b) False
2. What is the full form of DDL?
a) Data Definition Language
b) Dynamic Data Language
c) Detailed Data Language
d) Data Derivation Language
3. User can write Python script using
a) SQL.connect library
b) MySQL.connector library
c) MySQL.connect library
d) None of these
4. Following set of commands are executed in shell, what will be the output?
>>> str = "hello"
>>> str[:2]
a) he
b) llo
c) ello
d) hel
5. Which of the following is the fastest media of data transfer?
a) Fibre Optic
b) Telephone Lines
c) Untwisted Wire
d) Co-axial Cable
6. Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which of the following option can
be used to read all the remaining lines?
a) myfile.read(n-3)
b) myfile.readlines()
c) myfile.read(n)
d) myfile.readline()
7. What is the advantage of DBMS over File Processing System?
a) Redundancy is controlled.
b) It provides backup and recovery.
c) It provides multiple user interfaces.
d) All of these
8. The operation whose result contains all pairs of tuples from the two relations, regardless of whether their attribute values
match.
a) Intersection
b) Set difference
c) Join
d) Cartesian product
9. Which of the following mode will refer to binary data?
a) b
b) w
c) +
d) r
10. Which of the given argument types can be skipped from a function call?
a) positional arguments
b) default arguments
c) keyword arguments
d) named arguments
11. Which data structure is needed to convert infix notation to postfix notation?
a) Tree
b) Stack
c) Queue
d) Branch
12. Which of the following functions removes all leading and trailing spaces from a string?
a) rstrip()
b) lstrip()
c) strip()
d) all of these
13. State true or false:
DNS is a network service type.
a) True
b) False
14. Which of the following cannot be a variable?
a) _on
b) _it
c) in
d) _init_
15. Fill in the blanks:
Columns can be sorted in descending sequence by using the SQL keyword .
16. Find ODD parity bit for 10010001
a) 2
b) 0
c) none of these
d) 1
17. Assertion (A): When the comparison operator is directly applied to a series object, it returns a filtered result containing
the value that returns true.
Reason (R): Applying comparison operator on series works in vectorized way.
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): flush() function flushes the write buffer of the file stream.
Reason (R): The isatty() method, returns True if the file stream is distinct.
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 do you mean by firewall?
ii. For secure transmission through unguided media, which ones would you avoid?
2. OR
i. Wireless networks employ strategies to avoid collisions. Why can't they detect collisions?
20. List the most common parameters and the usage that are passed to communicate with the database.
21. How many times will the given loop iterate?

i = 0
while (i < 25):
print("Python")
i = i + 1

OR

Write a program that rotates the elements of a list so that the element at the first index moves to the second index, the
element in the second index moves to the third index, etc., and the element in the last index moves to the first index.
22. Answer:
1. Which method creates and returns a cursor object that may be used to execute SQL commands?
2. What does connection.commit( ) method do?
23. Write a Python program to concatenate following dictionaries to create a new one.
d1 = {'A': 10, 'B' : 20}
d2 = {'C': 30, 'D' : 40}
d3 = {'E': 50, 'F' : 60}

OR
Observe the output
i. >>> x = ‘Sum' * '3'
ii. >>> x = ‘Sum' + '3'
24. Write a program to accept a filename from the user and display all the lines from the file which contain Python comment
character '# '.

OR

Write a function to count the number of alphabets present in a text file "NOTES.txt".
25. 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)

Section C
26. Answer:
1. Find the syntax error in the following program and underline after correct them.

w = 90;
while (w > 60)
print (w)
w = w - 50

2. Find the output of following code

dic = {"Nitin" : (21, "NIIT") , "Ankit" : (15, "NIIT")}


print("The original dictionary : " , str(dic))
result = [(key, i , j ) for key, ( i , j ) in dic.items()]
print("The list after conversion : ",str(result))

27. Define a function overlapping () that takes two lists and returns true if they have at least one member in common, False
otherwise.
28. Explain the use of ORDER BY clause.

OR

How to create a database?


29. Write a function CountYouMe() in Python which reads the contents of a text file Notes.txt and counts the words You and
Me (not case sensitive).
30. What is the difference between a local variable and a global variable? Also, give a suitable Python code to illustrate both.
Section D
31. Each node of a STACK contains the following information :
i. Pin code of a city,
ii. Name of the city.

Write a program to implement the following operations in the above stack


i. PUSH( ) To push a node into the stack.
ii. POP( ) To remove a node from the stack.
32. Study the following tables FLIGHTS and FARES and write SQL commands for the questions (i) to (iv).

TABLE: FLIGHTS

FL_NO STARTING ENDING NO_FLIGHT NO_STOPS

IC301 MUMBAI DELHI 8 0


IC799 BENGALURU DELHI 2 1

MC101 INDORE MUMBAI 3 0


IC302 DELHI MUMBAI 8 0

AM812 KANPUR BENGALURU 3 1


IC899 MUMBAI KOCHI 1 4

AM501 DELHI TRIVANDRUM 1 5


MU499 MUMBAI MADRAS 3 3

IC701 DELHI AHMEDABAD 4 0

TABLE: FARES

FL_NO AIRLINES FARE TAX%

IC701 INDIAN AIRLINES 6500 10


MU499 SAHARA 9400 5
AM501 JET AIRWAYS 13450 8
IC899 INDIAN AIRLINES 8300 4

IC302 INDIAN AIRLINES 4300 10


IC799 INDIAN AIRLINES 10500 10

MC101 DECCAN AIRLINES 3500 4


i. Display FL_NO and NO_FLIGHT from KANPUR to BENGALURU from the table FLIGHTS.
ii. Arrange the contents of the table FLIGHTS in the ascending order of FL_NO.
iii. Display the FL_NO and fare to be paid for the flights from DELHI to MUMBAI using the tables FLIGHTS and
FARES, where the fare to be paid = FARE + FARE * TAX % 100.
iv. Display the minimum fare INDIAN AIRLINES is offering from the table FARES.
v. To display the detail fares of Indian airlines.
Section E
33. Institute of Distance Learning is located in Pune and is planning to go in for networking of four wings for better
interaction. The details are shown below:
The distance between various wings

Student Wing to Admin Wing 150 m

Student Wing to Admission Wing 100 m


Student Wing of Lib Wing 325 m

Admission Wing to Admin Wing 100 m


Admission Wing to Lib Wing 125 m

Admin Wing to Lib Wing 90 m

Number of computers

Student Wing 225


Admission Wing 50

Admin Wing 10
Lib Wing 25
i. Suggest the type of networking (LAN, MAN, WAN) for connecting Lib Wing to Admin Wing. Justify your answer.
ii. Suggest the most suitable place (i.e. wing) to house the server, with a suitable reason.
iii. Suggest and placement of the following devices with reasons.
a. Repeater
b. Switch
iv. The Institute is planning to link its study centre situated in Delhi. Suggest an economic way to connect it with
reasonably high speed. Justify your answer.
v. Expand the following
PAN
WAN
34. Sarthak a student of class XII, created a table” Class” with following attribute Sname, Sroll,Smark and Grade . Grade is
one of the columns of this table. To find the details of students where Grades have not been entered, he wrote the
following Mysql query which did not give the desired result:
SELECT Sname FROM Class WHERE Grade=”Null”;
SELECT Sroll FROM Class WHERE Grade=”Null”;
SELECT Smark FROM Class WHERE Grade=”Null”;
SELECT * FROM Class WHERE Grade=”Null”;
SELECT Grade FROM Class WHERE Grade=”Null”;
Help Sarthak to run the query by removing the errors from the query and write the correct query.

OR

Give output for following SQL queries as per given table(s) :


Table: Books

Book_Id Book_Name Author_Name Publishers Price Type Qty.

C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5


F0001 The Tears William Hopkins First Publ. 650 Fiction 20

T0001 My First C++ Brian and Brooke EPB 350 Text 10


T0002 C++ Brainworks A.W. Rossaine TDH 350 Text 15

F0002 Thunderbolts Anna Roberts First Publ. 750 Fiction 50

Table: Issued

Book_Id Quantity_Issued

T0001 4
C0001 5

F0001 2
i. SELECT COUNT() FROM Books;
ii. SELECT MAX(Price) FROM Books WHERE Quantity >= 15;
iii. SELECT Book_Name, Author_Name FROM Books WHERE Publishers = "EPB";
iv. SELECT COUNT (DISTINCT Publishers) FROM Books WHERE Price >= 400;
35. Answer:
1. i. What is data redundancy? What are the problems associated with it?
ii. Consider the following tables WORKER and PAYLEVEL and answer the following parts of this question :

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

Table : PAYLEVEL
PLEVEL PAY ALLOWANCE

P001 26000 12000


P002 22000 10000

P003 12000 6000

Give the output of the following SQL queries:


i. SELECT COUNT (PLEVEL), PLEVEL FROM WORKER GROUP BY PLEVEL;
ii. SELECT MAX(DOB), MIN(DOJ) FROM WORKER;
iii. SELECT Name, Pay FROM WORKER W, PAYLEVEL P
WHERE W.PLEVEL = P.PLEVEL AND W.ECODE < 13;
iv. SELECT PLEVEL, PAY + ALLOWANCE FROM PAYLEVEL WHERE PLEVEL = 'P003';
2. OR
i. What is wrong with the following statement?
SELECT * FROM Employee
WHERE grade = NULL;
Write the corrected form of the above SQL statement.
ii. Consider the following tables GARMENT and FABRIC. Write SQL commands for the statements (i) to (v).

TABLE: GARMENT

GCODE DESCRIPTION PRICE FCODE READYDATE


10023 PENCIL SKIRT 1150 F03 19-DEC-08
10001 FORMAL SHIRT 1250 F01 12-JAN-08

10012 INFORMAL SHIRT 1550 F02 06-JUN-08


10024 BABY TOP 750 F03 07-APR-07

10090 TULIP SKIRT 850 F02 31-MAR-07


10019 EVENING GOWN 850 F03 06-JUN-08

10009 INFORMAL PANT 1500 F02 20-OCT-08


10007 FORMAL PANT 1350 F01 09-MAR-08

10020 FROCK 850 F04 09-SEP-07


10089 SLACKS 750 F03 20-OCT-08

TABLE: FABRIC

FCODE TYPE

F04 POLYSTER
F02 COTTON

F03 SILK
F01 TERELENE
i. To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.
ii. To display the details of all the GARMENTS, which have READYDATE in between 08-DEC-07 and
16-JUN-08 (inclusive of both the dates).
iii. To display the average PRICE of all the GARMENTS. Which are made up of FABRIC with FCODE as
F03.
iv. To display FABRIC wise highest and lowest price of GARMENTS from GARMENT table. (Display
FCODE of each GARMENT alongwith highest and lowest price.)
v. To display garment’s description with their price whose fabric is silk.
Class 12 - Computer Science
Sample Paper - 08 (2023-24)

Solution

Section A
1. (a) True
Explanation: True, A string can be surrounded by three sets of single quotation marks or by three sets of double
quotation marks.
2. (a) Data Definition Language
Explanation: Data Definition Language is a language used to define data structures and modify data.
3. (b) MySQL.connector library
Explanation: MySQL.connector library
4. (a) he
Explanation: str[:2] prints only the values at index 0 and 1 (as 2 is exclusive) of string and hence the answer is “he”.
5. (a) Fibre Optic
Explanation: Fibre Optic
6. (b) myfile.readlines()
Explanation: myfile.readlines()
7. (d) All of these
Explanation: It provides all the mentoined features.
8. (d) Cartesian product
Explanation: Cartesian product is the multiplication of all the values in the attributes.
9. (a) b
Explanation: b, binary mode is referred for binary data.
10. (b) default arguments
Explanation: default arguments
11. (b) Stack
Explanation: The stack data structure is needed to convert infix notation to postfix notation.
12. (c) strip()
Explanation: strip()
13. (a) True
Explanation: True
14. (c) in
Explanation: in is a keyword
15. 1. DESC
2. DESC , used with ORDER BY
16. (b) 0
Explanation: Parity refers to the number of bits set to 1 in the data item
Even parity - an even number of bits are 1
Odd parity - an odd number of bits are 1
A parity bit is an extra bit transmitted with a data item, chose to give the resulting bits even or odd parity
Even parity - data: 10010001, parity bit 1
Odd parity - data: 10010001, parity bit 0
17. (d) A is false but R is true.
Explanation: Applying comparison operator on series works in vectorized way i.e applies this check on each element
and then return true/ false for each element.
18. (c) A is true but R is false.
Explanation: The flush() function flushes the write buffer of the file stream and isatty() function returns True if the file
stream is interactive otherwise it return False.
Section B
19. Answer:
1. i. A firewall is a piece of security software or hardware designed to protect web servers.
ii. Microwave and Radio wave are avoided for secure transmission through unguided media.
2. OR
i. In wireless, we don't have the luxury of detecting collisions and resending packets because there's no way to
detect a collision over the air. Collisions occur when multiple transmissions take place at the same over a
network. Wireless networks are half-duplex in nature, i.e., they cannot listen while transmitting (and while
listening, they cannot transmit - only one operation at a time). Hence they cannot find out if any other
transmission is taking place simultaneously, and thus cannot detect collisions.

20. Parameter Usage


Dsn Data source name. This usually includes the name of your database and the server where it's running.
Host Host, or network system name, on which the database runs.

Database The name of a valid user for the database.


User User name for connecting to the database

Password The password for the user name that you provided to connect to the database.
21. 25 times

OR

lis = eval(input ("Enter list:"))


last = lis[-1]
for i in range(len(lis) -1, 0, -1):
lis[i] = lis[i - 1]
lis[0] = last
print(lis)
22. Answer:
1. The cursor method of connection object, i.e., connection.cursor( ) method.
2. This method sends a COMMIT statement to the MySQL server, committing the current transaction. Since by default
Connector/Python does not auto-commit, it is important to call this method after every transaction that modifies data
for tables.

23. d1 = {'A' : 10, 'B' : 20}


d2 = {'C' : 30, 'D' : 40}
d3 = {'E' : 50, 'F' : 60}
d4 = {}
for i in (d1, d2, d3):
d4.update(i)
print(d4)

OR
i. It will give TypeError and correct code is x = ‘Sum’ * 3
ii. Sum3
24. file_name = raw_input("Enter file name or path:")
try:
for line in open(file_name):
line = line.strip() #remove extra spaces
if line[0]=='#':
print line
except:
print "File Not Found"

OR

def count_alphabet():
file_name="NOTES.txt"
ctr = 0
with open(file_name, 'r') as fileObject:
for line in fileObject:
for word in line:
for char in word:
if char.isalpha():
ctr = ctr + 1
print(ctr)
25. Output
49
25
9
1
Section C
26. Answer:
1. Correct code is
w = 90
while(w > 60) :
print(w)
w = w - 50
2. Output
The original dictionary : {'Ankit' : (15, 'NIIT'), 'Nitin' : (21, 'NIIT')}
The list after conversion : [( 'Ankit', 15, 'NIIT'), ('Nitin', 21, 'NIIT')]
27. def overlapping (list1, list2):
len_1 = len(list1)
len_2 = len(list2)
for i in range (0, len_1):
for j in range (0, len_2):
if list1[i]==list2[j]:
return True
else:
return False
28. The ORDER BY keyword is used to sort the result set along a specified column with the SELECT command.
The ORDER BY keyword sorts the records in ascending order by default. If you want to sort the records in a descending
order, you can use the DESC keyword.
Syntax

SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC/DESC;

OR

Create a database Creating database is an easier task. You need to just type the name of the database in a CREATE
DATABASE command.
Syntax
CREATE DATABASE [IF NOT EXISTS]<database_name>;
CREATE DATABASE command will create an empty database with the specified name and would not contain any
table.
IF NOT EXISTS is an optional part of this statement which prevents you from an error if there exists a database with
the given name in the database catalog.
For example, mysql>CREATE DATABASE BOOK;
Output Query OK, 1 row affected <0.01 sec>
29. CountYouMe function will count the number of occurences of word You and Me in the file given.
def CountYouMe():
wordlist = [line.strip() for line in open(‘Notes.txt’)]
# Searching for a word in a file
count =0
for word in wordlist:
words = word.split(" ")
for word in words:
# Remove all leading and trailing white spaces
word =word.strip().lower()
if word == 'you' or word=='me'():
count = count + 1
if count == 0:
print ("Not found in file")
else:
print ("count=", count)
Example: If the file contains
You are my best friend
You and me make a good team.
Output would be: count=3
30. The differences between a local variable and a global variable are as given below :
Local Variable Global Variable
1. It is a variable which is declared within a function or within a 1. It is a variable which is declared outside all the
block functions

2. It is accessible only within a function/block in which it is 2. It is accessible throughout the program


declared

3.Local variables are created when the function has started 3.Global variable is created as execution starts
execution and are lost when the function terminates. and is lost when the program ends.

For example, in the following code, x, xCubed are global variables and n and cn are local variables.
def cube(n):
cn = n * n * n
return cn
x = 10
xCubed = cube(x)
print(x, "cubed is", xCubed)
Section D
31. MAX_SIZE = 1000
stack = [0 for i in range(MAX_SIZE)]
top = 0
def isEmpty():
global top
return top == 0
def push(x):
global stack, top
if top >= MAX_SIZE:
return
stack[top] = x
top += 1
def pop():
global stack, top
if isEmpty():
return
else:
top -= 1
return stack[top]
string = input().split()
for i in string:
push(i)
while not isEmpty():
x = pop()
print(x+x, end = ' ')
32. i. SELECT FL_NO, NO_FLIGHT FROM FLIGHTS WHERE STARTING = 'KANPUR' AND ENDING =
'BENGALURU';
ii. SELECT * FROM FLIGHTS ORDER BY FL_NO;
iii. SELECT FL_NO, FARE + FARE * TAX%100 FROM FARES WHERE FL_NO = (SELECT FL_NO FROM
FLIGHTS WHERE STARTING='DELHI' AND ENDING='MUMBAI');
iv. SELECT MIN(FARE) FROM FARES GROUP BY AIRLINES HAVING AIRLINES='INDIAN AIRLINES’;
v. SELECT * FROM FARES WHERE AIRLINES="Indian Airlines";
Section E
33. i. Since, the distance between Lib Wing and Admin Wing is small. So type of networking is small, i.e. LAN.
ii. Since, maximum number of computers are in Student Wing, so suitable place to house the server is Student Wing.
iii. a. Repeater should be installed between Student Wing and Admin Wing as distance is more than 60 m.
b. Switch should be installed in each wing to connect several computers.
iv. Broadband connection as it is between economical and speedy.
v. Personal Area Network
Wide Area Network
34. SELECT Sname FROM Class WHERE Grade IS ”Null”;
SELECT Sroll FROM Class WHERE Grade IS ”Null”;
SELECT Smark FROM Class WHERE Grade IS ”Null”;
SELECT * FROM Class WHERE Grade IS ”Null”;
SELECT Grade FROM Class WHERE Grade IS ”Null”;

OR

i. COUNT()
5
ii. MAX(Price)
750

iii. iii. Book_Name Author_Name

Fast Cook Lata Kapoor


My First C++ Brian and Brooke
iv. COUNT (DISTINCT Publishers)
1
35. Answer:
1. i. Data redundancy means having multiple copies of the same data in the database. It leads to problems like
wastage of space and data inconsistency.

ii. i. COUNT (PLEVEL) PLEVEL

1 P001
2 P003
2 P002
ii.
MAX (DOB) MIN (DOJ)

12-3ul-1987 13-Sep-2004
iii.
Name Pay
Radhe Shyam 26000
Chander Nath 12000
iv.
PLEVEL PAY+ALLOWANCE

P003 18000
2. OR
i. IS NULL should be used in place of = NULL. Following is the correct statement: SELECT * FROM
employee WHERE grade IS NULL ;
ii. i. SELECT GCODE, DESCRIPTION FROM GARMENT ORDER BY GCODE DESC;
ii. SELECT * FROM GARMENT
WHERE READYDATE BETWEEN '08-DEC-07' AND '16-JUN-08';
iii. SELECT AVG(PRICE) FROM GARMENT WHERE FCODE='F03';
iv. SELECT-FCODE, MAX(PRICE), MIN(PRICE)
FROM GARMENT GROUP BY FCODE;
v. SELECT DESCRIPTION, PRICE FROM GARMENT
WHERE GARMENT.FCODE = FABRIC.FCODE AND TYPE ="SILK";

You might also like