Computer Science
Computer Science
Page: 1/11
14. (A) Details of all products whose names start with 'App'
(1)
(1 mark for correct answer)
15. (D) CHAR
(1)
(1 mark for correct answer)
16. (B) count()
(1)
(1 mark for correct answer)
17. (B) FTP
(1)
(1 mark for correct answer)
18. (B) Gateway
(1)
(1 mark for correct answer)
19. (B) Packet Switching
(1)
(1 mark for correct answer)
20. (C) A is True but R is False.
(1)
(1 mark for correct answer)
21. (C) A is True but R is False.
(1)
(1 mark for correct answer)
Page: 2/11
(II)
A) L1.extend(L2)
OR
B) L2.reverse()
(1 mark for correct answer)
25. (A), (C)
(½ x 2 = 1 Mark)
(2)
Minimum and maximum possible values of the variable b: 1,6
(½ x 2 = 1 Mark)
26. def swap_first_last(tup):
if len(tup) < 2:
return tup
new_tup = (tup[-1],) + tup[1:-1] + (tup[0],)
return new_tup
(2)
OR
Page: 3/11
B) SMTP: Simple Mail Transfer Protocol.
def show():
f=open("Email.txt",'r')
data=f.read()
words=data.split()
for word in words:
if '@cmail' in word:
print(word,end=' ')
f.close()
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for splitting the text into words)
(1 mark for correctly displaying the desired words) (3)
OR
(B)
def display_long_words():
with open("Words.txt", 'r') as file:
data=file.read()
words=data.split()
for word in words:
if len(word)>5:
print(word,end=' ')
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
( ½ mark for splitting the text into words)
(1 mark for correctly displaying the desired words)
Page: 4/11
30. (A)
(I)
def push_book(BooksStack, new_book):
BooksStack.append(new_book)
(II)
def pop_book(BooksStack):
if not BooksStack:
print("Underflow")
else:
return(BookStack.pop())
(III)
def peep(BooksStack):
if not BooksStack:
print("None")
else:
print(BookStack[-1])
(3x1 mark for correct function body; No marks for any function header as it
was a part of the question)
OR
(B)
def push_even_numbers(N):
(3)
EvenNumbers = []
for num in N:
if num % 2 == 0:
EvenNumbers.append(num)
return EvenNumbers
VALUES = []
for i in range(5):
VALUES.append(int(input("Enter an integer: ")))
EvenNumbers = push_even_numbers(VALUES)
def pop_even():
if not EvenNumbers:
print("Underflow")
else:
print(EvenNumbers.pop())
pop_even()
Page: 5/11
def Disp_even():
if not EvenNumbers:
print("None")
else:
print(EvenNumbers[-1])
Disp_even()
(1/2 for identifying even numbers)
(1/2 mark for correctly adding data to stack)
(1/2 mark for correctly poping data on the stack and 1/2 mark for checking
condition)
(1/2 mark for correctly displaying the data with none)
(1/2 mark for function call statements)
31. (A) 15@
7@
9
OR
(3)
(B) 1 #2 #3#
1 #2 #3 #
1#
C_Name | Total_Quantity
--------- |---------------
Jitendra |1
Mustafa |2
Dhwani |1
Page: 6/11
(II)
(IV)
MAX(Price)
-----------
12000
(II)
def Count_records():
import csv
f=open("happiness.csv",'r')
records=csv.reader(f)
next(records, None) #To skip the Header row
count=0
for i in records:
count+=1
print(count)
f.close()
Page: 7/11
(½ mark for opening in the file in right mode)
(½ mark for correctly creating the reader object)
(½ mark for correct use of counter)
(½ mark for correctly displaying the counter)
Note (for both parts (I) and (II)):
(i) Ignore import csv as it may be considered the part of the
complete program, and there is no need to import it in individual
functions.
(ii) Ignore next(records, None) as the file may or may not have the
Header Row.
34. (I) Select * from FACULTY natural join COURSES where Salary<12000;
Or
Select * from FACULTY, COURSES where Salary<12000 and
facuty.f_id=courses.f_id;
(II) Select * from courses where fees between 20000 and 50000;
(III) Update courses set fees=fees+500 where CName like
'%Computer%';
(IV)
(A) Select FName, LName from faculty natural join courses where
Came="System Design"; (4)
Or
Select FName, LName from faculty, courses where Came="System
Design" and facuty.f_id=courses.f_id;
OR
Page: 8/11
(½ mark for correctly importing the connector object)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)
(½ mark for correctly displaying the data)
def input_candidates():
candidates = []
n = int(input("Enter the number of candidates you want to add: "))
for i in range(n):
candidate_id = int(input("Enter Candidate ID: "))
candidate_name = input("Enter Candidate Name: ")
designation = input("Enter Designation: ")
experience = float(input("Enter Experience (in years): "))
candidates.append([candidate_id, candidate_name, designation,
experience])
return candidates
candidates_list = input_candidates()
def append_candidate_data(candidates):
with open('candidates.bin', 'ab') as file:
for candidate in candidates:
pickle.dump(candidate, file)
print("Candidate data appended successfully.")
append_candidate_data(candidates_list)
(II)
import pickle
def update_senior_manager():
updated_candidates = []
with open('candidates.bin', 'rb') as file:
while True:
candidate = pickle.load(file)
if candidate[3] > 10:
candidate[2] = 'Senior Manager'
updated_candidates.append(candidate)
Page: 9/11
pickle.dump(candidate, file)
update_senior_manager()
(III)
import pickle
def display_non_senior_managers():
with open('candidates.bin', 'rb') as file:
while True:
candidate = pickle.load(file)
if candidate[2] != 'Senior Manager': # Check if not Senior Manager
print(f"Candidate ID: {candidate[0]}")
print(f"Candidate Name: {candidate[1]}")
print(f"Designation: {candidate[2]}")
print(f"Experience: {candidate[3]}")
print("--------------------")
display_non_senior_managers()
(II) Switch
(1 mark for correct answer)
(III)
Page: 10/11
(IV) There is no requirement of the Repeat as the optical fibre cable used for
the network can carry the data to much longer distances than within the
campus.
(1 mark for correct answer)
Page: 11/11
SAMPLE QUESTION PAPER (THEORY)
CLASS: XII SESSION: 2024-25
COMPUTER SCIENCE (083)
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.
Page: 1/11
5. What will be the output of the following code snippet?
message= "World Peace" (1)
print(message[-2::-2])
9. If a table which has one Primary key and two alternate keys. How many
Candidate keys will this table have?
(A) 1
(1)
(B) 2
(C) 3
(D) 4
Page: 2/11
12. What will be the output of the following code?
c = 10
def add():
global c
c = c + 2
print(c,end='#')
add() (1)
c=15
print(c,end='%')
(A) 12%15#
(B) 15#12%
(C) 12#15%
(D) 12%15#
13. Which SQL command can change the degree of an existing relation? (1)
15. In which datatype the value stored is padded with spaces to fit the specified
length.
(A) DATE
(1)
(B) VARCHAR
(C) FLOAT
(D) CHAR
16. Which aggregate function can be used to find the cardinality of a table?
(A) sum()
(B) count() (1)
(C) avg()
(D) max()
Page: 3/11
18. Which network device is used to connect two networks that use different
protocols?
(A) Modem
(1)
(B) Gateway
(C) Switch
(D) Repeater
19. Which switching technique breaks data into smaller packets for
transmission, allowing multiple packets to share the same network (1)
resources.
Q20 and Q21 are Assertion(A) and Reason(R) 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
21. Assertion (A): A SELECT command in SQL can have both WHERE and
HAVING clauses.
Reasoning (R): WHERE and HAVING clauses are used to check (1)
conditions, therefore, these can be used interchangeably.
Page: 4/11
(II)
A) Write a statement to insert all the elements of L2 at the end of L1.
OR
B) Write a statement to reverse the elements of list L2.
25. Identify the correct output(s) of the following code. Also write the minimum
and the maximum possible values of the variable b.
import random
a="Wisdom"
b=random.randint(1,6)
(2)
for i in range(0,b,2):
print(a[i],end='#')
26. The code provided below is intended to swap the first and last elements of
a given tuple. However, there are syntax and logical errors in the code.
Rewrite it after removing all errors. Underline all the corrections made.
def swap_first_last(tup)
if len(tup) < 2:
return tup (2)
new_tup = (tup[-1],) + tup[1:-1] + (tup[0])
return new_tup
27. (I)
A) What constraint should be applied on a table column so that
duplicate values are not allowed in that column, but NULL is
allowed.
OR
B) What constraint should be applied on a table column so that (2)
NULL is not allowed in that column, but duplicate values are
allowed.
Page: 5/11
(II)
A) Write an SQL command to remove the Primary Key constraint
from a table, named MOBILE. M_ID is the primary key of the
table.
OR
B) Write an SQL command to make the column M_ID the Primary
Key of an already existing table, named MOBILE.
29. A) Write a Python function that displays all the words containing @cmail
from a text file "Emails.txt".
OR (3)
B) Write a Python function that finds and displays all the words longer than
5 characters from a text file "Words.txt".
30. A) You have a stack named BooksStack that contains records of books.
Each book record is represented as a list containing book_title,
author_name, and publication_year.
Write the following user-defined functions in Python to perform the
specified operations on the stack BooksStack:
(I) push_book(BooksStack, new_book): This function takes the stack
BooksStack and a new book record new_book as arguments and
pushes the new book record onto the stack.
(II) pop_book(BooksStack): This function pops the topmost book record
from the stack and returns it. If the stack is already empty, the
function should display "Underflow".
(III) peep(BookStack): This function displays the topmost element of (3)
the stack without deleting it. If the stack is empty, the function
should display 'None'.
OR
(B) Write the definition of a user-defined function `push_even(N)` which
accepts a list of integers in a parameter `N` and pushes all those integers
which are even from the list `N` into a Stack named `EvenNumbers`.
Write function pop_even() to pop the topmost number from the stack and
returns it. If the stack is already empty, the function should display "Empty".
Write function Disp_even() to display all element of the stack without
deleting them. If the stack is empty, the function should display 'None'.
Page: 6/11
For example:
If the integers input into the list `VALUES` are:
[10, 5, 8, 3, 12]
Page: 7/11
(IV) Display the sum of Price of all the orders for which the quantity
is null.
OR
B) Write the output
(I) Select c_name, sum(quantity) as total_quantity
from orders group by c_name;
(II) Select * from orders where product like
'%phone%';
(III) Select o_id, c_name, product, quantity, price
from orders where price between 1500 and 12000;
(IV) Select max(price) from orders;
33. A csv file "Happiness.csv" contains the data of a survey. Each record of the
file contains the following data:
● Name of a country
● Population of the country
● Sample Size (Number of persons who participated in the survey in
that country)
● Happy (Number of persons who accepted that they were Happy)
(4)
For example, a sample record of the file may be:
[‘Signiland’, 5673000, 5000, 3426]
Write the following Python functions to perform the specified operations on
this file:
(I) Read all the data from the file in the form of a list and display all
those records for which the population is more than 5000000.
(II) Count the number of records in the file.
34. Saman has been entrusted with the management of Law University
Database. He needs to access some information from FACULTY and
COURSES tables for a survey analysis. Help him extract the following
information by writing the desired SQL queries as mentioned below.
Table: FACULTY
F_ID FName LName Hire_Date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000 (4)
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra 11-9-2004 11000
106 Sulekha Srivastava 5-6-2006 10000
Table: COURSES
C_ID F_ID CName Fees
C21 102 Grid Computing 40000
C22 106 System Design 16000
Page: 8/11
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
(I) To display complete details (from both the tables) of those Faculties
whose salary is less than 12000.
(II) To display the details of courses whose fees is in the range of 20000
to 50000 (both values included).
(III) To increase the fees of all courses by 500 which have "Computer"
in their Course names.
(IV) (A) To display names (FName and LName) of faculty taking System
Design.
OR
(B) To display the Cartesian Product of these two tables.
Field Type
itemNo int(11)
itemName varchar(15)
price float
qty int(11)
(4)
Write the following Python function to perform the specified operation:
AddAndDisplay(): To input details of an item and store it in the table
STATIONERY. The function should then retrieve and display all records
from the STATIONERY table where the Price is greater than 120.
Page: 9/11
(II) Write a function to update the data of candidates whose experience
is more than 10 years and change their designation to "Senior
Manager".
(III) Write a function to read the data from the binary file and display the
data of all those candidates who are not "Senior Manager".
ADMIN 30
FOOD 18
MEDIA 25
DECORATORS 20
DELHI HEAD
OFFICE 18
Page: 10/11
(I) Suggest the most appropriate location of the server inside the
MUMBAI campus. Justify your choice.
(II) Which hardware device will you suggest to connect all the
computers within each building?
(III) Draw the cable layout to efficiently connect various buildings
within the MUMBAI campus. Which cable would you suggest for
the most efficient data transfer over the network?
(IV) Is there a requirement of a repeater in the given cable layout?
Why/ Why not?
(V) A) What would be your recommendation for enabling live visual
communication between the Admin Office at the Mumbai campus
and the DELHI Head Office from the following options:
a) Video Conferencing
b) Email
c) Telephony
d) Instant Messaging
OR
B) What type of network (PAN, LAN, MAN, or WAN) will be set up
among the computers connected in the MUMBAI campus?
Page: 11/11