Xii - Set A - CS
Xii - Set A - CS
A
SCHOOLS COMPLEX
CbeSSC PRE BOARD EXAMINATION (December 2024)
MARKING SCHEME
GRADE: XII MARKS: 70
SUBJECT: COMPUTER SCIENCE (083) TIME: 3 HRS
General Instructions:
• This question paper contains 37 questions.
• All questions are compulsory. However, internal choices have been provided in some
questions. Attempt only one of the choices in such questions
• The paper is divided into 5 Sections- A, B, C, D and E.
• Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
• Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
• Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
• Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
• Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.
• In case of MCQ, text of the correct answer should also be written.
Ans:
b) ['apple', 'banana', 'cherry,dates']
5. What will be the output of the following code snippet? 1
a= "Coimbatore Sahodaya" (1 mark
print(a[-3::-3]) for
correct
Ans: answer)
ah obo
6. What will the output of this code be, and why? 1
tuple1 = (5, 6, 7) (1 mark
tuple2 = tuple1 for
tuple1 = tuple1 + (8,) correct
print(tuple1 is tuple2) answer)
a) True – because tuple1 and tuple2 still reference the same tuple object.
b) True – because tuples are immutable, so they remain the same object even
after modification.
c) False – because tuple1 now references a new tuple after concatenation.
d) False – because the + operator creates a mutable copy of the tuple.
Ans:
c) False – because tuple1 now references a new tuple after concatenation
7. What will be the output of this code? 1
dict1 = {'a': [1, 2], 'b': [3, 4]} (1 mark
dict2 = dict1 for
dict2['a'].append(5) correct
dict2['c'] = [6, 7] answer)
print(dict1)
print(dict1 == dict2)
Ans:
a) {'a': [1, 2, 5], 'b': [3, 4], 'c': [6, 7]}
True
8. What type of error will the following code raise when executed? 1
my_list = [1, 2, 3] (1 mark
my_list[5] = 10 for
correct
a) IndexError b) ValueError c) TypeError d) KeyError answer)
Ans:
a) IndexError
9. If a table has one Primary key, one Composite key (made up of two columns), 1
and two alternate keys, how many Candidate keys will this table have? (1 mark
a) 1 b) 2 c) 3 d) 4 for
Ans: correct
d)4 answer)
10. What will the following code snippet output when executed? 1
(1 mark
file = open("test.txt", "w") for
file.write("Hello\n") correct
file.write("World\n") answer)
file.close()
Ans:
c) Hello\n
11. State whether the following statement is True or False: 1
Using the raise statement without any arguments in Python re-raises the last (1 mark
exception that was active in the current scope. for
correct
Ans: True answer)
12. What will be the output of the above code? 1
a=4 (1 mark
def increment(): for
global a correct
a += 3 answer)
print(a, end='@')
increment()
a = 20
print(a, end='#')
Ans:
a) 7@20#
13. Which command would you use to rename a table from old_table to new_table in 1
MySQL? (1 mark
for
Ans: correct
ALTER TABLE old_table RENAME TO new_table; answer)
14. Which of the following statements about SQL constraints is TRUE? 1
(1 mark
a) A PRIMARY KEY constraint allows multiple NULL values in a column. for
b) A FOREIGN KEY constraint is used to ensure data integrity between two correct
tables. answer)
c) A UNIQUE constraint allows duplicate values in a column.
d) A CHECK constraint is used to ensure that all values in a column are the same
Ans:
b) A FOREIGN KEY constraint is used to ensure data integrity between two
tables.
15. Which of the following SQL data types is specifically used to store date and time 1
values? (1 mark
a) DATE b) VARCHAR c) TIMESTAMP d) INT for
correct
Ans: answer)
c) TIMESTAMP
16. Which of the following SQL statements is correct to calculate the total sales for 1
each product in a Sales table? (1 mark
a) SELECT product_id, SUM(sales_amount) FROM Sales; for
b) SELECT product_id, SUM(sales_amount) FROM Sales GROUP BY correct
product_id; answer)
c) SELECT product_id, COUNT(sales_amount) FROM Sales;
d) SELECT product_id, AVG(sales_amount) FROM Sales GROUP BY
sales_amount;
Ans:
b) SELECT product_id, SUM(sales_amount) FROM Sales GROUP BY
product_id;
17. Which of the following is NOT a characteristic of a Local Area Network (LAN)? 1
a) Covers a small geographic area (1 mark
b) High data transfer rates for
c) Limited to a single building or campus correct
d) Typically uses public communication channels answer)
Ans:
d) Typically uses public communication channels
18. Which device can be used to create a network that connects multiple devices and 1
manages traffic within that network? (1 mark
a) Hub b) Switch c) Bridge d) Modem for
Ans: correct
b) Switch answer)
19. Which of the following formats is correct for representing a MAC address? 1
a) 192.168.0.1 b) AA:BB:CC:DD:EE c) 10.0.0.1 d) 256.255.255.0 (1 mark
for
Ans: correct
b) AA:BB:CC:DD:EE answer)
Q20 and 21 are ASSERTION AND REASONING based questions. Mark the
correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b)Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d)A is false but R is True
20. Assertion (A): The read() method in Python reads the entire contents of a file as 1
a single string. (1 mark
Reason (R): The readline() method in Python reads the entire file line by line and for
returns all lines as a single string. correct
answer)
Ans:
c) A is True but R is False
21. Assertion (A): In Python’s MySQL connector, using execute() within a try- 1
except block can help handle SQL execution errors gracefully. (1 mark
Reason (R): If an error occurs during SQL execution, the MySQL connector will for
raise an OperationalError exception that can be caught and managed within the correct
except block. answer)
Ans:
b)Both A and R are true and R is not the correct explanation for A
SECTION- B (7x2=14)
22. What is the difference between the formal parameters and actual parameters? 2
What are their alternative names? Each
Ans: correct
Formal Parameters (Parameters or Placeholders) key
These are the variables listed in a function's definition, acting as placeholders for differenc
values that will be passed to the function. Formal parameters define the number e- ½
and type of inputs the function will accept. mark,
Actual Parameters (Arguments) Each
These are the actual values or expressions passed to a function when it is called. correct
Actual parameters provide the data that will replace the formal parameters in the alternativ
function's execution. e name-
½ mark
Key differences:
Ans:
(ii) 30#40#50#
Maximum value for FROM,TO are 3,4 respectively.
26. The given Python code to print all Prime numbers in an interval (range) 2
inclusively. The given code accepts 02 number (low & high) as arguments for the Each
function Prime_Series() and return the list of prime numbers between those two correctio
numbers inclusively. Observe the following code carefully and rewrite it after n½
removing all syntax and logical errors. Underline all the corrections made. mark,
def Prime_Series(low, high) writing
primes = [] correct
for i in range(low, high + 1): code ½
flag = 0 mark,
if i < 2: underline
continue ½ mark
if i == 2:
primes.append(2)
continue
for x in range(2, i):
if i % x == 0:
flag = 1
continue
if flag == 0:
primes.append(i)
return primes
low=int(input("Lower range value: "))
high=int(input("High range value: ")
print(Prime_Series())
Ans:
def Prime_Series(low, high)
primes = []
for i in range(low, high + 1):
flag = 0
if i < 2:
continue
if i == 2:
primes.append(2)
continue
for x in range(2, i):
if i % x == 0:
flag = 1
break #correction 1
if flag == 0:
primes.append(i)
return primes
low=int(input("Lower range value: "))
high=int(input("High range value: ")
print(Prime_Series(low,high)) #correction 1
27. Consider a MySQL table named “Students” with columns – RollNo, Name, 2
Marks. Write SQL commands to: Each
(i) Add a new column named ‘Phone’ to store the phone number of the students. correct
(ii) Set RollNo as the primary key of the table. answer 1
Ans: mark
i) ALTER TABLE Students ADD Phone VARCHAR(15);
ii) ALTER TABLE Students ADD PRIMARY KEY (RollNo);
OR
Consider a MySQL table named “Books” with columns – BookID, BookName,
Pages, Price, Rating. The rating column has data type INT. Write SQL
commands to:
(i) Change the data type of rating column to allow for floating point values (1.0
to 5.0)
(ii) Delete the pages column from the database.
Ans:
i) ALTER TABLE Books MODIFY Rating number(2, 1);
ii) ALTER TABLE Books DROP COLUMN Pages;
28. a) When a user browses a website, the web server sends a text file to the web 2
browser. What is the name of this? 1 mark
b) What is the purpose of server in a network? for
Ans: correct
a) Cookies answer
b) A server manages network resources in a network.
SECTION- C (3x3=9)
29. Write a method/function DISPLAYWORDS() in python to read lines from a text 3
file STORY.TXT, and display those words, which are less than 4 characters. (½ mark
def DISPLAYWORDS(): for
C=0 opening
file=open('STORY.TXT', 'r') the file)
line=file.read() (½ mark
word = line.split() for
for w in word: reading
if len(w)<4: lines
print(w) and/or
file.close() splitting)
(1 mark
OR for
Write a function in Python to read a text file, Result.txt and displays those lines checking
which contains at least 5 words. condition
def display_lines_with_min_words(file_name="Result.txt", min_words=5): ) (½
with open(file_name, 'r') as file: Mark for
for line in file: printing
words = line.split() word)
if len(words) >= min_words: (½ mar
print(line.strip()) for
display_lines_with_min_words() closing
the file)
30. A list contains following record of a customer: 3
[Customer_name, Phone_number, City] (3x1
mark for
Write the following user defined functions to perform given operations on the correct
stack named ‘status’: function
(i) Push_element() - To Push an object containing name and Phone number of body; No
customers who live in Goa to the stack. marks
(ii) Pop_element() - To Pop the objects from the stack and display them. Also, for any
display “Stack Empty” when there are no elements in the stack. function
(iii) Peak_element(): This function displays the topmost element of the stack header as
without deleting it. If the stack is empty, the function should display 'None'. it was a
part of
For example: the
If the lists of customer details are: question)
[“Gurdas”, “99999999999”,”Goa”]
[“Julee”, “8888888888”,”Mumbai”]
[“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]
Ans:
# Initialize the stack
status = []
Ans:
47.0
35.0
4.0
26.0
OR
(half of
Predict the output: the
text="LearningCS" output 1
L=len(text) ½ mark,
ntext="" correct
for i in range (0,L): case ans
if text[i].islower(): another
ntext=ntext+text[i].upper() half 1 ½
elif text [i].isalnum(): mark)
ntext=ntext+text[i-1]
else:
ntext=ntext+'&&'
print(ntext)
Ans:
SEARNINGgC
SECTION-D (4x4=16)
32. A departmental store MyStore is considering to maintain their inventory using 4
SQL to store the data. As a database administer, Abhay has decided that: (i,ii –
Name of the database - mystore each 1
Name of the table – STORE mark)
The attributes of STORE are as follows: (iii –
ItemNo- numeric each 1
ItemName - character of size 20 mark)
Scode - numeric
Quantity – numeric
In
common
(half of
the
query- ½
mark,
another
half of
the
query– ½
mark)
(i) Identify the attribute best suitable to be declared as a primary key.
(ii) Write the degree and cardinality of the table STORE.
(iii) Write the commands to
(a) Insert the following data into the attributes Item No, ItemName and SCode
respectively in the given table STORE Item No = 2010, ItemName = "Note
Book" and Scode = 25
(b) remove the table STORE from the database MyStore.
Ans:
(i) ItemNo
(ii) Degree = 4 Cardinality = 7
(iii) (a) INSERT INTO store (ItemNo, ItemName, Scode) VALUES(2010,
"Note Book",25);
(b) DROP TABLE store;
33. Write a Program in Python that defines and calls the following user 4
defined functions:
(i) add() – To accept and add data of a toystore to a CSV file ‘toydata.csv’. Each
record consists of a list with field elements as tid, tname and tprice to store toy id, (½ mark
toy name and toy price respectively. for
(ii) search()- To display the records of the toys whose price is more than 500. importin
g csv
Ans: module
import csv
def add(): 1½
fout=open("toydata.csv","a",newline='\n') marks
wr=csv.writer(fout) each for
tid=int(input("Enter Toy Id :: ")) correct
tname=input("Enter toy name :: ") definitio
tprice=int(input("Enter toy price :: ")) n of
TD=[tid,tname,tprice] add() and
wr.writerow(TD)
fout.close()
def search(): 1½
fin=open("toydata.csv","r",newline='\n') marks
data=csv.reader(fin) each for
found=False correct
print("The Details are: ") definitio
for i in data: n of
if int(i[2])>500: search()
found=True
print(i[0],i[1],i[2]) ½ mark
if found==False: for
print("Record not found") function
fin.close() call
add() statemen
print("Now displaying") ts)
search()
34. In a database High sport there are two tables: students and sports with the 4
instances given below:
Each
correct
query- 1
mark
(in
common
- half of
the
query- ½
mark,
second
half of
Write the SQL queries for the following statements: the
(i) To display name and game of those students whose address is available in query- ½
students’ table. mark)
(ii) To delete a column phone from the table students.
(iii) To display names of those students who are studying in class 12 and their
corresponding coach names is their admission number.
(iv) To count the number of students who play volleyball.
Ans.
(i) Select name, game from students,sports where
students.admno=sports.admno and address is not null;
(ii) alter table students drop phone;
(iii) select name,coachname from students,sports where class like “12%”
and students.admno=sports.admno;
(iv) select count(*) from students,sports where game=”volleyball” and
students.admno=sports.admno;
35. You are tasked with creating a Python function to manage users in a database. 4
You have a table named USERS in a database called USERDB with the
following structure:
Connecti
Column Name Data type on code-
UserID Integer 1 mark
Name Varchar(30) User
Email Varchar(30) input- 1
Age Integer mark
AccountBalance Decimal(10,2) Inserting
record- 1
Write a Python function named AddUserAndDisplay() that performs the mark,
following operations: select- 1
✓ Connects to the USERDB database using the following credentials: mark
Host: localhost, User: admin, Password: Admin123
✓ Prompts the user to input the details of a user, including: (any
User ID, Name, Email, Age, and Account Balance. other
✓ Inserts the user details into the USERS table. valid
✓ Retrieves and displays all records from the USERS table where the code can
account balance is greater than 100. be
consider
Ans: ed)
import mysql.connector
def AddUserAndDisplay():
connection = mysql.connector.connect(
host='localhost',
user='admin',
password='Admin123',
database='USERDB' )
if connection.is_connected():
print("Connected to USERDB database.")
user_id = int(input("Enter User ID (positive integer): ")) # Assuming
User ID is an integer
name = input("Enter Name: ")
email = input("Enter Email: ")
age = int(input("Enter Age (positive integer): "))
account_balance = float(input("Enter Account Balance (non-negative):
"))
cursor = connection.cursor()
insert_query = """INSERT INTO USERS (UserID, Name, Email, Age,
AccountBalance)
VALUES (%s, %s, %s, %s, %s)"""
cursor.execute(insert_query, (user_id, name, email, age,
account_balance))
connection.commit()
print("User details added successfully.")
select_query = "SELECT * FROM USERS WHERE AccountBalance >
100"
cursor.execute(select_query)
records = cursor.fetchall()
if records:
print("\nUsers with account balance greater than 100:")
for record in records:
print(record)
else:
print("\nNo users found with account balance greater than 100.")
if connection.is_connected():
cursor.close()
connection.close()
print("Database connection closed.")
AddUserAndDisplay()
SECTION-E (2x5=10)
36. (i) What is the difference between seek() and tell()? 5
Ans: i)correct
seek(): this method is used to position the file object at a particular position answer 1
in a file. The syntax of seek() is: file_object.seek(offset [, reference_point]) mark
* offset is the number of bytes by which the file object is to be moved. ii) write
* reference_point indicates the starting position of the file object. That is, file- 2
with reference to which position, the offset has to be counted. It can have any marks(op
of the following values: 0- beginning of the file 1-current position of the file en(),
2- end of fil input- 1
tell(): This function returns an integer that specifies the current position of mark,
the file object in the file. That is the byte position from the beginning of the dump,fil
file till the current position of the file object. The syntax of using tell() is: e close-
file_object.tell() 1 mark)
(ii) A binary file “STUD.DAT” has structure (admission_number, Name, read file-
total_mark) with student details. 2 marks
• Write a user defined function WriteFile() to create a file input data for a record (open,
and write to “stud.dat” file. The number of records to be entered until the user condition
chooses ‘Y’ / ‘Yes’. - 1 mark,
• Write a function ReadFile() in Python that would read the contents of the file print- ½
“STUD.DAT” and display the details of those students whose total mark is less mark, try
than or equal to 250 under the printed heading "REMEDIAL STUDENT LIST “. except-
Also display and the number of students scoring above 250 marks as Bright ½ mark)
Student.(using try..except)
Ans:
import pickle
def WriteFile():
fobj=open("stud.dat","wb")
ch='y'
while ch.upper()=='Y':
admission_number=int(input("Enter Admission Number : "))
name=input("Enter Student Name :")
total_mark = int(input("Enter total mark : "))
rec=[admission_number, name, total_mark]
pickle.dump(rec,fobj)
print("\n Have you any more record to enter: ", end='')
ch=input()
fobj.close()
def ReadFile():
fobj=open("stud.dat","rb")
bright = 0
print("**************** REMEDIAL STUDENT LIST
**************")
print("Admission No\tName of the Student\tTotal_mark")
try:
while True:
rec=pickle.load(fobj)
if rec[2]<=250:
print("\t",rec[0],"\t",rec[1], "\t\t", rec[2])
else:
bright = bright + 1
except:
fobj.close()
return bright
WriteFile()
print("No. of Bright students: ",ReadFile())
37. Meticulous EduServe is an educational organization. It is planning to setup 5
its India campus at Chennai with its head office at Delhi. The Chennai campus Each
has 4 main buildings – ADMIN, ENGINEERING, BUSINESS and MEDIA. correct
answer –
a) Suggest and draw the 1 mark
cable layout to efficiently
connect various blocks of
buildings within the
CHENNAI campus for
connecting the digital
devices.
c) Which block, in
Chennai Campus should
be made the server?
Justify your
answer.
e) Is there a requirement
of a repeater in the given cable layout? Why/
Why not?
Ans:
a)
b) Switch
c) Admin block, as it has maximum number of computers.
d) Microwave
e) No, a repeater is not required in the given cable layout as the length of
transmission medium between any two blocks does not exceed 70 m.