Computer Science Class 12
Computer Science Class 12
3. What error occurs when you execute the following Python code snippet?
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
a) 30.0
b) 30.8
c) 28.4
d) 27.2
11. Which of the following statement is true for extend () list method?
a) adds element at last c) adds multiple elements at last
b) adds element at specified index d) adds elements at random index
14. Which of the following method is used to delete element from the list?
a)del()
b) delete()
c)pop()
d)All of these
15. The step argument in range() function .
a. indicates the beginning of the sequence
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 32
b. indicates the end of the sequence
c. indicates the difference between every two consecutive numbers in the sequence
d. generates numbers up to a specified value
Answers of MCQ:
1) A 2)A 3)B 4)A 5)D 6)C 7)A 8)B 9) D 10)B 11)B 12)B 13)A 14)C
15)C
Sum = 0
for k in range(5):
Sum = Sum+k
print(Sum)
Sum = 0
for k in range(10 , 1, -2):
Sum = Sum+k
print(Sum)
for k in range(4):
for j in range(k):
print(‘*’, end = ‘ ‘)
print()
5. How many times the following loop will execute? Justify your answer
A=0
while True:
print(A)
A =A+1
6. Give the output of the following. Also find how many times the loop will execute.
A=0
while A<10:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 33
print(A, ‘ , ‘)
A =A+1
7. Give the output of the following. Also find how many times the loop will execute.
A=0
while A<10:
print(A, ‘ , ‘)
A =A+1
print(‘\n’, A)
T = (5)
T = T*2
print(T)
10. What kind of error message will be generated if the following code is executed
A=5
B = ‘hi’
d = A+B
print(D)
S = ‘abcdefgh’
L = list(S)
print(L[1:4])
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 34
print( y)
1)10
2)30
3)
*
* *
* * *
4) * * * * *
****
** *
**
*
5) infinite loop. Condition / test expression is always Ture.
6) 0,1,2,3,4,5,6,7,8,9
7) 0,1,2,3,4,5,6,7,8,9
10
10)TypeError
11) [1,2,3,4,5,6,7,8,9]
12) [1,2,3,4,5,6,7,8]
14) 1
1
2. Write Python code to remove an element as entered by the user form the list, L
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 35
3. Create a list k, by selecting all the od numbers within the given range, m and n. User
will input the values of m , n at run time
4. Write Python code to create and add items to a dictionary. Ask the user to input key
value pairs. Continue as long as the user wishes.
5. Write Python code to find whether the given item is present in the given list using for
loop.
6. Create a list, L, with the squares of numbers from 0 to 10
7. Mr. Rahul wants created a dictionary to store the details of his students and to
manipulate thedata.
He wrote a code in Python, help him to complete the code:
3) m = int(input(‘lower limit’))
n = int(input(‘upper limit’))
n = n+1
L = [x for x in range(m, n) if x%2!=0]
4)
D={}
while Ture:
K = input(‘type a key’)
V = int(input(‘type the value’)
D[K] = V
C = input(‘type ‘y’ to add more’)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 36
if C!=’y’:
break
5) flag = 0
L = eval(input(‘input a list on numbers’))
E = int(input(‘item to be searched’)
K =len(L)
for p in range(K):
if E ==L(p):
flag = 1
print(‘found and index is ‘,p)
if flag==0:
print(‘not found’)
6)
list1=[]
for x in range(10):
list1.append(x**2)
list1
Output:
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
OR
list1=list(map(lambda x:x**2, range(10)))
7)
Statement 1 : StudentDict = dict( )
Statement 2 = for i in range( n ):
Statement 3: studentDict[rollno]=[name, physicsMarks, chemistryMarks, mathMarks]
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 37
FUNCTIONS
Practice Questions
1 Which of the following is a valid function name?
a) Start_game() b) start game() c) start-game() d) All of the above
2 If the return statement is not used in the function then which type of value will be
returned by the function?
a)int b) str c) float d) None
3 Richa is working with a program where she gave some values to the function. She
doesn’t know the term to relate these values. Help her by selecting the correct option.
a) function value b) arguments or parameters
c) return values d) function call
4 What is the minimum and maximum value of c in the following code snippet?
import random
a=random.randint(3,5)
b = random.randint(2,3)
c=a+b
print(c)
a) 3 , 5 b) 5, 8 c) 2, 3 d) 3, 3
5 In python function, the function calling another function is known as
and the function being called is
known _ _
print(“100+200”)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 38
a) int() b) str() c) input() d) float()
print(float())
12 Identify the module to which the following function load () belong to?
def fun():
global a
a=10
print(a)
a=5
fun()
print(a)
a) 10 b) 5 c) 5 d) 10
10 10 5 5
15 Value returning functions should be generally called from inside of an expression
a) True b) False
17 These are predefined functions that are always available for use. For using them we
don’t need to import any module
19 If you want to communicate between functions i.e. calling and called statement,
then you should use
a) values b) return c) arguments d) none of the above
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 50
20 Which of the following function header is correct?
a) def mul(a=2, b=5,c) b) def mul(a=2, b, c=5)
c) def mul(a, b=2, c=5) d) def mul(a=2, b, c=5)
21 Find the flow of execution of the following code:
1. def calculate (a, b):
2. res=a**b
3. return res
4.
5. def study(a):
6. ans=calculate(a,b)
7. return ans
8.
9. n=2
10. a=study(n)
11. print(a)
a) 1 > 5 > 9 > 10 >6 > 2 > 3 > 7 > 11 b) 5 > 9 > 10 > 6 > 2 > 3 > 7 > 11
c) 9 > 10 > 5 > 1 > 6 > 2 > 3 > 7 > 11 d) None of the above
22. Python resolves the scope of a name using the LEGB rule
a) True b) False
24 When you use multiple type argument in function, then default argument take place
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 51
ANSWERS
1 a)Start_game()
2 d) None
3 b) arguments or parameters
4 b) 5, 8
5 b) caller, called
6 c) 100+200
7 a) math
8 d) tuple
9 b) 9
10 c) input()
11 b) 0.0
12 c)pickle
13 b) 0 or many
a) 10
14
10
15 a) True
16 b) local
17 a) built in function
18 c) scope
19 c) arguments
22 a) True
23 a) None
24 b) at end
25 b) default parameter
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 52
QUESTIONS
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 53
6 Which of the following function header is Correct:
A. def fun(x=1,y)
B. def fun(x=1,y,z=2)
C. def fun(x=1,y=1,z=2)
D. def fun(x=1,y=1,z=2,w)
Ans.c) def fun(x=1,y=1,z=2)
7 What is the output of the program given below?
x = 50
def func (x) :
x=2
func (x)
print ('x is now', x)
A) x is now 50 B) x is now 2 C) x is now 100 D) Error
Ans. A)
A) x is now 50
8 Choose the correct output from the options given below.
print(‘Welcome!’)
print(‘Iam’, name ) # is double underscore
a) Welcome! b) Error
Iam main
c) Welcome! d)None of these
Iam name
Ans. a)Welcome!
Iam main
9 Predict the output of the following code fragment
def update(x=10):
x+=15
print("x=",x)
x=20
update()
print("x=",x)
a) x=20 b) x=25
x=25 x=25
c) x=20 d) x=25
x=25 x=20
Ans. d)
x=25
x=20
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 54
10 Predict the output of the following code fragment
def display(x=2,y=3):
x=x+y
y+=2
print(x,y)
display( )
display(5,1)
display(9)
a) 5 5 b)12 5
63 63
12 5 55
c) 5 6 d) 5 5
12 5 7 7
63 6 6
Ans. a)
55
63
12 5
11 Find the output print(pow(5,4,9))
a) 7 b)0 c)4 d) error
Ans. C) 4
Hint: pow(x, y, z) is equal to xy % z
Give the output of the following program
12 def check(a):
for i in range(len(a)):
a[i]=a[i]+5
return a
b=[1,2,3,4]
c=check(b)
print(c)
a) [6, 8, 8, 9] b) [6,7,8,9]
c) [7, 7, 8, 9] d) [6,7,9,9]
Ans. b) [6, 7, 8, 9]
13 Give the output
def abc(x,y=60):
return x+y
a=20
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 55
b=30
a=abc(a,b)
print(a,b)
b=abc(a)
print(a,b)
a=abc(b)
print(a,b)
Ans.
0 *11 *12 *9 *
0 *11 *
0 *11 *12 *
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 56
15. Find the output of the following program:
def ChangeIt(Text,C):
T=""
for K in range(len(Text)):
T=T+Text[K].lower();
elif K%2==0:
T=T+Text[K].upper()
else:
T=T+T[K-1]
print(T)
OldText="pOwERALone"
ChangeIt(OldText,"%")
Ans: c)
PPW%RRllN%
16 What possible outputs are expected to be displayed on screen at the time of execution
of the program from the following code? Also specify the maximum value that can be
assigned to each of the variables L and U.
import random
Arr=[10,30,40,50,70,90,100]
L=random.randrange(1,3)
U=random.randrange(3,6)
for i in range(L,U+1):
print(Arr[i],"@",end="")
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 57
i) 40 @50 @ ii) 10 @50 @70 @90 @
iii) 40 @50 @70 @90 @ iv) 40 @100 @
Ans. Options i and iii
i)40 @50 @
def disp(str):
m=' '
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"@"
print(m.swapcase())
disp('StudyBag$2021')
a) StudyBagG@2@2 b) sTUDYbAGg@2@2 c) StudyBagG$2$2 d) None
Ans : a)
StudyBagG@2@2
Note: The swapcase() method returns a string where all the upper case letters are
lower case and vice versa. Syntax. string.swapcase().
18 What will be the output of the following code
total=0
def add(a,b):
global total
total=a+b
print(total)
add(6,6)
print(total)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 58
a) 12 b) 12 c) 0 d) None of these
12 0 12
Ans : a)
12
12
19 Find and write the output of the following Python code:
def makenew(mystr):
newstr = " "
count = 0
for i in mystr:
if count%2 ==0:
newstr = newstr+i.lower()
else:
if i.islower():
newstr = newstr+i.upper()
else:
newstr = newstr+i
count +=1
newstr = newstr+mystr[:3]
print ("The new string is :", newstr)
makenew("cbseEXAMs@2022")
import random
L=[10,7,21]
X=random.randint(1,2)
for i in range(X):
Y=random.randint(1,X)
print(L[Y],"$",end=" ")
Minimum value of x is 1
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 59
21 Choose the correct option:
Statement1: Local Variables are accessible only within a function or block in which it
is declared.
24 Consider the code given below and Identify how many times the message “Hello
All” will be printed.
def prog(name):
for x in name:
if x.isalpha():
print('Alphabet')
elif x.isdigit():
print('Digit')
elif x.isupper():
print('Capital Letter')
else:
print('Hello All')
prog('[email protected]')
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 60
a) 0 b) 2 c) 1 d) 3
Ans: b) 2
def changer(p,q=10):
p=p/q
q=p%q
print(p,"#",q)
return p
a=200
b=20
a=changer(a,b)
print(a,"$",b)
a=changer(a)
print(a,"$",b)
Ans.
10.0 # 10.0
10.0 $ 20
1.0 # 1.0
1.0 $ 20
26 What will be the output for the below code snippet?
def div(lst,n):
for i in range(0,n):
if lst[i]%5==0:
lst[i]+=5
else:
lst[i]=lst[i]//2
lt=[45,20,23,54,5]
div(lt, len(lt))
for i in lt:
print(i,end='#')
a) 50#25#11.5#27.0#10# b) 50#25#11#27#10#
c) 50#25#1#0#10# d) 225#100#1#0#25#
Ans: b) 50#25#11#27#10#
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 61
DATA FILE HANDLING
SAMPLE PROGRAMS
1. Write a program to write roll no and name to xiib.txt
2. Write read contents from story.txt and count no: of independent words
“to” in the file
Ans: string
PRACTICE QUESTIONS
1. Write a program to read contents from the text file story.txt and count no:of
vowels in it
2. Write a program to read contents from the text file myfile.txt and find average
word count
3. Write a program to read contents from the text file library.txt and count “is” as
independent word
4. Write a program to read contents from the text file diary.txt and count number of
lines with Starting letter “T” or “M”
5. Write a program to read contents from the text file mydiary.txt and count number
of lines with ending letter “r”
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 62
8
MULTIPLE CHOICE QUESTIONS
1. If a text file is opened in w+ mode, then what is the initial position of file
pointer/cursor?
a. Beginning of file
b. End of the file
c. Beginning of the last line of text file
d. Undetermined
3. To read the entire remaining contents of the file as a string from a file object
myfile, we use
a. myfile.read(2)
b. myfile.read()
c. myfile.readline()
d. myfile.readlines()
4. A text file is opened using the statement f = open(‘story.txt’). The file has a total
of 10 lines. Which of the following options will be true if statement 1 and statement 2
are executed in order.
Statement 1: L1 = f.readline( )
Statement 2: L2 = f.readlines( )
a. L1 will be a list with one element and L2 will be list with 9 elements.
b. L1 will be a string and L2 will be a list with 10 elements.
c. L1 will be a string and L2 will be a list with 9 elements.
d. L1 will be a list with 10 elements and L2 will be an empty list.
5. Which function of a file object can be used to fetch the current cursor position in
terms of number of bytes from beginning of file?
a. seek( )
b. bytes( )
c. tell( )
d. fetch( )
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 69
6. What will be the output of the following code?
f = open(‘test.txt’, ‘w+’)
L = *‘First Line\n’, ‘Second Line\n’, ‘Third Line’+
f.writelines(L)
f.flush()
f.seek(0)
O = f.readlines()
print(len(O))
a. 33
b. 31
c. 28
a.3
a. AllngsAll
b. AllcanAll
c. Allcancan
d. Allngscan
8. What will be the most correct option for possible output of the following code,
given that the code executes without any error.
f = open(‘cricket.txt’)
data = f.read(150)
print(len(data))
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 70
b. 151
c. More than or equal to 150
d. Less than or equal to 150
9. For the following python code, what will be the datatype of variables x, y, z given
that the code runs without any error?
f = open(‘story.txt’)
x = f.read(1)
y = f.readline()
z = f.readlines()
a. string, list, list
b. None, list, list
c. string, string, list
d. string, string, string
a. 12
b. 11
c. 13
d. 10
Answers:
1. a. Beginning of file
2. d. All of the mentioned
3. b. myfile.read()
4. c. L1 will be a string and L2 will be a list with 9 elements.
5. c. tell( )
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 71
6. d. 3
7. a. AllngsAll
8. d. Less than or equal to 150
9. c. string, string, list
10. a. 12
b) File.write(“ABC”)
Ans: A named entity, usually stored on a hard drive that contains a stream of
characters are called files.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 72
Offset: This is used for defining the number of positions to move forward.
from_where: This is used for defining the point of reference. It can take
0: beginning of the file. 1: current position of the file. 2: end of the file.
2. Write a function in Python that counts the number of “the” or “this” words
present in a text file “myfile.txt”.
Example: If the “myfile.txt” contents are as follows:
This is my first class on Computer Science. File handling is the easiest topic for me
and Computer Networking is the most interesting one.
The output of the function should be: Count of the/this in file: 3
Answer:
def displayTheThis():
num=0
f=open("myfile.txt","r")
N=f.read()
M=N.split()
for x in M:
if x=="the" or x== "this":
print(x)
num=num+1
f.close()
print("Count of the/this in file:",num)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 73
4. Write a Python program to count all the line having 'a' as last character.
Answer:
count =0
f=open('fracture.txt',"r")
data=f.readlines()
for line in data:
if line[-2] == 'a':
count=count+1
print("Number of lines having 'a' as last character is/are : " ,count)
f.close()
5. Assume that a text file named TEXT1.TXT already contains some text written into
it, write a program with a function named vowelwords(),that reads the file TEXT1.TXT
and create a new file named TEXT2.TXT ,which shall contain only those words from the
file TEXT1.TXT which don’t start with an uppercase vowel(i.e. with ‘A’,’E’,’I’,’O’,’U’) ,
for example if the file TEXT1.TXT contains
Carry Umbrella and Overcoat When it Rains
then the file TEXT2.TXT shall contain
Carry and when it Rains.
Answer:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 74
BINARY FILES
Operations on binary file
Writing data into binary file
Searching of data
Modifying data
Deleting data
Appending data
pickle.load() can generate runtime exceptions like EOFError. try and except
block will handle runtime errors raised due to EOF (end of file) .In try block write all the
statements that can generate an exception and in except block write code to handle the
exception.
Write a program to write contents to a binary file stud.dat with record format
[rollno,name,marks]
Write a program to read contents from the file stud.dat and display those
records whose marks >90. Assume stud.dat existing in the system with the record
format [rollno,name,marks]
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 75
6
Deleting data from a binary file
Write a program to read contents from the file stud.dat and delete those records whose
marks <90. Assume stud.dat existing in the system with the record format
[rollno,name,marks]
Below program is implemented using function and module os is used to use functions
like rename() and remove()
Write a program to update records in the file stud.dat with records in the format
[rollno,name,marks].Increase 10 marks to the student whose rollnumber entered by
the user
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 77
Appending data in to a binary file
Write a program to append records into the file stud.dat with records in the format
[rollno,name,marks]
The with statement is a compact statement which combines the opening of file ,
processing of file along with inbuilt exception handling.The with statement will also close
the file automatically after with block is over.
content = myObject.read()
Here, we don’t have to close the file explicitly using close() statement. Python
will automatically close the file.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 78
SAMPLE QUESTIONS
PRACTICE QUESTIONS
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 79
2. A binary file “students.dat” has structure (admission_number, Name, Percentage,
subject). Write a function countrec() in Python that would read contents of the file and
display the details of those students whose subject is “Biology” and percentage is below
45%. Also display the number of such students
i) Write a user defined function CreatePC() to input data for a record and append in
Computers.dat .
ii. Write a function FindPCs(Price) in Python which accepts the Price as parameter and
display only those computer records from Computers.dat which are having less than or
equal to given price.
2. Shylesh is writing python code to append a new record to a binary file ‘salary.dat’
that is storing list objects containing [empid, empname, salary]. Consider the
following code written by him.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 80
import pickle
f = open(‘salary.dat’, ‘ab’)
id = input(“Enter employee id : ”)
name = input(“Enter name of employee: ”)
sal = float(input(“Enter salary :”))
record = _ #Blank 1
pickle.dump(record,f)
f.close()
3. Which is the valid syntax to write an object onto a binary file opened in the write
mode?
a. pickle.dump(<object to be written>, <file handle of open file>)
b. pickle.dump(<file handle of open file>, <object to be written>)
c. dump.pickle(<object>, <file handle>)
d. None of the above
4. What is the binary file mode associated with “ file must exist, otherwise error will
be raised and reading and writing can take place”.
a. wb+
b. w+
c. rb
d. rb+
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 81
myfile.close()
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
6. A binary file “salary.dat” has structure [employee id, employee name, salary].
What the following code will display:
def records():
num=0
fobj=open("data.dat","rb")
try:
print("Emp id\tEmp Name\tEmp Sal")
while True:
rec=pickle.load(fobj)
if rec[2]< 20000:
print(rec[0],"\t\t",rec[1],"\t\t",rec[2])
except:
fobj.close()
records()
7. In which file, no delimiters are used for line and no translations occur?
(a) Text file
(b) Binary file
(c) csv file
(d) None of the above
8. Choose the file mode used to write data into binary file.
(a) rb
(b) wb
(c) r+
(d) w+
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 82
9. Which of the following function is used to read data from a binary file?
(a) write
(b) load
(c) dump
(d) scan
10. Dima is trying to read a list l1 from a binary file ‘num’. Consider the following
code written by her.
import pickle
f1 = open("num",'rb')
print(l1)
f1.close()
(a) pickle.load(f1)
(b) pickle.load(l1,f1)
(c) pickle.read(f1)
(d) pickle.dump(l1,f1)
Answers:
a.[id,name,sal]
d. rb+
c. Statement 3
d.Display the details of those employees whose salary is less than 20000.
(b) wb
(b) load
(a) pickle.load(f1)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 83
CASE STUDY QUESTIONS
Amit Kumar of class 12 is writing a program to store roman numbers and find their
equivalents using a dictionary. He has written the following code. As a programmer,
help him to successfully execute the given task.
Answers:
(a) pickle
(b) wb
(c) rb
(d) file2.close()
(e) C
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 84
LONG ANSWER QUESTIONS
I. Write a user defined function CreateEmp() to input data for a record and add to emp.dat.
II. Write a function display() in Python to display the detail of all employees.
Answer:
I.
import pickle
def CreateEmp():
f1=open("emp.dat",'wb')
eid=input("Enter E. Id")
ename=input("Enter Name")
designation=input("Enter Designation")
salary=int(input("Enter Salary"))
l=[eid,ename,designation,salary]
pickle.dump(l,f1)
f1.close()
II.
import pickle
def display():
f2=open("emp.dat","rb")
while True:
try:
rec=pickle.load(f2)
print(rec['eid'],rec['ename'],rec['designation'],rec['salary'])
except EOFError:
break
f2.close()
2. A binary file “emp.DAT” has structure [EID, Ename, designation,salary].
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 85
display the details of those employee whose designation is “Manager”.
I)
import pickle
def createemp():
f1=open("emp.dat",'ab')
eid=input("Enter E. Id")
ename=input("Enter Name")
designation=input("Enter Designation")
salary=int(input("Enter Salary"))
l=[eid,ename,designation,salary]
pickle.dump(l,f1)
f1.close()
II) def Show():
f2=open("emp.dat","rb")
while True:
try:
rec=pickle.load(f2)
if (rec['designation']=='Manager'):
print(rec['eid'],rec['ename'],
rec['designation'],rec['salary'])
except EOFError:
break
f2.close()
3. A binary file “employee.dat” has structure [ empId, empName , Dept, Salary].
(i) Write a user defined function addData() to input data for a record and add tp
employee.dat
(ii) Write a function checkSalary(empName) in Python which accepts the empName as
parameter and return the salary of particular employee by the given employee name stored
in the file employee.dat
(i)
import pickle
def addData():
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 86
fobj=open("employee.dat","ab")
empID=int(input("Enter Emp ID : "))
empName=input("Employee Name :")
Dept = input(“Department: “)
Salary = int(input("Monthly Salary : "))
rec=[ empId, empName , Dept, Salary]
pickle.dump(rec,fobj)
fobj.close()
(ii)
import pickle
def checkSalary(empName):
fobj=open("employee.dat","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if Author==rec[3]:
num = num + 1
except:
fobj.close()
return num
import pickle
def display(scien_name):
fobj=open("Discovery.DAT","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if rec[1] == scien_name:
print(rec[0],rec[1],rec[2],sep="\t")
num = num + 1
except:
fobj.close()
return num
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 87
CSV FILE
• A Comma Separated Values (CSV) file is a plain text file that contains the comma-
separated data.
• These files are often used for exchanging data between different applications.
• CSV files are usually created by programs that handle huge amounts of data. They
are used to export data from spreadsheets (ex:- excel file) and databases (Ex:- Oracle,
MySQL). It can be used to import data into a spreadsheet or a database.
writer( )
reader( )
Both the methods return an Object of writer or reader class. Writer Object again have two
methods – writerow( ) , writerows( ).
writer( ) Methods
This function returns a writer object which is used for converting the data given by the
user into delimited strings on the file object.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 88
Example:-
## writerow()
import csv
row=['Nikhil', 'CEO', '2', '9.0']
f=open("myfile.csv", 'w')
w_obj = csv.writer(f)
w_obj.writerow(row)
f.close()
## writerows()
import csv
rows = [['Nikhil','CEO','2','9.0'],
['Sanchit','CEO','2','9.1']]
f=open("myfile.csv",'w')
w_obj = csv.writer(f)
w_obj.writerows(rows)
f.close()
reader( ) Methods
This function returns a reader object which will be used to iterate over lines of a given
CSV file.
r_obj = csv.reader(csvfile_obj)
for i in r_obj:
print(i)
import csv
f=open("myfile.csv",'r')
r_obj = csv.reader(f)
for data in r_obj:
print(data)
f.close()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 89
SAMPLE QUESTIONS:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 90
3. The default delimiter for a CSV file is :
a. Semi colon
b. Colon
c. Comma
d. Hyphen
4. _ module of Python provides the functionality to read and write tabular data
in CSV file.
a. pickle
b. csv
c. file
d. ccv
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 91
b. writerow( )
c. writer( )
d. None of the above
10. The opening function of a csv file is similar to the opening of:
a. Binary file
b. Text File
c. Both of them
d. None of them
11. The argument of open function is to specify how Python handle the
newline characters in csv file
a. newline
b. line
c. mode
d. char
13. To specify a different delimiter while writing into a csv file, argument is used
with writer object :
a. newline
b. separator
c. character
d. delimiter
14. Which mode opens the file for exclusive creation, which fails in the case where file
already exists
a. a
b. w
c.x
d. r
15. The file mode to open a CSV file for reading as well as writing is .
a. a+
b. w+
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 92
c. r+
d. All the above.
16. Identify the line number which may cause an error:
import csv #Line1
line=[[1,2,3],[4,5,6]]#Line 2
with open("sample.csv","w",newline="") as csvfile: #Line3
writer=csv.writer(csvfile,delimiter="|") #Line4
for line in writer: #Line5
writer.writerow(line)
a. Line1
b. Line2
c. Line 4
d. Line
19. Which of the following parameter needs to be added with open function to avoid
blank row followed by each record in the CSV file?
a. quotechar
b. quoting
c. newline
d. skiprow
20. Ajaikrishna wants to separate the values by a $ sign. Suggests him a pair of function
and parameter to use it.
a. open, quotechar
b. writer, quotechar
c. open, delimiter
d. writer, delimiter
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 93
21. Tejalakshmi of Class 12 have written the below code . Observe and fill in the given
blanks so that it opens the file “data.csv” and read and print all the records.
V. What is the default data type of data read from this file?
a. List
b. String
c. Tuple
d. Integer
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 94
22. Sudev, a student of class 12th, is learning CSV File Module in Python. During
examination, he has been assigned an incomplete python code to create a CSV file
‘customer.csv’ .Help him in completing the code which creates the desired CSV file.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 95
I. Identify suitable code for the blank space in line marked as Statement-1.
a) include
b) add
c) Import
d) import
II. Identify the missing code for the blank space in line marked as Statement-2.
a) Customer
b) reader
c) csvwriter
d) writer
III. Identify the argument name for the blank space in line marked as Statement-3?
a) Row
b) Rec
c) row
d) rec
IV. Identify the missing file name for the blank space in line marked as Statement-4?
a) customer
b) customer.csv
c) customer.txt
d) customer.dat
V .Identify the object name for the blank space in line marked as Statement-5?
a) i
b) Rec
c) row
d) rec
23. Daya of class 12 is writing a program to create a CSV file “empdata.csv” with empid,
name & mobile number. Also to search a particular empid and display its record details.
He has written the following code. As a programmer, help him to successfully execute the
given task.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 96
Choose the module he should import in Line 1.
a) math
b) pickle
c) csv
d) random
II. Choose a code to write the column heading from fields list in Line2.
a) writerows(fields)
b) writerow(field)
c) writerow(fields)
d) writerows(fields)
III. Choose a code to write the row from rows list in Line3.
a) writerows(row)
b) writerow(row)
c) writerow(rows)
d) write_row(row)
IV. Choose a code for line 4 to read the data from a csv file.
a) csv.reader(f)
b) csv.read(f) d) pickle.load(f) e) f.read()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 97
V. Choose the correct variable (list value) to check “emplid” in Line5
a) Row[0]
b) Rec[0]
c) row[0]
d) rec[0]
24. Viraj is making a software on “Countries and their Capitals” in which various records
are to be stored/retrieved in “CAPITAL.CSV” data file. It consists of few records of
Countries and their Capitals. He has written the following code in python. As a
programmer, you have to help him to successfully execute the program.
II. Choose the file mode to be passed to add new records in Statement-2.
a) w
b) r
c) w+
d) a
III. Identify the correct variables in Statement-3 to store data to the file.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 98
a) country,capital
b) Country,Capital
c) Coun,Cap
d) [Country,Capital]
IV. Choose the correct option for Statement-4 to read the data from a csv file.
a) Reader()
b) reader()
c) read
d) reader
25. Rinsha of class 12 is writing a program to create a CSV file “user.csv” which will
contain user name and password for some entries. She has written the following code.
As a programmer, help her to successfully execute the given task.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 99
I. Name the module she should import in Line 1.
a. CSV
b. csv
c. math
d. File
II. In which mode, Rinsha should open the file to add data into the file.
a. r
b. a
c. w
d. w+
III. Fill in the blank in Line 3 to read the data from a csv file.
a. writer()
b. reader()
c. write()
d. read()
26. Consider the following csv file and the code fragment associated with the following
csv file :
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 100
a. SLNO12345
b. SLNO
c. The entire content
d. Error
II. What will be the output printed by the above code if the break is replaced with
continue?
a. SLNO12345
b. SLNO
c. The entire content
d. Error
III. What will occur if the file stud.csv is not existing in the mentioned path?
a. It will create a new one
b. It will create an error
c. None of the above
d. It will cause a system reboot
IV. Which statement in the above code will help to move to the next record?
a. fobj.next()
b. next(fobj)
c. fobj.move()
d. fobj.forward()
27. Sai Krishna has created the following csv file named item.csv:
He has written the following program for managing the file. Help him to find the
answers for the following questions.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 101
I. What will be printed by Line1?
a. All the records
b. ITEMNO, NAME, PRICE c.item.csv
d. None of the above
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 102
ANSWERS
QNO OPT
I b
II a
27 III b
IV c
V b
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 103
DATA STRUCTURE
Implementation of stack – menu oriented program
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 104
7
SAMPLE QUESTIONS:
1. Choose the correct output for the following stack operation(* top position)
(a) 8 5 2 5 1*
(b) 8 5 5 2 1*
(c) 2 5 5 1*
(d) 5 2 1*
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 108
(e) Which list method can be used to perform Push operation in a stack implemented
by list?
(f) append()
(g) extend()
(h) push()
(i) insert()
2. Which list method can be used to perform Pop operation in a stack implemented
by list?
(a) pop()
(b) pop(1)
(c) remove()
(d) pop(0)
4. Consider the following operation performed on a stack of size 3, What will be the
output? (* top position)
(a) overflow
(b) underflow
(c) 10 20 30 40 50*
(d) 10 20 40 50*
5. Based on the below given code, Write answer to the following questions i to v
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 109
(i) Identify the suitable code for statement 1?
a) colour.insert(len(colour),n)
b) colour.append(len(colour),n)
c) colour.append()
d) colour.extend()
a) push(colour,c[i])
b) push(colour)
c) push(c[i])
d) push(colour,i)
a) colour==[]:
b) colour.isEmpty():
c) len(colour)=0:
d) None of the above
a) colour.pop(1)
b) colour.pop()
c) del colour[1]
d) colour.delete(1)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 110
b) pop(colour)
c) call pop(colour)
d) def pop(colour)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 111
(e) L[3][2][0]
(f) L[3][2]
(g) L[3][2][1]
(h) L[3][3]
(b)
b=[[9,6],[4,5],[7,7]] X=b[:2]
X[1].append(10)
print(X)
11. Consider STACK=*‘a’,’b’,’c’,’d’+. Write the STACK content after each operations:
a) STACK.pop( )
b) STACK.append(‘e’)
c) STACK.append(‘f’)
d) STACK.pop( )
12. Write a program to implement a stack for the students(studentno, name). Just
implement Push.
13. Write a program to implement a stack for the students(studentno, name). Just
implement Pop and display.
14. If
L=["Python", "is", "a", ["modern", "programming"], "language", "that", "we", "use"] ,
then find the output:
a) L[0][0]
b) L[3][0][2]
c) L[3:4][0]
d) L[3:4][0][1]
e) L[3:4][0][1][3]
f) L[0:9][0]
g) L[0:9][0][3]
h) L[3:4][1]
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 112
Long Answer Type Questions (3-marks)
1. Write a program for linear search in a list.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 113
8. Write a function in Python PUSH(Arr),where Arr is a list of numbers, from this list
push all even numbers into a stack implemented by using a list. Display the stack if it has
at least one element, otherwise display “stack empty” message.
>>> li=[1,6,89,100,25,29]
>>> push(li)
The item 1 can't be inserted because it is not an even number The item 89 can't be inserted
because it is not an even number The item 25 can't be inserted because it is not an even
number The item 29 can't be inserted because it is not an even number
Stack elements after push operation : [100, 6]
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 114
12. Write a function in Python PUSH(Arr),where Arr is a list of numbers, From this list
push all numbers divisible by 5 in to a stack implemented by using a list. Display the stack
if it has at least one element, otherwise display appropriate error message.
>>> li=[10,2,5,6,15,30]
>>> push(li)
The item 2 can't be inserted because it is not divisible by 5 The item 6 can't be inserted
because it is not divisible by 5 Stack elements: [30, 15, 5, 10]
ANSWER KEY
I. MCQ/ Very Short Answer Type Questions(1-mark)
1. (d) 5 2 1*
2. (a) append()
3. (a) pop()
4. (a) overflow
5.
(i). a colour.insert(len(colour),n)
(ii). a push(colour,c[i]) (iii).a colour==[]
(iv). b colour.pop()
(v). b pop(colour)
6. Data Structure means organization of data. A data structure has well defined
operations or behaviour.
7. STACK
8. Yes
9. Lists
10. Graphs
11 PUSH
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 115
12 pop
13. len()
14. 0
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 116
10. (a) Ans: [[9, 6], [4, 5], 10]
(b) Ans: [[9, 6], [4, 5, 10]]
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 117
14. (a) Ans: ‘P’
(b) Ans: ‘d’
(c) Ans: ['modern', 'programming']
(d) Ans: 'programming'
(e) Ans: 'g'
(f) Ans: 'Python'
(g) Ans: 'h'
(h) Ans: IndexError: list index out of range
15. Ans: pop() will delete the last element of a list whereas pop(0) will delete element at
index zero of a list
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 118
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 119
5. #Stack operation-Push
6. #stack operation-Pop
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 120
8.
9.
10.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 121
11.
12
13
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 122
COMPUTER NETWORKS
Model Questions
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 123
8. A _ is established in circuit switching before actual communication.
a. Switch b. Link c. Protocol d. Hub
9. The is the difference between upper and lower frequencies of a
communication medium.
a. Bandwidth b. Data rate c. Latency d. communication speed
10. The unit of Bandwidth is?
a. Khz b. Hz c. Watt d. KW
11. For every device connected to a network, there will be a unique _ _.
a. Name b. ID c. IP Address d. IC
12. Raw data is processed to get .
a. File b. Information c. Communication d. Message
13. Which of the following is/are true regarding packet switching?
1. The packets of data are sent simultaneously through different paths.
2. The free communication channel is utilized properly.
3. Protocols are used for the reliable receipt of data at the receiver end.
4. Sequence numbers are assigned to the data packets.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 150
18. Establishing a Terminating
Communication
Connection Connection
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 151
a. LAN, WAN, MAN b. WAN, LAN, MAN
c. MAN, LAN, WAN d. WAN, MAN, LAN
26. You are a member of a club that deals with computer networks. The club has to take
a project to build a MAN. Where would this project likely take place?
a. A small building/organization b. University or college
c. Home d. None of the above
27. What is the acronym MAN stand for?
a. Magnetic Access Network b. Metropolitan Area Network
c. Multi-Area Network d.. Multi-Access net
28. In your school there is a library, and you can use the internet to do research, this
library will most likely be a WAN network?
a. True b. False
29. Types of Networks are Categories by their Geographical Area cover?
a. True b. False
30. Metropolitan Area Network Normally Require an Internet connection?
a. True b. False
31. What’s a web browser?
a) A kind of spider
b) A computer that store www files
c) A person who likes to look at websites
d) A software program that allows you to access sites on the World Wide Web
32. A is a document commonly written and is accessible through the internet or
other network using a browser?
a) Accounts b) Data
c) Web page d) Search engine
33. Which of the following is used to read HTML code and to render Webpage?
a) Web Server b) Web Browser
c) Web Matrix d) Weboni
34. Which of these tech company owns Firefox web browser?
a) Lenovo b) IBM
c) Apple d) Mozilla
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 152
35. Which of the following browsers were/are available for the Macintosh?
a) Opera b) Safari
c) Netscape d) All of these
36. What is the name of the browser developed and released by Google?
a) Chrome b) Googly
c) Heetson d) Titanium
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 153
(a) Web Servers (b) Web Browsers
(c) Web Designers (d) Web Crawler
46_ is a mark-up language that helps in developing web pages.
(a) HTTP (b) HTML (c) XML (d) C++
47 is a language used to transport data over internet.
(a) HTTP (b) HTML (c) XML (d) C++
48. is a set of rules for communication between two computers over a
network.
(a) Modem (b) Protocol
(c) Switch (d) IP address
49. In web services, the communication takes place between
(a) Two electronic devices (b) Two human beings
(c) Two spiders (d) None of the above
50. Web services means services provided by
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 154
7. Mr. Roy, General Manager of Infopark Solutions discovered that the communication
between his company’s main office and HR office is extremely slow and signals drop quite
frequently. These offices are 150 meters away from each other and connected by an
Ethernet cable. Suggest him a device which can be installed between the offices for
smooth communication.
8. Name The transmission media best suitable for connecting to hilly areas.
9. How many pair of wires are there in twisted pair cable (Ethernet)?
10. Name a device that forwards data packets along networks.
11. What is the full form of WWW?
12. What is the full form of Internet?
13. Who invented the WWW in 1989?
14. Special software’s that is used to view webpages are
15. are used to store webpages, so whenever a request, it will serve the request.
16. are programs /computers used to store information’s in the form of
webpages.
17. Web pages that are linked to each other via _
18. _ protocol is used to transfer web pages over internet.
19. Full form of HTTP?
20. is a massive collection of digital pages to access information over the
Internet
21. Write any 2 differences between HTML & XML?
22. is a real-time communication between two or more users via computer.
23. helps us to learn anywhere using Internet.
24. allows customers to conduct financial transactions on a secure Website.
25. Internet can be used to get reservation of trains and air planes through
service.
26. helps to create and maintain social relationship over web.
27. Expand the following abbreviations:
a. HTTP
b. XML
c. HTTPS
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 155
d. HTML
e. VoIP
28. Name any two common web browsers.
29. Full form of Email is
30. What out of the following, you will use to have an audio visual chat with an expert
sitting in a faraway place to fix-up technical issues?
(i) E-mail (ii) VoIP (iii) FTP
31. Match the following
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 156
III. Short Answer Type (Theory with Answers)
1. Your friend wishes to install a wireless network in his office. Explain him the difference
between guided and unguided media.
Guided media uses cables to connect computers, whereas unguided media uses
waves
2. What are Protocols? Name the protocol used to transfer a file from one device to the
other.
Protocols are set of rules that are followed while transmitting data through a
computer network. Protocols determines how to data can be moved securely from a
source device to a destination device. The protocol used for transferring a file from one
device to another is the File Transfer Protocol (FTP)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 157
Data transfer rate: It is the amount of data moved through a communication channel per
unit time. The units of Data transfer rate are Bits per second (Bps), Kilobits per second
(Kbps) , Megabits per second (Mbps) or Gigabits per second (Gbps).
9. Explain why Circuit Switching is not cost effective compared to Packet Switching?
The Circuit Switching is not cost effective like Packet Switching because, in Circuit
Switching, every time there is a need to set up a connection between the sender and the
receiver before communicating the message.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 158
10. Explain how an IP Address become helpful in investigating cyber-crimes.
IP address can be used to trace the physical location of a user connected to a network. By
this many cyber crime can be investigated and traced out efficiently tracking the exact
location from where the cybercrime is carried out.
12. What is the difference between World Wide Web & Internet?
Internet means interconnected networks that spread all over the world (i.e. the
physical infrastructure), while WWW means the information’s (available in the form of
webpages) that can be accessed through internet.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 159
17. Give one suitable example of each URL and domain name?
URL: https://kvsangathan.nic.in/hq-gyan-kosh
Domain name: kvsangathan.nic.in
20. Differentiate between the terms Domain Name and URL in context of web services.
Also write one example of each to illustrate the difference.
Domain Name URL
A domain name or website name URL is a string that represents the complete web
is a human-friendly text form of address of any web page. It’s used to locate a
the IP address. webpage.
It is the part of the URL that is It is the string that represents a complete web
more human friendly. address that contains the domain name.
Example: kvsangathan.nic.in Example: https://kvsangathan.nic.in/contact-us
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 160
4) Which of the following is not a network protocol?
(i) HTML (ii) HTTP (iii) SMTP (iv) FTP
6) Devanand, a student of Class XII, is not able to understand the difference between
web client and web-server. Help him in understanding the same by explaining their
role and giving suitable example of each.
7) Write the full form of Cc and Bcc (used in email communication). Explain the
difference between them.
8) Define Internet and write its two uses in our daily life. How is it different from the
World Wide Web (WWW).
14) Among the following service available on the World Wide Web are?
i) Email ii) HTML iii) XML iv) Video conferencing
(a) (i) and (ii) (b) (i) and (iv)
(c) (ii) and (iii) (d) None of the above
15) HTML and XML are _
(a) Programming Languages (b) Scripting Languages
(c) Mark-up Languages (d) None of the above
16) XML uses
(a) User defined tags (b) Predefined Tags
(c) Both user defined and predefined tags (d) None of the above
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 161
17) XML was not designed to _
(a) store the data (b) present the data
(c) carry the data (d) both a & c
18) Which of the following will you suggest to establish the online face to face
communication between the people in the Regional Office Ernakulum and Delhi
Headquarter?
(a) Cable TV (b) Email
(c) Text chat (d) Video Conferencing
19) What kind of data gets stored in cookies and how is it useful?
21) “With XML you invent your own tags”, Explain this statement with the help of
example.
22) Define Domain Name Resolution?
23) tags are case sensitive and tags are not case
sensitive.
(a) HTML, XML (b) HTTP, XML
(c) XML, HTTP (d) XML,HTML
25) Which protocol helps us to browse through web pages using internet browsers?
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 162
30) . MyPace University is setting up its academic blocks at Naya Raipurand is planning
to set up a network. The University has 3 academicblocks and one Human Resource
Center as shown in the diagram below: Study the following structure and answer
questions (a) to (e)
a) Suggest the most suitable place (i.e., Block/Center) to install the server of this
University with a suitable reason.
b) Suggest an ideal layout for connecting these blocks/centers for a wired
connectivity.
c) Which device will you suggest to be placed/installed in each of these
blocks/centers to efficiently connect all the computers within these blocks/centers?
d) Suggest the placement of a Repeater in the network with justification.
e) The university is planning to connect its admission office in Delhi, which is more
than 1250km from university. Which type of network out of LAN, MAN, or WAN will
be formed? Justify your answer.
2. What happens to the Network with Star topology if the following happens:
(i) One of the computers on the network fails?
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 163
(ii) The central hub or switch to which all computers are connected, fails?
3. Two doctors have connected their mobile phones to transfer a picture file of a person
suffering from a skin disease. What type of network is formed?
4. SunRise Pvt. Ltd. is setting up the network in the Ahmadabad. There are four
departments named as MrktDept, FunDept, LegalDept, SalesDept.
MrktDept to FunDept 80 m
MrktDept to LegalDept 180 m
MrktDept to SalesDept 100 m
LegalDept to SalesDept 150 m
LegalDept to FunDept 100 m
FunDept to SalesDept 50 m
MrktDept 20
LegalDept 10
FunDept 8
SalesDept 42
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 164
5. Name the protocol Used to transfer voice using packet switched network.
6. What is HTTP?
7. Write the purpose of the following devices:
(i). Network Interface Card
(ii). Repeater
3. The following is a 32 bit binary number usually represented as 4 decimal values, each
representing 8 bits, in the range 0 to 255 (known as octets) separated by decimal points.
192.158.1.38
What is it? What is its importance?
4. Dinsey has to share the data among various computers of his two offices branches
situated in the same city. Name the network (out of LAN, WAN, PAN and MAN) which is
being formed in this process.
5. . Global Pvt. Ltd. is setting up the network in the Bangalore . There are four
departments
Distances between various buildings are as follows:
Accounts to Research Lab 55 m
Accounts to Store 150 m
Store to Packaging Unit 160 m
Packaging Unit to Research Lab 60 m
Accounts to Packaging Unit 125 m
Store to Research Lab 180 m
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 165
Number of Computers
Accounts 25
Research Lab 100
Store 15
Packaging Unit 60
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 166
ANSWER KEY
I. Multiple Choice Questions(MCQ)
1. a 2. d 3. c 4. b 5. a
6. a 7. c 8. b 9. a 10. b
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 167
8. Microwave / Radio wave
9. Two insulated copper wires
10. Router
11. World Wide Web
12. Interconnected Networks
13. Tim Berners-Lee
14. Web browsers
15. Web servers
16. Web servers
17. hyperlinks
18. HTTP- HyperText Transfer Protocol
19. HyperText Transfer Protocol
20. World Wide Web(WWW) or Web
21. Refer comparison table
22. Chat
23. E-learning
24. Internet banking
25. E-reservation
26. Social networking websites
27.
a. HTTP- HyperText Transfer Protocol
b. XML – eXtensible Mark-up Language
c. HTTPS - HyperText Transfer Protocol Secure
d. HTML - HyperText Mark-up Language
e. VoIP-Voice over Internet Protocol
28. Google Chrome, Mozilla Firefox
29. Electronic mail
30. Ii.VoIP
31.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 168
A Video conferencing P Each of the end user has a camera as well as
microphone to capture video and audio in real time
and it will be transmitted over internet
B E-Shopping Q Purchasing products through computers/mobile
devices
C E-mail R Messages normally reaches a recipients account
within seconds
D E-reservation S Without ever having to go booking office
E E-learning T Self-paced learning modules allow students to work at
their own speed
32.
Web Services Applications
A Video conferencing P VConSol
B E-Shopping Q GEM
C E-mail R Gmail
D E-reservation S IRCTC
E E-learning T Diksha App
F Social Networking U Instagram
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 169
Bcc : Blind Carbon Copy: no recipient can check who else has received the mail.
8. The Internet is a worldwide network that links many smaller computer-networks.
Uses of the Internet 1. E-learning 2. E-commerce
The difference between the internet and www:
Internet means interconnected networks that spread all over the world (i.e. the physical
infrastructure), while WWW means the information’s (available in the form of webpages)
that can be accessed through internet.
9. Web Browser
10. Server
11. A website is a collection of interlinked webpages.
12. Web Browsers
13. Role of server is to serve various clients (sharing data or resources among multiple
clients)
14. (b) (i) and (iv)
15. (c) Mark-up Languages
16. (a) User defined tags
17. (b) present the data
18. (d) Video Conferencing
19. Cookies can store a wide range of information, including personally identifiable
information (such as your name, home address, email address, or telephone number).
Cookies often store your settings for a website, such as your preferred language or
location. When you return to the site, browser sends back the cookies that belong to the
site. This allows the site to present you with information customized to fit your needs.
20. (a) .com - commercial
(b) .org - organization
21. XML tags are created by the user as there are no standard tags.
Ex : <name>Nayana<name>
22. The process of converting domain names (website names) into corresponding IP
address with the help of DNS servers is called domain name resolution.
23. (d) XML,HTML
24. (d) Photoshop
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 170
25. HTTP - Hyper Text Transfer Protocol
26. Google Chrome or any other valid browser name
27. (B) Extensible Markup Language
28. (D) FTP
29. Web Server
30 a. Most suitable place to install the server is HR center, as this center has maximum
number of computers.
b.
c. Switch
d. Repeater may be placed when the distance between 2 buildings is more than 70 meter.
e. WAN, as the given distance is more than the range of LAN and MAN.
1. Advantage: Since there is a single common data path connecting all the nodes, the
bus topology uses a very short cable length which considerably reduces the installation
cost.
Disadvantage: Fault detection and isolation is difficult. This is because control of the
network is not centralized in any particular node. If a node is faulty on the bus, detection
of fault may have to be performed at many points on the network. The faulty node has
then to be rectified at that connection point.
2. (i). failure in one cable will not affect the entire network
(ii). If the central hub or switch goes down, then all the connected nodes will not be able
to communicate with each other.
3. PAN
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 171
ii) As per 80 – 20 rule, SalesDept because it has maximum no. of computers.
iii) Each building should have hub/switch and Modem in case Internet connection is
required.
iv) MAN (Metropolitan Area Network)
5. VoIP
6. HTTP is a protocol that is used for transferring hypertext(i.e. text, graphic, image,
sound, video, etc,) between 2 computers and is particularly used on the World Wide
Web (WWW)
7.
(i) Network Interface Card (NIC) is a network adapter used to set up a wired network. It
acts as an interface between computer and the network.
(ii) A repeater is a device that amplifies a signal being transmitted on the network.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 172
(ii) The most suitable place/ building to house the server of this organization would be
building Research Lab, as this building contains the maximum number of computers
(iii). a)Repeater : distance between Store to Research Lab is quite large, so a repeater
would ideally be placed.
b) Hub/Switch : Each would be needed in all the buildings to interconnect the group
of cables from the different computers in each building.
6. IP address 192.168.1.1
URL : https://www.apple.com/
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 173
Interface Python with SQL database
# TO CREATE A TABLE IN MYSQL USING PYTHON INTERFACE
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="s
ystem",database="student")
mycursor=mydb.cursor()
mycursor.execute("CREATE TABLE FEES (ROLLNO INT,NAME
VARCHAR(20),AMOUNT INT);")
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="system
",database="student")
mycursor=mydb.cursor()
mycursor.execute("SHOW TABLES")
for x in mycursor:
print(x)
#TO DESCRIBE TABLE STRUCTURE USING PYTHON INTERFACE
mydb=mysql.connector.connect(host="localhost",user="root",passwd="system"
,database="student")
mycursor=mydb.cursor()
mycursor.execute("DESC STUDENT")
for x in mycursor:
print(x)
# TO EXECUTE SELECT QUERY USING A PYTHON INTERFACE
import mysql.connector
conn=mysql.connector.connect(host="localhost",user="root",passwd="12345
",database="student")
c=conn.cursor()
c.execute("select * from student")
r=c.fetchone()
while r is not None:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 197
print(r)
r=c.fetchone()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 201
# TO DELETE A RECORD FROM THE TABLE USING PYTHON INTERFACE
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="system
",database="student")
mycursor=mydb.cursor()
mycursor.execute("DELETE FROM STUDENT WHERE MARKS<50")
mydb.commit()
print(mycursor.rowcount,"RECORD DELETED")
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="syste
m",database="student")
mycursor=mydb.cursor()
mycursor.execute("ALTER TABLE STUDENT MODIFY GRADE CHAR(3)")
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 202
commit( ): After executing insert or update query we must commit our
transaction using commit method of connection object.
Eg: mycon.commit()
rollback( ): mysqlConnection.rollback() reverts the changes made by the
current transaction.
rowcount: This attribute returns the number of rows that were affected
by an execute()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 203
5. Cardinality is total _
a) number of rows in a table
b) number of columns in a table
c) number of data items in a table
d) none of the above
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 204
12. A data ................. is a set of rules that define valid data.
a) Query b)Constraint c)Dictionary d)All of the above
16. Which of the following statements is not true about relational database?
a) Relational data model is the most widely used data model.
b) The data is arranged as a collection of tables in relational database.
c) Relational database increases data redundancy and inconsistency.
d) None of the above.
18. A _ is a property of the entire relation, rather than of the individual tuples in
which each tuple is unique.
a) Rows b)Key c)Attribute d)Fields
19. Which one of the following attribute can be taken as a primary key?
a) Name b)Street c)Id d)Department
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 205
21. Answer the questions based on the table Employee.
Table: Employee
c) Which column can be made as the primary key in the table Employee?
i) EMPID
ii) EMAIL
iii) Both i and ii
iv) None of the above
d) If two columns are added to the table Employee, then the cardinality and
degree of the table is …… and …… respectively.
i) 4,7
ii) 7, 4
iii) 6,5
iv) 5,6
e) State True/False:
Both EMPID and EMAIL can be defined as primary key in the table
Employee.
i) True ii)False
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 206
23. A(n) in a table represents a logical relationship among a set of values.
a) Column b)Key c)Row d)Attribute
24. Which of the following attributes can be considered as a choice for the primary
key?
a) Name b)Street c)RollNo d)Subject
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 207
Worksheet 1:
1. There is a column HOBBY in a Table CONTACTS. The following two statements are
4. Kunal has entered the following SQL command on Table ‘STUDENT’ that has
TotalMarks as one of the columns.
SELECT COUNT (*) FROM STUDENT;
The output displayed is 20. Then, Kunal enters the following command :
SELECT COUNT (*) FROM STUDENT WHERE TotalMarks <100;
The output displayed is 15. Then, Kunal enters the following command :
SELECT COUNT (*) FROM STUDENT WHERE TotalMarks >= 100;
He predicts the output of the above query as 5. Do you agree with Kunal ? Give reason
for your answer.
5. Consider the table given below :
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 208
Write command for (i) and output for (ii)
(ii) SELECT Area, COUNT (*) FROM Salesperson GROUP BY Area HAVING COUNT (*) > 1;
6. Consider the table ‘PERSONS’ given below. Write commands in SQL for (i) to (iv) and
write output for (i) to (iii)
(i) How many rows and how many columns will be there in the Cartesian product of
these two tables?
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 209
(ii) Which column in the 'Bill' table is the foreign key?
8. Consider the tables HANDSETS and CUSTOMER given below:
With reference to these tables, Write commands in SQL for (i) and (ii) and output for (iii)
below:
(i) Display the CustNo, CustAddress and corresponding SetName for each customer.
(ii) Display the Customer Details for each customer who uses a Nokia handset.
(iii) select SetNo, SetName from Handsets, customer where SetNo = SetCode and
CustAddress = 'Delhi';
9. Consider the tables DOCTORS and PATIENTS given below:
With reference to these tables, write commands m SQL for (I) and (II) and output for (iii)
below:
(i) Display the PatNo, PatName and corresponding DocName for each patient
(ii) Display the list of all patients whose OPD_Days are MWF.
(iii) select OPD_Days, Count(*) from Doctors, Patients where Patients.Department
= Doctors.Department Group by OPD_Days;
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 210
Worksheet 2
1. The following table represents information on sales representatives of ABC company
with the following data.
Sales man name
Code
Address
commission
salary.
Write Python code to create the above table.
2. Write Python mysql connectivity program to retrieve all the data from a table student.
3. Write a python code to delete all the records from employee table whose age >60
and the table has the following fields. Empid, empname, deptid, age, payscale
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 211
d = int (results[3])
print (d*3)
def Search(eno):
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="sy
stem",database="DB")
mycursor=mydb.cursor()
query="select * from emp where empno= ".format(eno)
mycursor.execute(query)
results = mycursor.
print(results)
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="
system",database="student")
mycursor=mydb.cursor()
mycursor.execute("UPDATE STUDENT SET MARKS=95 WHERE MARKS=50")
print(mycursor.rowcount,"RECORD UPDATED")
Code is running but the record in actualdatabase is not updating, what could be the
possible reason?
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 212
con=msq.connect(#ConnectionString) # Assumingallparameterrequiredas
passed
if _:
print(“Connected!”)
else:
print(“ Error! Not Connected”)
9. Write a python connectivity program to retrieve data, one record at a time from EMP
table for employees with id<10.
10. Write python connectivity program to delete the employee record whose name is
read from the keyboard at execution time.
11. SD School is managing the student data in student table in school database. Write a
python code that connects to database school and display the record of students and
total number of students.
12. Which record will get inserted in the table by the following code:
Import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="s
ystem",database="db")
mycursor=mydb.cursor()
a=1011
b=”Euphoria”
c=599.00
mycursor.execute("INSERT INTO BOOKS(bookid,bname,price) VALUES
({},'{}',{})" .format(a,b,c))
mydb.commit()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 213
WORKSHEET 3 - Fill in the blanks
1.A ------------------- is a special control structure that facilitates the row by row processing
of records in the resultset.
2.After importing mysqlconnector, first of all --------------- is established by using connect()
3----------------- method executes a database query from within Python.
4. Running of sql query through database cursor returns the table records in the form
of
5. A connectivity package--------------- must be imported before running db connection
program.
program.
a) database object b)connection object c)fetch object d)query object
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 214
3. What do you mean by candidate key?
It is an attribute or a set of attributes or keys participating for Primary Key, to uniquely
identify each record in that table.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 215
9. Meetali is a database programmer, She has to write the query from EMPLOYEE
table to search for the employee who are getting any commission, for this she
has written the query as:
SELECT * FROM EMPLOYEE WHERE commission=null;
But the query is not producing the correct output, help Raj and correct the query
so that he gets the desired output.
10. Raj is a database programmer, He has to write the query from EMPLOYEE table to
search for the employee who are not getting any commission, for this he has
written the query as: SELECT * FROM EMPLOYEE WHERE commission=null;
But the query is not producing the correct output, help Raj and correct the query
so that he gets the desired output.
11. Deepika wants to remove all rows from the table BANK. But he needs to maintain
the structure of the table. Which command is used to implement the same?
12. While creating table ‘customer’, Rahul forgot to add column ‘price’. Which
command is used to add new column in the table. Write the command to
implement the same.
13. Observe the given Table TEACHER and give the output of question (i) and (ii)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 216
(i) SELECT TEACHER_NAME,DOJ FROM TEACHER WHERE TEACHER_NAME LIKE
“%I%”;
(ii) SELECT * FROM TEACHER WHERE DOJ LIKE “%-09-%”;
1. To display NO, NAME, TDATE from the table TRIP in descending order of NO.
2. To display the NAME of the drivers from the table TRIP who are traveling by transport
vehicle with code 101 or 103.
3. To display the NO and NAME of those drivers from the table TRIP who travelled
between ‘2015-02-10’ and ‘2015-04-01’.
4. To display all the details from table TRIP in which the distance travelled is more than
100 KM in ascending order of NOP
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 217
ANSWERS: 1. Multiple Choice Questions (MCQ )
1 D 2 A 3 B 4 B
5 A 6 B 7 C 8 B
9 A 10 B 11 A 12 B
13 D 14 B 15 A 16 C
17 D 18 B 19 C 20 B
13 Foreign key
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 218
South 2
6. I) 132000
II) F 42000
M 33000
III) F 3
M 4
7. i) 15 rows and 6 columns
ii) custID
8. i) select Custno,CustAddress,setName from customer c,handset h where
c.setNo=h.setName;
ii) select Custno,CustAddress,setName from customer c,handset h where
c.setNo=h.setName and h.setName like ‘Nokia%’;
iii) N2 Nokia 3G
B1 Blackberry
9. I) select patNo,PatName,DocName from Patient p,doctor d where
p.docID=d.docID;
II) select patNo,PatName,DocName from Patient p,doctor d where
p.docID=d.docID and OPD_Days=”MWF”;
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="syste
m",database="sales") mycursor=mydb.cursor()
mycursor.execute("CREATE TABLE SALESMAN (NAME VARCHAR(20),CODE INT
,ADDRESS VARCHAR(20), COMMISSION DEC,SALARY FLOAT);")
2.
import mysql.connector
conn=mysql.connector.connect(host="localhost",user="root",passwd="syste
m",database="DB") c=conn.cursor()
c.execute("select * from student")
r=c.fetchone()
while r is not None:
print(r)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 219
r=c.fetchone()
conn.close()
3.
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="system
",database="DB") mycursor=mydb.cursor()
mycursor.execute("DELETE FROM EMP WHERE AGE>60
") mydb.commit()
print(mycursor.rowcount,"RECORD DELETED")
mydb.close()
4. 165000
5. .{ } and fetchone()
7. con.is_connected()
8. fetchall() function is used to fetch all the records from the cursor in the form of tuple.
fetchone() isusedtofetchonerecordatatime. Subsequentfetchone() willfetch
nextrecords. If no more records to fetch, it returns None.
9. import mysql.connector
conn=mysql.connector.connect(host="localhost",user="root",passwd="system",datab
ase="com")
c=conn.cursor()
c.execute("select * from emp where id>10")
r=c.fetchone()
while r is not None:
print(r)
r=c.fetchone()
conn.close()
10.
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="system
",database="DB") mycursor=mydb.cursor()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 220
s= input(“enter the name”)
mycursor.execute("delete from emp where name =’,-’)”.format(s)
mydb.commit()
11.
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="system
",database="school") mycursor=mydb.cursor()
sql=”select * from student”
mycursor.execute(sql)
recs=mycursor.fetchall()
count=0
for r in recs:
count+=1
print(r)
print(“total no of records”,count)
1. database cursor
2. database connection.
3. execute()
4.resultset
5.mysql.connector
1. b)fetchtwo()
2. b)fetchone()
3. c)commit()
4. b)execute()
5. b)connection object
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 221
Answers-MODEL PRACTICE QUESTIONS
1. ALTER TABLE
2. IS NULL
3. DESC
4. LIKE
% (percent) and _ (underscore)
5. ORDER BY
6. DISTINCT
7. DROP TABLE
8. DESC
9. SELECT * FROM EMPLOYEE WHERE commission IS NOT null;
10. SELECT * FROM EMPLOYEE WHERE commission IS null;
11. DELETE FROM BANK.
(ii)
TEACHER_CODE TEACHER_NAME DOJ
----------------------------------------------------------------------
T002 AMIT 2007-09-05
T003 ANKIT 2007-09-20
14.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 222
KENDRIYA VIDYALAYA SANGHATHAN – ERNAKULAM REGION
SAMPLE PAPER-1(SOLVED) – COMPUTER SCIENCE (083)
General Instructions:
1. This question paper contains five sections, Section A to E.
6. A network device used to divide a single computer network into various sub- 1
networks . i)router ii)switch ii)hub iv)R
7. With SQL, how do you select all the records from a table named “Persons” 1
where the value of the column “FirstName” ends with an “a”?
a) SELECT * FROM Persons WHERE FirstName=’a’
b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d) SELECT * FROM Persons WHERE FirstName=’%a%’.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 223
8. Which of the following is not a DDL command? 1
a) UPDATE b) TRUNCATE c) ALTER d) None of the Mentioned
9. To include the use of functions which are present in the random library, we 1
must use the option:
a) import random
b) random.h
c) import.random
d) random.random
12. Which of the following command is used to change the VALUES OF rows that 1
already exist in a table?
1. Insert. 2. Union. 3. Update. 4. Select
13. Give the output: my_data = (1, 2, "Kevin", 8.9) print (my_data[-3]) 1
1. 8.9 2. “Kevin”. 3. 1 4. 2
16 To write data into CSV from python console, which of the following function is 1
correct?
a) csv.write(file) b) csv.writer(file)
c) csv.Write(file) d) csv.writerow()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 224
18 Ms. Suman is working on a binary file and wants to write data from a list to a 1
binary file. Consider list object as l1, binary file suman_list.dat, and file object as
f. Which of the following can be the correct statement for her?
a) f = open(‘sum_list’,’wb’); pickle.dump(l1,f)
b) f = open(‘sum_list’,’rb’); l1=pickle.dump(f)
c) f = open(‘sum_list’,’wb’); pickle.load(l1,f)
d) f = open(‘sum_list’,’rb’); l1=pickle.load(f)
a) 6+7*4+2**3//5-8
b) 8<5 or no 19<=20 and 11<4
21 Differentiate between Candidate Key and Primary Key in the context Relational 2
Database Mode
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 225
25 In the table Loan below 2
(a) Identify the candidate key(s) from the table Garment.
(b) What is the cardinality and degree of the table?
26 Vedika has created a dictionary containing names and marks as key-value pairs 3
of 5 students. Write a program, with separate user-defined functions to perform
the following operations:
Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
Pop and display the content of the stack.
The dictionary should be as follows:
27. A department is considering to maintain their worker data using SQL to store the 3
data. As a database administer, Karan has decided that :
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 226
characters. Write an appropriate query to change the size.
III) Karan wants to remove all the data from table WORKER from the database
Department.
Which command will he use from the following:
28. Ashok Kumar of class 12 is writing a program to create a CSV file “cust.csv” with 3
custid, custname and mobile no and search custname and delete the record. He
has written the following code. As a programmer, help him to successfully
execute the given task.
import _________ # LINE1
record = list()
custname= input("Please enter a customer name to delete:")
with open('cust.csv', 'r') as f:
data = csv. (f) # LINE2
for row in data:
record.append(row)
for field in row:
if field == custname:
record. (row) #LINE3
with open('cust.csv', 'w') as f:
writer = csv.writer(f)
writer.writerows(record
29. Write SQL commands for(a) to (b) and write the outputs for (C) on the basis of 2+1
table GRADUATE
a) List the names of those students who obtained DIV 1 sorted by NAME .
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 227
b )Display a report, listing NAME , STIPEND , SUBJCT and amount of stipend
received in a year assuming that the STIPEND is paid every month.
C.) Give the output of the following SQL statements based on table GRADUATE :
(i) Select MIN(AVERAGE ) from GRADUATE where SUBJECT=”PHYSICS”;
(ii) Select SUM(STIPEND) from GRADUATE where DIV=1;
30 A) Write a function countmy() in Python to read the text file "DATA.TXT" and 3
count the number of times "my" occurs in the file.
For example, if the file "DATA.TXT" contains "This is my website. I have displayed
my preferences in the CHOICE section." - the countmy() function should display
the output as: "my occurs 2 times"Or
Write a method/function DISPLAYWORDS() in python to read lines from a text
file STORY.TXT, and display those words, which are less than 4 characters.
Or
31. Indian School, in Mumbai is starting up the network between its different wings. 5
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL as
shown below:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 228
a. Repeater b.Hub/Switch
4. The organisation also has inquiry office in another city about 50-60 km
away in hilly region. Suggest the suitable transmission media to interconnect
to school and inquiry office out of the following : (1)
1. The books table of test database contains the records shown below:-
Title ISBN
Die to Live 78127873915
Again? 23686286243
Ushakaal 12678987036
Ushakiran 42568987036
What will be the output produced by following code:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 229
33 A. Considering the following definition of dictionary MULTIPLEX, write a method 5
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".
Or
Following is the structure of each record in a data file named "phonebook.DAT".
,“name”: value, "phone": value}
Write a program to edit the phone number of “Arvind” infile “phonebook.dat”. If
there is no record for “Arvind”, report error.
34 Write SQL commands for the queries (i) to (iii) and output for (iv) & (vii) based 4
on a
I) Identify the most appropriate Primary key for Tables Company and Customer.
Ii) To display those company name which are having prcze less than 30000.
iii a.To increase the price by 1000 for those customer whose name starts with S?
Or
Iii)a) Delete the records from table customer whose name has KUMAR.
B. Insert a new record in table COmpany where CID : 777, Name : APPLE City
KOCHI and PRODUCTNAME is LAPTOP
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 230
35 Aradhana is creating a binary file student.dat that has structure 4
(rollno,name,class,percentage). She wrote a program to updating a record in
the file requires roll number to be fetched from the user whose name is to be
updated. She has few doubts in the code. Help her to complete the task. She
uses intermediate file for working temp.dat
Import ______ #STATEMENT 1
import os
f1 = open(‘student.dat','rb')
f2=open(“temp.dat”,” ”) #Statement2
r=int(input(“enter rollno which you want to search”))
try:
while True:
e = pickle.load(f1)
if e[0]==r:
e*1+=input(“enter name”)
pickle.dump( ) #Statement3
else:
pickle.dump(e,f2)
except:
f1.close()
f2.close()
os.remove(“student.dat”)
os. (“temp.dat”,”student,dat”) #Statement4
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 231
KENDRIYA VIDYALAYA SANGHATHAN – ERNAKULAM REGION
SAMPLE PAPER-1(SOLUTION) – COMPUTER SCIENCE (083)
Part A
Section 1 [18 marks] (1x18)
1. (a) // 1
2. (d)str 1
3. (a) Tuple 1
4. b)LAN 1
5. a)IT act 2000 1
6. ii)switch 1
7. c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’ 1
8. a) UPDATE 1
9. a) import random 1
10. c) more than one 1
11. 4. Memory address of x 1
12 3. Update. 1
13. 4. 2 1
14. c) [1, 3, 2, 1, 3, 2] . 1
15. b) a list of lines 1
16. b) csv.writer(file) 1
17 c) Statement A is correct but Statement B is not correct 1
18 a) f = open(‘sum_list’,’wb’); pickle.dump(l1,f) 1
Section B [2x7=14]
Answer All questions
19 a) 27 b) False 2
20 a) Post Office Protocol b)Transmission Control Protocol/Internet 2
Protocol c) World Wide Web
d) Hypertext Transfer Protocol Secure
21 Candidate Key: The columns which can serve as primary key of a table 2
is known as candidate keys. There can be multiple candidate for a
relation.
Primary Key: Primary key is a field name which identifies rows
uniquely. There can be only one primary key for a relation.
22 1 2
2
3
3
Sum=9
23 ALTER Command is used to add, delete, modify the attributes of the 2
relations (tables) in the database. UPDATE Command is used to update
existing records in a database.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 232
24 i)Cyber stalking ii)Phishing 2
25 a) GCODE, GNAME, b) Degree=5 & Cardinality=6 2
26 def push(stk,item): 3
stk.append(item)
def Pop(stk):
if stk==[]:
return None
else:
return stk.pop()
stk=[]
d={"Ramesh":58, "Umesh":78, "Vishal":90, "Khushi":60, "Ishika":95}
for i in d:
if d[i]>70:
push(stk,i)
while True:
if stk!=[]:
print(Pop(stk),end=" ")
else:
break
27 I) WORKER_ID 3
II) alter table worker modify FIRST_NAME varchar(20);
lll)DELETE FROM WORKER;
28. a) csv 3
.b) reader
.c) remove
29 A. List the names of those students who obtained DIV 1 sorted by 2+1
NAME .
Ans.: SELECT name FROM graduate WHERE div=1 ORDER BY name;
(b )Display a report, listing NAME , STIPEND , SUBJCT and amount of
stipend received in a year
assuming that the STIPEND is paid every month.
Ans.: SELECT name, stipend, subject, stipend *12 FROM graduate;
(C) Give the output of the following SQL statements based on table
GRADUATE :
(i) Select MIN(AVERAGE ) from GRADUATE where SUBJECT=”PHYSICS”;
Ans. MIN(AVERAGE)
63
(ii) Select SUM(STIPEND) from GRADUATE where DIV=1;
Ans.: SUM(STIPEND)
1000
30 A) 3
def countmy ():
f = open("DATA.txt", "r")
count = 0
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 233
x = f.read()
word = x.split()
for i in word :
if (i == "my") :
count = count + 1
print ("my occurs", count, "times")
A. close()
Or
ii) )
def DISPLAYWORDS() :
file = open("story.txt", "r")
lst = file.readlines()
for i in lst :
word = i.split()
for j in word :
if len( j ) < 4 :
print( j )
file.close()
print("Word with length smaller than 3 :- \n")
DISPLAYWORDS()
1.
250 @ 150
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 234
250 @ 100
130 @ 100
c)
(Die to Live 78127873915)
(Again? 23686286243)
(Ushakaal 12678987036)
(ushakiran 42568987036)
Or
B.) Try = 0
f = open("phonebook.det","r")
data = f.readlines()
f.close()
f = open("phonebook.det","w")
name = input("Enter name which you want search :-")
for i in range(len(data)) :
line = data[ i ] . split()
if line[0] == name :
phone = input("Enter new Phone :-")
data[ i ] = name + " " + phone
Try = 1
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 235
if Try != 1 :
print("Try again !!!!! ")
for i in range(len(data)) :
line = data[ i ] . split()
for j in line :
f.write( j + "\t")
f.write("\n")
f.close()
print("Thankyou")
Section E [8 Marks]
[4x2]
34 1)CID for Company and CUSTID for CUtomer 4
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 236
KENDRIYA VIDYALAYA SANGATHAN ERNAKULAM REGION
CLASS XII SAMPLE PAPER-2 2022-23 (SOLVED)
List1=[2,3,5,7,9,11,13]
What will be the value of len(List1)
8 Name the built-in mathematical function / method that is used to 1
return the smallest integer less than or equal to N.
9 Name the protocol that is used to transfer files. 1
10 Ms. Priya is an IT expert. She recently used her skills to access the Admin 1
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 237
password for the network server of Happiest Minds Technology Ltd.
and provided confidential data of the organization to its CEO, informing
him about the vulnerability of their network security. Out of the
following options which one most appropriately defines Ms. Priya?
a) Cracker b) Operator c) Hacker d) Network Admin
11 In SQL, name the clause that is used to sort the records in 1
ascending/descending order of an attribute.
12 In SQL, what is the use of IS NOT NULL operator? 1
13 Name the aggregate function to find the average value in SQL. 1
14 Which of the following is not a DDL command? 1
a) UPDATE b)ALTER TABLE c)CREATE TABLE d)DROP TABLE
15 Name the transmission media best suitable for difficult terrain like hilly 1
areas.
16 Identify the data type of INFO: 1
INFO = ['hello',203,'9',[5,6]]
a. Dictionary b. String c. Tuple d. List
17 Assertion (A):- If the arguments in function call statement match 1
the number and order of arguments as defined in the function
definition, such arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).
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
18 Assertion (A):- If the arguments in function call statement match the 1
number and order of arguments as defined in the function definition,
such arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).
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
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 238
SECTION-B
19 Evaluate the following expressions: 2
a) 16 // 3 + 3 ** 3 + 15 / 4 - 9
b) x>y or y<z and not x!=z If x, y, z=25, 16, 9
20 Differentiate between WiFi and WiMax in context of wireless 2
communication technologies.
OR
Differentiate between Domain name and URL. Illustrate with the help of
suitable example.
21 Expand the following terms: 2
a. GPRS b. GSM c. WLL d. PPP
24 What are the incorrect output(s) from the given options when the following 2
code is executed? Also specify the minimum and maximum values that can
be assigned to the variable VALUE.
import random
VALUE = random.randint (0,3)
SUBJECT=*“PHY”,”CHEM”,”MATHS”,”COMP”+;
for I in SUBJECT:
for J in range(1, VALUE):
print(I, end=””)
print()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 239
Options:
Section- C
26 Write a function Interchange (num) in Python, which accepts a list num of 3
integers, and interchange the adjacent elements of the list and print the
modified list as shown below: (Number of elements in the list is assumed as
even)
Original List:
num = [5,7,9,11,13,15]
After Rearrangement
num = [7,5,11,9,15,13]
27 Write a function in Python that displays the words, starting with uppercase 3
letter in a file ‘legend.txt’.
Example: If the “legend.txt” contents are as follows:
Diego Maradona, Argentinian soccer legend and celebrated Hand of God
scorer dies at 60.
The output of the function should be:
Diego
Maradona,
Argentinian
Hand
God
OR
Write a function countdigits() in Python, which should read each character
of a text file “marks.txt”, count the number of digits and display the file
content and the number of digits.
Example: If the “marks.txt” contents are as follows:
Harikaran:40,Atheeswaran:35,Dahrshini:30,Jahnavi:48
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 240
The output of the function should be:
Harikaran:40,Atheeswaran:35,Dahrshini:30,Jahnavi:48
('Total number of digits in the file:', 8)
28 Write the outputs of the SQL queries (i) to (iii) based on the relations Car 3
and Customer given below:
Car
Ccode Cname Make Colour Capacity Charges
201 Triber Renault Yellow 7 1000
203 Altroz Tata Black 5 1500
208 Innova Toyota Silver 8 3000
209 Harrier Tata White 6 2000
212 Duster Renault Red 6 2500
217 Ertiga Suzuki Grey 7 2300
Customer
Custcode Custname Ccode
101 Gopinath 201
102 Ashok 203
103 Harshini 209
104 Vishnu 212
def Shuffle(str1):
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 241
str2=""
for i in range(0,len(str1)-1):
if(str1[i].islower()):
str2=str2+str1[i].upper()
elif str1[i].isupper():
str2=str2+str1[i].lower()
elif str1[i].isdigit():
str2=str2+'d'
else:
str2=str2+(str1[1-i])
print(str2)
Shuffle('Pre-Board Exam@2023')
Section-D
31 Young Minds Ltd. is an educational organization. It is planning to setup its 5
India campus at Chennai with its head office at Delhi. The Chennai campus
has 4
main buildings – ADMIN, ENGINEERING, BUSINESS and MEDIA.
You as a network expert have to suggest the best network related
solutions for
their problems raised in (i) to (v), keeping in mind the distances between
the
buildings and other given parameters.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 242
Number of Computers installed at various buildings are as follows :
ADMIN 110
ENGINEERING 75
BUSINESS 40
MEDIA 12
DELHI Head Office 20
(i) Suggest the most appropriate location of the server inside the CHENNAI
campus (out of the 4 buildings), to get the best connectivity for maximum
no. of computers. Justify your answer.
(ii) Suggest the topology and draw the cable layout to efficiently connect
various buildings within the CHENNAI campus.
(iii) Which hardware device will you suggest to be procured by the company
to minimize the transmission loss?
(iv) Which will be the most suitable wireless communication medium to
connect Chennai campus with its Delhi head office?
(v) Which of the following will you suggest to establish the online face-to-
face
communication between the people in the Admin Office of CHENNAI
Campus and DELHI Head Office?
(a) Cable TV
(b) Email
(c) Video Conferencing
(d) Text Chat
32 Write the SQL commands for the following questions (i) to (v) based on the 5
relations Car and Customer given below:
Car
Ccode Cname Make Colour Capacity Charges
201 Triber Renault Yellow 7 1000
203 Altroz Tata Black 5 1500
208 Innova Toyota Silver 8 3000
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 243
209 Harrier Tata White 6 2000
212 Duster Renault Red 6 2500
217 Ertiga Suzuki Grey 7 2300
Customer
OR
SECTION E
34 A Book store Current Books is planning to store their book details in a 4
database using SQL. As a database administrator, Poorvekka has decided
that:
(a) Name of the database - CB
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 244
(b) Name of the table - Collections
(c) The attributes of Collections are as
follows:
BookNo - Numeric
BookName – Character of size 25
Price – Numeric
Quantity – Numeric
Table : Collections
BookNo BookName Price Quantity
1647 The Lowland 399 75
5241 The Inheritance Of Loss 555 44
3546 The Guide 641 60
4541 Untouchable 529 53
5025 Train to Pakistan 643 73
6783 Godan 341 97
7614 The God Of Small Things 555 48
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 245
f=open('students.csv',' ') # Line2
writerObj = csv.writer(f)
writerObj.writerow([Name,Admno])
f.close()
#csv file reading code
def Retrievestudents():# to read data from CSV
AddStudents(“Raghava”, “2541”)
AddStudents (“Pooja”,”3411”)
AddStudents(“Krutika”,”2218”)
Retrievestudents () #Line 5
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 246
KENDRIYA VIDYALAYA SANGATHAN: ERNAKULAM REGION
CLASS XII SAMPLE PAPER -2 2022-23(SOLUTION)
MARKING SCHEME
Section - A
1 a) sub%marks 1
2 *“I”, “O”, “U”+ 1
3 Module “csv” 1
4 c) by 1
5 b) K[3] =405 (as tuple is immutable) 1
6 ,“Sub1” : “Physics” , “Sub2” : “Chemistry” , “Sub3”: “Math”- 1
7 7
1
8 floor() from math module 1
9 FTP (File Transfer Protocol) 1
10 c) Hacker 1
11 ORDER BY 1
12 To check for values which are not defined as NULL 1
13 AVG 1
14 a) UPDATE 1
15 Microwave / Radio wave 1
16 d. List 1
17 Ans: (c) A is True but R is False 1
18 Ans: (a) Both A and R are true and R is the correct explanation for A 1
SECTION B
19 a) 26.75 1
1
b) True
20 Wi-Fi is the name of a wireless networking technology that uses radio waves to 2
provide wireless high-speed Internet and network connections.
URL: The Uniform Resource Locator is a means to locate resources such as web
pages on the Internet. URL is also a method to address the web pages on the
Internet.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 247
Example: http://cbseacademic.nic.in/web_material/CurriculumMain22/CS2022-
23.pdf
is an URL where cbseacademic.nic.in is the domain name.
21 a. GPRS – General Packet Radio Services 2
b. GSM – Global System for Mobile communications
c. WLL – Wireless Local Loop/Wireless in Local Loop
d. PPP – Point to Point Protocol
22 Positional Parameter - When function calls are made, there is a one to one 2
correspondence between the argument and the parameter based on the
order/position in which the argument appears in the function.
Ex:
def fun1(x,y,z):
m= x/y-z
print(m)
a,b,c = 5,2,3
fun1(a,b,c)
fun1(4,b,b)
#fun1(a,b) #Error as the third argument is missing
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 248
print(m)
In the above table STUD, AdmNo and RollNo are candidate keys, If RollNo
is selected as Primary Key then AdmNo will be the alternate key.
SECTION C
26 def Interchange(num): 3
for i in range(0,n,2):
num[i], num[i+1] = num[i+1], num[i]
print(num)
num=[5,7,9,11,13,15]
n=len(num)
if n%2==0:
Interchange(num)
Note : Any correct code giving the same result is also accepted
27 def Disp_upper_first(): 3
word=""
f=open("legend.txt","r")
line=f.read()
word=line.split()
for i in word:
if i[0].isupper():
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 249
print(i)
f.close()
Disp_upper_first()
Note : Any correct code giving the same result is also accepted
OR
def countdigits():
c=0
f=open("marks.txt","r")
line=f.read()
print(line)
for i in line:
if i.isdigit():
c+=1
print("Total number of digits in the file:",c)
f.close()
countdigits()
Note : Any correct code giving the same result is also accepted
i.
28 3
Make Count(*)
Toyota 1
Suzuki 1
ii.
Cname Make
Innova Toyota
Duster Renault
Ertiga Suzuki
Harrier Tata
Altroz Tata
Triber Renault
iii.
Custname Cname
Gopinath Triber
Ashok Altroz
Harshini Harrier
Vishnu Duster
29 def Push(nums):
li =[] 3
for i in range(0,len(nums)):
if nums[i]%2!=0:
li.append(nums[i])
if len(li) == 0:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 250
print('Stack is empty!!')
else:
print(li)
Push([10,15,20,25,30,35])
Note : Any correct code giving the same result is also accepted
OR
def popStack(names) :
L = len(names)
if L==0:
print("Stack Underflow")
else:
val = names[L-1]
names.pop(L-1)
return val
res=popStack(['Harikaran','Balaji','Nikhil','Cathrine'])
print('Value returned:',res)
Note : Any correct code giving the same result is also accepted
30 OUTPUT : 3
pRE2bOARDxeXAMaddd
SECTION -D
31 (i) Most suitable place to install the server is ADMIN, as this building has 5
maximum number of computers.
(ii) Topology: STAR
Cable layout:
(iii) Repeater
(iv) Satellite Link
(v) (c) Video Conferencing
32 (i) Select Cname, Charges from Car where Colour=’silver’; 5
(ii) Select distinct Ccode from customer;
(iii) Select min(Charges), max(Charges) from Car;
(iv) Update Car set Charges=Charges - Charges*0.1 from Car R, Customer C
where R.Ccode=C.Ccode;
(v) Select Cname, Make from Car where Charges between 2000 and 3000;
33 import pickle 5
def AddVahan():
f1= open(“vehicle.dat”, “ab”)
RegNo = input(“Enter the vehicle registration number: “)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 251
Type = input(“Enter the vehicle type: “)
Make = input(“Enter the manufacturer name: “)
Year = int(input(“Enter the year of manufacturing: "))
rec = [RegNo, Type, Make, Year]
pickle.dump(rec, f1)
f1.close()
def CountVahan(Type):
f1 = open(“vehicle.dat”, “rb”)
count = 0
try:
while True:
rec = pickle.load(f1)
if Type == rec[1]:
count = count + 1
except:
f1.close()
return count
OR
import pickle
def ShowPlayer():
f1 = open(“player.dat”, “rb”)
count = 0
try:
while True:
rec= pickle.load(f1)
if rec[3] >50 and rec[2] == “India”:
print(rec [0], rec [1], rec [2], rec *3+,sep=”\t”)
count +=1
except:
f1.close()
print(“Number of Indian players with strike rate more than 50=”, count)
SECTION E
34 (a) BookNo 4
(b) Degree=4 Cardinality =7
(c) UPDATE collections SET quantity = quantity + 20 WHERE quantity < 50;
(d) DELETE FROM Collections;
35 (a) Line 1 :import csv 4
(b) Line 2 :f=open('students.csv','a')
(c) Line 3 :readerObj=csv.reader(fobj)
(d) Line 4: Not mandatory, as we have opened the file using “with” operator, it
closes automatically.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 252
KENDRIYA VIDYALAYA SANGATHAN, ERNAKULAM REGION
SAMPLE QUESTION PAPER-3(SOLVED)
COMPUTER SCIENCE
CLASS: XII
Max.Marks:70 Time Allowed:3 hours
General Instructions:
1.
This question paper contains five sections, Section A to E.
2.
All questions are compulsory.
3.
Section A have 18 questions carrying 01 mark each.
4.
Section B has 07 Very Short Answer type questions carrying 02 marks each.
5.
Section C has 05 Short Answer type questions carrying 03 marks each.
6.
Section D has 03 Long Answer type questions carrying 05 marks each.
7.
Section E has 02 questions carrying 04 marks each. One internal choice is given in Q34
against part c only.
8. All programming questions are to be answered using Python Language only.
Q.NO PART A Marks
SECTION 1
Attempt any 15 questions from question no 1 to 21.
Which of the following is not a relational operator
1 1
a) > b)<= c)!= d)=
Identify the data type of result of expression 10<5
2 1
a)bool b)int c)float d)None
Which is not a type of tokens from the following.
3 1
a)keyword b) literals c)Operators d)Class
Identify valid declaration of tuple
a)T=,‘a’,’b’,’c’,’d’- b) T=‘a’,’b’,’c’,’d’
4 1
c)D=(‘a’,’b’,’c’,’d’) d) both b and c
Write the module that need to be imported to execute the function dump():
5 1
a)random b)csv c)mysql.connector d)pickle
Given the list L=[-1,4,6,-5] ,write the output of print(L[-1:-3])
6
a)[4,6,-5] b)[] c)[6,-5] d)error
What will be the output of following:
x,y=10,5
7 x,y=y,x 1
print(x,y)
a) 10,5 b)5 10 c) 5,10 d)10 5
A function can return ------ number of values
8 1
a)0 b)None c)Many d)2
The default file open mode is ----------- mode
9 1
a)r b)r+ c)w d)a
Which of the following is/are mutable data type?
10 1
a)int b)string c)list d)tuple
Which operator in SQL is used to compare a value to a specified list of
11 values 1
a)BETWEEN b)= c)IN d)ALL
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 253
Which of the following is not an aggregate function?
12 1
a)MIN() b)SUM() c)UPPER() d)COUNT()
Which keyword is used to eliminate duplicate values in an SQL select query?
13 1
a)unique b)distinct c)key d)all
Which of the following network device is a broadcasting device
14 1
a)switch b)hub c)gateway d)router
What is the degree of the following relation?
slno dateofadmn class
15 1 2022-06-05 V 1
2 2022-08-23 VIII
a)3 b)5 c)2 d)1
If all devices are connected to a central hub, then topology is called
16 1
a)tree topology b)bus topology c)star topology d)mesh topology
Q17 and 18 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
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 254
b) a=5
print(a+4<10)
22 What is scope? What is the scope resolving rule in python? 2
(a)Expand the following terms:
23 i)MAN ii)HTML 2
b)What is URL ?
Write output for the following code.
def encrypt(str):
str1=""
for i in str:
if i.isupper():
str1+=i.lower()
else:
str1+="*"
return str1
s=encrypt("HeLLo")
print(s)
24 2
or
Go through the python code shown below and find out the possible
output(s) from the suggested options i to iv. Also specify maximum and
minimum value that can be assigned to the variable j.
import random
i=random.random()
j=random.randint(0,6)
print(int(i),”:”,j+int(i))
(i)0:0 (ii)0:6 (iii)1:7 (iv)1:6
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 255
CUSTOMER
CCode CName VCode
Hemant
1 Sahu 101
2 Raj Lal 108
Feroza
3 Shah 105
4 Ketan Dhal 104
a) What will be the output of following statement?
select VehicleName,Capacity from Cabhub c, Customer s where
c.Vcode=s.Vcode and c.capacity<4;
b) Write the output of the queries (i) to (iv) based on the table CABHUB
i) select count(VCode),Color from CABHUB group by Color;
ii) select distinct capacity from Cabhub;
iii) select min(Charges),max(charges) from CABHUB;
iv) select VehicleName,Make from CABHUB order by VehicleName
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 256
L05 21
Write a function SUMNOS() that accept a list L of numbers and find sum of
all even numbers and sum of all odd numbers.
If L=[1,2,3,4],
29 3
Output :
sum of even nos:6
Sum of odd numbers:4
A stack S contains Name of countries.Write a function POP(A), to remove
Name from stack. Function should handle underflow condition and should
return removed element.
30 OR 3
Write a function PUSH(STACK,Name) to add new name to the STACK data
structure . Also display all the names having at least 4 characters from the
stack.
SECTION D
“Learn Together” is an educational NGO. It is setting up its new campus at
Jabalpur for its web based activities. The campus has 4 compounds as shown
in the diagram below:
Y Z
Building
W
X
Building Building
31 5
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 257
Z Building to W Building 35 m
Y Building 15
Z Building 5
W Bulding 20
a) Suggest the most suitable place (i.e. building) to house the server of
this organisation with a suitable reason.
(i) Repeater
(ii) Hub/Switch
RollNo – integer
Name – string
Marks – integer
Address –String
Phone-integer
Note the following to establish connectivity between Python and MYSQL:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 258
Username is root
Password is root
The table exists in a MYSQL database named school.
The details (RollNo, Name, Marks,Address,Phoneno) are to be
accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to establish connection to the database
Statement 2 – to execute the command that inserts the record in the table
Student. Statement 3- to add the record permanently in the database
OR
a) Predict the output of the following
def student(firstname, lastname ='Mark', standard ='Fifth'):
print(firstname, lastname, 'studies in', standard, 'Standard')
student("John")
student('George','Jose','Seventh')
b) The code given below reads the following record from the table named
student and displays only those records whose address is ‘Delhi’ RollNo –
integer Name – string , Marks – integer ,Address-string,Phone-integer
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 259
Statement 3- to read the complete result of the query (records who are from
“Delhi”) into the object named r, from the table student in the database
What are the characteristics of csv file ? Write a Program in Python that
defines and calls the following user defined functions:
When do we use csv file?. Write a Program in Python that defines and calls
the following user defined functions:
SECTION E
Advaith,a manager has stored the details of departments in a table called
DEPARTMENT.
DEPTNO DNAME LOC
----- -------------- --------
34 10 ACCOUNTING NEW YORK 1+1+2
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 260
He wants to add one more record to this table and has written the following
code and unable to insert that record.
INSERT INTO DEPARTMENT VALUES(43,”HRD”);
i. Help him to correct the code for adding the record
ii. How can he restrict Null values in the table
iii. Write a commands to :
a. show the names of department starting with “R”.
b.update LOC as “New York” for DEPTNO 30.
OR(Option for part iii only)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 261
KENDRIYA VIDYALAYA SANGATHAN, ERNAKULAM REGION
Sample Paper-3(SOLUTION)
SUB: COMPUTER SCIENCE
CLASS XII
Q.NO PART A Marks
Section -A
1 d)= 1
2 a)bool 1
3 d)class 1
4 d)both b and c 1
5 d)pickle 1
6 b)[] 1
7 b)5 10 1
8 c)Many 1
9 a)read 1
10 c)list 1
11 c)IN 1
12 c)UPPER() 1
13 DISTINCT 1
14 b)hub 1
15 a)3 1
16 c)star topology 1
17 b 1
18 c 1
Section-B
19 x=10 2
for I in range(a):
if I%3==0:
print(I)
else:
pass
or
What are routers?.
A router is a network device that can receive the data , analyse it and
transmit it to other networks . It is used to connect a Local Area Network to
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 262
the internet. Using a routing table, it ensures that data packets are travelling
through the best suitable paths to their destinations.
In simple words, a gateway is a device that we use for communicating among
various networks possessing different protocol sets. It is responsible for
converting a given protocol to another one.Gateway connects dissimilar
network
21 a) 32 1+1
b) True
23 a) MAN –Metropolitan Area Network b)HTML –Hyper Text Mark up Language 1+1
URL stands for Uniform Resource Locator. A URL is nothing more than the
address of a given unique resource on the Web.
24 h*ll* 2
OR
minimum-0
maximum -1
options(i) and (ii)
25 1. Order By : 2
Order by keyword sort the result-set either in ascending or in descending
order. This clause sorts the result-set in ascending order by default. In
order to sort the result-set in descending order DESC keyword is used.
Order By Syntax –
SELECT column_1, column_2, column_3...........
FROM Table_Name
ORDER BY column_1, column_2, column_3 ......... ASC|DESC;
2. Group By :
Group by statement is used to group the rows that have the same value. It
is often used with aggregate functions for example:AVG(), MAX(), COUNT(),
MIN() etc. One thing to remember about the group by clause is that the
tuples are grouped based on the similarity between the attribute values of
tuples.
Group By Syntax –
SELECT function_Name(column_1), column_2
FROM Table_Name
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 263
WHERE condition
GROUP BY column_1, column_2
ORDER BY column_1, column_2;
OR
26 a) 1+2
Vehicle Capacity
A-Star 3
Indigo 3
b)
I)
count(vcode) color
2 WHITE
1 BLUE
1 RED
1 SILVER
II)
distinct capacity
7
4
3
III)
min(charge) max(charge)
12 35
iv)
Vehicle Name Make
A-Star Suzuki
C Class Mercedes
Indigo Tata
Innova Toyota
SX4 Suzuki
27 def countA(): 3
file=open("ABC.txt",'r')
r=file.read()
s=r.split()
count=0
for i in s:
if i[-1]=='n':
count+=1
file.close()
print("Count of words ending with “n” is", count)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 264
OR
def printnum():
file=open("an.txt",'r')
r=file.read()
for i in r:
if i.isdigt():
print(i)
file.close()
28 a) i) 2+1
TOTAL_PRICE
435
ii)
BookName AuthorName
Science Agarkar
Telugu Nannayya
iv)
b) DESC BOOKS
29 def SUMNOS(L): 3
SE=0
SO=0
for i in L:
if i%2==0:
SE+=i
else:
SO+=i
print(“Sum of Even no:s=”,SE)
print(“Sum of Odd no:s=”,SO)
30 def POP(A): 3
if len(A)==0:
print(“UNDERFLOW”)
else:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 265
val=A.pop()
return val
OR
Write a function PUSH(STACK,Name) to add new name to the STACK data
structure . Also display all the names having atleast 4 characters from the
stack.
def PUSH(STACK,Name):
STACK.append(Name)
#code for displaying
if len(STACK)==0:
print(“Empty stack”)
else:
top=len(STACK)-1
for i in range(top,-1,-1):
if len(STACK[i])>=4:
print(STACK[i] )
31 a) The most suitable place / block to house the server of this organisation 5(1
would be X Building, as this block contains the maximum number of each)
computers, thus decreasing the cabling cost for most of the computers as well
as increasing the efficiency of the maximum computers in the network.
b)
Answer:
Layout 1
Y Z
W
X
Layout 2:
Y Z
W
X
c)
Answer:
The type of network that shall be formed to link the sale counters situated in
various parts of the same city would be a MAN, because MAN (Metropolitan
Area Networks) are the networks that link computer facilities within a city.
d)
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 266
Answer:
(i) In layout1 between X&Z,X&W.In layout2 between Y and Z.Because
distance is more than 90m.
(ii) In both the layouts, a hub/switch each would be needed in all the
buildings, to interconnect the group of cables from the different
computers in each block
e)switch
def DISPLAY_PROD():
found=False
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
for i in data:
if int(i[1])>100:
found=True
print(i[0],i[1])
if found==False:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 267
print("Record not found")
fin.close()
ADD_PROD()
print(“Displaying product having price more than 100\n”)
DISPLAY_PROD()
OR
CSV file are useful when we need to import data into many other software
applications.
import csv
def inser_ROLL():
fout=open("marks.csv","a",newline="\n")
wr=csv.writer(fout)
rollno=int(input("Enter Roll number "))
mark=float(input("Enter mark :: "))
lst=[rollno,mark]
wr.writerow(lst)
fout.close()
def read_ROLL():
fin=open("marks.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(“No.of records=”:,len(d))
for i in data:
print(i)
fin.close()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 268
SAMPLE PAPER (UNSOLVED) – COMPUTER SCIENCE (083)
MAX MARKS: 70 TOTAL TIME : 3 hrs
Part A
Section 1 [18 marks] (1x18)
1 Which of the following is an invalid identifier? 1
a. CS_class_XII
b. csclass12
c. _csclass12
d. 12CS
2 Which of the is a correct statement? 1
a. xyz = 10 100 1000
b. x y z = 10 100 1000
c. x, y, z = 10, 100, 1000
d. x y z= 10, 100, 1000
3 Aman wants to write a function in python. But he doesn’t know how to 1
start with it! Select the keyword used to start a function out of the
following:
a) function
b) start
c) def
d) fun
4 Which of the following is not a part of the python function? 1
a) function header
b) return statement
c) parameter list
d) function keyword
5 Which of the following is the correct statement for checking the presence 1
of a key in the dictionary?
a) <key> in <dictionary_object>
a) <key> not in <dictionary_object>
c) <key> found in <dictionary_object>
d) a) <key> exists in <dictionary_object>
6 What will be the output of : 1
t=(4,5,6)
del t[1]
print(t)
a) (4,6) b) ([4,6])
c) [4,6] d) Error
7 Which of the following statement is correct? 1
a) Tuples are mutable.
b) Tuples are immutable.
c) Tuples and lists are same.
d) All of these are correct.
8 What will be the output of following code: 1
txt="Term 1"
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 269
print(txt*2)
a) Term 1 Term 2
b) Term 1Term 1
c) Term 1 2
d) TTeerrmm 11
9 The append() method adds an element at 1
a. first
b. last
c. specified index
d. at any location
10 Which point can be considered as difference between string and list? 1
a. Length
b. Indexing and Slicing
c. Mutability
d. Accessing individual elements
11 If n=”Hello” and user wants to assign n*0+=’F’ what will be the result? 1
a. It will replace the first character
b. It’s not allowed in Python to assign a value to an individual character
using index
c. It will replace the entire word Hello into F
d. It will remove H and keep rest of the characters
12 In list slicing, the start and stop can be given beyond limits. If it is then 1
a. raise exception IndexError
b. raise exception ValueError
c. return elements falling between specified start and stop values
d. return the entire list
13 Ms. Hetvee is working on a string program. She wants to display last four 1
characters of a string object named s. Which of the following is statement
is true?
a. s[4:]
b. s[:4]
c. s[-4:]
d. s[:-4]
14 Which of the following statement is true for extend() list method? 1
a. adds element at last
b. adds multiple elements at last
c. adds element at specified index
d. adds elements at random index
15 The statement del l[1:3] do which of the following task? 1
a. deletes elements 2 to 4 elements from the list
b. deletes 2nd and 3rd element from the list
c. deletes 1st and 3rd element from the list
d. deletes 1st, 2nd and 3rd element from the list
16 If l=[11,22,33,44], then output of print(len(l)) will be 1
a. 4
b. 3
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 270
c. 8
d. 6
17 Assertion(A) The personal area Network (PAN) is established within a very 1
small area(20 to 30 sq ft) to share the information.
Reason (R ): The campus are network is used to interconnect the
computers located within a campus such as university campus, corporate
campus, hospital campus etc.
Based on the above discussion, choose an appropriate state form the
options given below:
(a) Both assertion and reason are true and the reason is the correct
explanation of assertion.
(b) Both assertion and reason are true but the reason is not the correct
explanation of assertion.
(c) Assertion is true but reason is false.
(d) Assertion is false but reason is true.
(e) Assertion and reason both are wrong.
18 Assertion ( A) : In SQL, the aggregate function Avg() calculates the average 1
value on a set of values and produce a single result.
Reason ( R) : The aggregate functions are used to perform some
fundamental arithmetic tasks such as Min(),Max(), Sum() etc
(a) Both assertion and reason are true and the reason is the correct
explanation of assertion.
(b) Both assertion and reason are true but the reason is not the correct
explanation of assertion.
(c) Assertion is true but reason is false.
(d) Assertion is false but reason is true.
(e) Assertion and reason both are wrong.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 271
(b) Which field will be considered as the foreign key if the tables Customers
and Loan are related in a database?
25 Rewrite the following code in Python after removing all syntax error(s). 2
Underline each correction done in the code.
Value=30
for VAL in range(0,Value)
If val%4==0:
print (VAL*4)
Elseif val%5==0:
print (VAL+3)
else
print(VAL+10)
Section C [15 Marks] [3x5]
Answer All questions
26 Coach Abhishek stores the races and participants in a dictionary. Write a 3
program, with separate user defined functions to perform the following
operations:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 272
27 a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
Table : Teacher
iv) SELECT Name, Place FROM Teacher T, Placement P WHERE Gender =’M’
AND T.Department=P.Department;
Or
29 You are a student in CBSE school. 1 Teacher has given a task to write a 3
python code to perform the following binary file operations with the help of
two user defined functions/modules:
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 273
a) Addrecord() to create a binary file called school.dat containing
student information (in list datatype) - student number, name, marks(out of
100) of each student.
Or
b) Search() to display name and marks of the student by asking the
student number from the user.
30 Give the output of the following Queries from the given table: 3
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 274
(i) Suggest the kind of network required (out of LAN, MAN, WAN) for each of
the following units. (2)
(a) Production Unit and Media Unit
(b) Production Unit and Finance Unit
(ii) Which of the following devices will you suggest for connecting all
computers with each of their office units? (1)
(a) Switch/Hub (b) Modem (c) Telephone
(iii) Suggest a cable/wiring layout for connecting the company’s local office
units located in Chennai. Also, suggest an effective method/technology for
connecting the company’s office unit located in Delhi (2)
32 A. Find an output of the following code 5
def func(b): (2+3)
global x
print(‘Global x=’, x)
y=x+b
x=7
z=x–b
print(‘Local x = ‘,x)
print(‘y = ‘,y)
print(‘z = ‘,z)
x=3
func(5)
B.) ABC Infotech Pvt. Ltd. needs to store, retrieve and delete the records of
its employees. Develop an interface that provides front-end interaction
through Python, and stores and updates records using MySQL.
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 275
Give statements for 1,2 , 3or4
try:
cursor ______ (sql) #statement2
Write a Program in Python that defines and calls the following user defined
functions:
(i) ADD() – To accept and add data of a student to a CSV file ‘Stud.csv’. Each
record consists of a list with field elements as studid,s name and Smark to
store student id, student name and student percent marks respectively.
(ii) Count() – To count the number of records present in the CSV file where
Smark is greater then 75% from stud.csv.
OR
Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user defined
functions:
(i) add() – To accept and add data of a client to a CSV file ‘Client.csv’. Each
record consists of a list with field elements as Cid, Cname and CCity
(ii) search()- To display the records of the Clients whose city is KOCHI
SECTION E ( 4x2= 8 marks)
34 Consider the table ‘PERSONS’ given below 4
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 276
(i) Display the SurNames, FirstNames and Cities of people residing in
Udhamwara city.
(ii) Display the Person Ids (PID), cities and Pincodes of persons in descending
order of Pincodes.
(iii) Display the First Names and cities of all the females getting Basic salaries
above 40000.
(iv) Display First Names and Basic Salaries of all the persons whose
firstnames starts with “G”
35 Consider an employee data, Empcode, empname and salary. Sneha Wrote 4
python function to create binary file emp.dat and store their records. And
function to read and display all the records Help her complete the code
import _______ #STATEMENT 1
def add_record():
f = open(“emp.dat”,”ab”)
empcode =int(input(“employee code:”))
empname = int(input(“empName:”))
salary = int(input(“salary:”))
d = [empcode, empname, salary]
pickle.dump( ) #STATEMENT 2
f. close()
def search():
f=open(“ ______ ”,”rb”) #STATEMENT 3
while True:
try:
d=pickle.load( __ ) #STATEMENT 4
print(d)
except EOFError:
break
f.close()
MD - STUDENT SUPPORT MATERIAL - COMPUTER SCIENCE-083 FOR THE ACADEMIC YEAR 2025-26 277
CBSE 2022 TERM-2 QP WITH MARKING SCHEME
Maximum Marks: 35 Time: 2 hours
General Instructions :
i. This question paper is divided into 3 Sections – A, B and C
ii. Section A, consists of 7 questions (1-7). Each question carries 2 marks.
iii. Section B, consists of 3 questions (8-10). Each question carries 3 marks.
iv. Section C, consists of 3 questions (11-13). Each question carries 4 marks.
v. Internal choices have been given for question numbers 7, 8 and 12.
Section -A
(Each question carries 2 marks)
Also write an example using Python statements for removing the last
element of the list.
Ans Order of operations performed in a Stack is
LIFO (Last In First Out)
pop()
OR
pop(-1)
OR
pop
Example:
L=[10,20,30,40]
L.pop() OR L.pop(-1)
OR
OR
(1 mark for writing correct order)
(1 mark for correct Python statement to demonstrate the pop() function)
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #3/15]
STUDENT SUPPORT MATERIAL COMPUTER SCIENCE(083) 292
2. (i) Expand the following : 1
VoIP, PPP
Ans VoIP : Voice over Internet Protocol
PPP : Point to Point Protocol
(½ mark each for writing correct expansion)
(ii) Riya wants to transfer pictures from her mobile phone to her laptop. She 1
uses Bluetooth technology to connect two devices. Which type of network
(PAN/LAN/MAN/WAN) will be formed in this case?
Ans PAN/ Personal Area Network
(1 mark for correct type of network)
(1 mark each for writing any correct explanation of Attribute and Domain)
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #4/15]
STUDENTS SUPPORT MATERIAL COMPUTER SCIENCE(083) 293
Assume that the required library for establishing the connection between
Python and MYSQL is already imported in the given Python code. Also
assume that DB is the name of the database connection for table MEMBER
stored in the database CLUB.
MYCUR = DB.cursor()
MYCUR.execute("USE CLUB")
MYCUR.execute("SELECT * FROM MEMBER WHERE ACTIVITY='GYM'")
R=MYCUR.fetchone()
for i in range(2):
R=MYCUR.fetchone()
print(R[0], R[1], sep ="#")
Ans M1002#Pratik
M1004#Rakesh
(Note: Deduct ½ mark for missing # or writing the output in a single line OR
writing any additional line along with the correct output)
5. Write the output of the SQL queries (a) to (d) based on the table 2
VACCINATION_DATA given below:
TABLE: VACCINATION_DATA
VID Name Age Dose1 Dose2 City
101 Jenny 27 2021-12-25 2022-01-31 Delhi
102 Harjot 55 2021-07-14 2021-10-14 Mumbai
103 Srikanth 43 2021-04-18 2021-07–20 Delhi
104 Gazala 75 2021-07-31 NULL Kolkata
105 Shiksha 32 2022-01-01 NULL Mumbai
Ans
Name Age
Harjot 55
Srikanth 43
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #5/15]
STUDENTS SUPPORT MATERIAL COMPUTER SCIENCE(083) 294
Ans
City COUNT(*)
Delhi 2
Mumbai 2
Kolkata 1
Ans
City
Delhi
Mumbai
Kolkata
Ans
MAX(Dose1) MIN(Dose2)
2022-01-01 2021-07-20
6 Write the output of SQL queries (a) and (b) based on the following two 2
tables DOCTOR and PATIENT belonging to the same database :
Table: DOCTOR
DNO DNAME FEES
D1 AMITABH 1500
D2 ANIKET 1000
D3 NIKHIL 1500
D4 ANJANA 1500
Table: PATIENT
PNO PNAME ADMDATE DNO
P1 NOOR 2021-12-25 D1
P2 ANNIE 2021-11-20 D2
P3 PRAKASH 2020-12-10 NULL
P4 HARMEET 2019-12-20 D1
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #6/15]
Note:
Deduct ½ mark for any additional row along with the correct rows
Ignore column heading of the output and order of the output rows
Ans
2021-12-25
2019-12-20
Note:
Deduct ½ mark for any additional row along with the correct rows
Ignore column heading of the output and order of the output rows
7. Differentiate between Candidate Key and Primary Key in the context of 2
Relational Database Model.
Ans A table may have more than one or a combination of
attribute(s)that identifies a tuple uniquely. All such
attribute(s) are known as Candidate Keys.
Example:
Table: BANK
ACNO NAME PHONE
10001 RISHABH 9810876677
10031 ARNAV 9810876123
10064 ARNAV 9810875577
10076 GURSHARAN 9810871144
Candidate Keys: ACNO, PHONE
Primary Key: ACNO
OR
(1 mark for writing only the correct explanation/example of candidate key)
(1 mark for writing only the correct explanation/example of primary key)
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #7/15]
STUDENT SUPPORT MATERIAL COMPUTER SCIENCE(083) 296
OR
Consider the following table PLAYER : 2
Table: PLAYER
PNO NAME SCORE
P1 RISHABH 52
P2 HUSSAIN 45
P3 ARNOLD 23
P4 ARNAV 18
P5 GURSHARAN 42
(a) Identify and write the name of the most appropriate column from the
given table PLAYER that can be used as a Primary key.
Ans PNO
(Note: Don’t deduct marks, if any additional column name is also mentioned
along with PNO)
(b) Define the term Degree in relational data model. What is the Degree of
the given table PLAYER ?
Ans Total number of columns/attributes in a table/relation
is known as its Degree.
Section -B
(Each question carries 3 marks)
8. ● Write the definition of a user defined function PushNV(N) which 3
accepts a list of strings in the parameter N and pushes all strings
which have no vowels present in it, into a list named NoVowel.
● Write a program in Python to input 5 Words and push them one by one
into a list named All.
The program should then use the function PushNV() to create a stack
of words in the list NoVowel so that it stores only those words which
do not have any vowel present in it, from the list All.
Thereafter, pop each word from the list NoVowel and display the
popped word. When the stack is empty, display the message
"EmptyStack".
For example:
If the Words accepted and pushed into the list All are
['DRY', 'LIKE', 'RHYTHM', 'WORK', 'GYM']
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #8/15]
for i in range(5) :
All.append(input('Enter a Word: '))
PushNV(All)
while NoVowel :
print(NoVowel.pop(), end=' ')
else :
print('EmptyStack')
OR
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #9/15]
[10,6,14,18,30]
[10,6,18,30]
30 18 6 10 StackEmpty
Ans def Push3_5(N):
for i in N :
if i%3==0 or i%5==0 :
Only3_5.append(i)
NUM=[]
Only3_5=[]
for i in range(5):
NUM.append(int(input('Enter an Integer: ')))
Push3_5(NUM)
while Only3_5 :
print(Only3_5.pop(), end=' ')
else :
print('StackEmpty')
OR
Any other correct equivalent code
(½ mark for checking divisibility correctly)
(½ mark for pushing integers into the stack Only3_5)
(½ mark for reading 5 integers from the users)
(½ mark for assigning those 5 integers into NUM)
(½ mark for writing correct code to pop and display the integers from Only3_5)
(½ mark for writing correct code to check empty stack and display the message
'StackEmpty')
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #10/15]
(b) To display the names of all the tables stored in the opened database.
(c) To display the structure of the table "BOOKS" existing in the already
opened database "LIBRARY".
Section - C
(Each question carries 4 marks)
11. Write SQL queries for (a) to (d) based on the tables PASSENGER and 4
FLIGHT given below:
Table : PASSENGER
Table: FLIGHT
2021-12-25
2021-11-20
2021-12-10
2021-12-20
2021-01-15
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #11/15]
(b) Write a query to display the total number of MALE and FEMALE
PASSENGERS.
(c) Write a query to display the NAME, corresponding FARE and F_DATE of
all PASSENGERS who have a flight to START from DELHI.
(d) Write a query to delete the records of flights which end at Mumbai.
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #12/15]
Ans
topologies.
OR
Any other correct difference/definition/advantages
(1 Mark for mentioning any one correct difference between the topologies)
(½ mark each for writing any one advantage of Bus and Tree Topologies)
OR
(½ mark each for conveying correct understanding of Bus and Tree Topology
using/not using diagram)
(½ mark each for writing any one advantage of Bus and Tree Topologies)
OR
Ans
HTML XML
OR
Any other valid difference/characteristic
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #13/15]
OR
(ii) What is a web browser ? Write the names of any two commonly used web 2
browsers.
13. Galaxy Provider Ltd. is planning to connect its office in Texas, USA with its 4
branch at Mumbai. The Mumbai branch has 3 Offices in three blocks
located at some distance from each other for different operations –
ADMIN, SALES and ACCOUNTS.
As a network consultant, you have to suggest the best network related
solutions for the issues/problems raised in (a) to (d), keeping in mind the
distances between various locations and other given parameters.
Layout of the Offices in the Mumbai branch:
[Sub Code: 083 Series: %BAB% Paper Code: 91 Set - 4] [Page #14/15]
ACCOUNTS Block
(a) It is observed that there is a huge data loss during the process of data
transfer from one block to another. Suggest the most appropriate
networking device out of the following, which needs to be placed along
the path of the wire connecting one block office with another to refresh
the signal and forward it ahead.
(i) MODEM (ii) ETHERNET CARD
(iii) REPEATER (iv) HUB
Ans (iii) REPEATER
(1 Mark for correct identification of the Networking Device)
(b) Which hardware networking device out of the following, will you suggest
to connect all the computers within each block ?
(d) Draw the cable layout (block to block) to efficiently connect the three
offices of the Mumbai branch.
Ans