MId B
MId B
General Instructions:
1. This question paper contains two parts A and B. Each part is com-
pulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2 sections:
a. Section – I is short answer questions, to be answered in one
word or one line.
b. Section – II has two case studies questions. Each case study
has 4 case-based sub- parts. An examinee is to attempt any 4
out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which
two question have internal options.
b. Section-II is long answer questions of 3 marks each in which
two questions have internal options.
c. Section-III is very long answer questions of 5 marks each in
which one question has internal option.
6. All programming questions are to be answered using Python
Language only
Section-I
Select the most appropriate option out of the options given for each question.
Attempt any 15 questions from question no 1 to 21.
1. Find the invalid expression(s) from the following. Justify
a. ob1 = “aa”, “bb”, “cc”, “dd”
ob2 = ob1 * 3
b. ob1 = [“aa”, “bb”, “cc”, “dd”]
ob2 = ob1 * 3
c. ob1 = “aa bb cc dd”
ob2 = ob1 * “3”
d. ob1 = {‘aa’:bb, ‘cc’:dd}
ob2 = ob1 *3
COMPUTER SCIENCE-(B) \ 2 \ 8
2 Explain the use of return statement in a void and non void function. (1)
3 Which method is used to read a line from a text file? Explain with example.(1)
4 How many times the following loop will execute? Justify your answer.
num = 1000
while num < 100:
print(num + num, end = “\t”)
num //= 10 (1)
5 What will be the output of the following code
def func(a, b=100, c=50):
print(a * b)
func(20, b = 30)
func(10, c = 10, b = 100) (1)
6 What is __main__ segment in Python. Explain with example. (1)
7 Explain the use of nonlocal keyword with example (1)
8 What will be the output of the following code. Justify your answer.
def fun(ob1):
ob1 = ob1 * 2
return ob1
ob1 = 10,20,30
fun(ob1)
print(ob1) (1)
9 Differentiate between pop() and remove() methods of list. (1)
10 What will be the output of the following code.
def change(n):
f, s= n%100,n%10
while n > 0:
r = n%10
if r%2!=0:
f *= r
else:
s +=r
n //=100
return f,s
print(change(87654)) (1)
11 Explain Degree, Attribute (1)
12 Give one difference and one similarity between Primary key and Unique constraints.(1)
COMPUTER SCIENCE-(B) \ 3 \ 8
Table- Teacher
(a) Identify the attribute best suitable to be declared as a primary key and
alternate key. (1)
(b) Write the degree and cardinality of the table Teacher (1)
(c) Insert a record in table Teacher (Assume your own values) (1)
(d) Abhay want to remove the table Teacher from the database University. Which
command will he use from the following:
a) DELETE FROM Teacher;
b) DROP TABLE Teacher;
c) DROP DATABASE Teacher;
d) DELETE Teacher FROM University; (1)
(e) Help Abhay to delete the entire database. (1)
23 Mr. X is writing a program to create a TEXT file “MyText.txt” which contain
Identificationid and codes for all employees of a entries. The identificationid and
codes are separated by a space in the file.The Identificationid is of fixed length i.e. 6
characters and codes are of length 4. He has written the following code to check for
verification of id’s and codes. As a programmer, help him to successfully execute the
given task.
Str= ‘ ’
f = ______________________ #line1
Id = input(“Enter Identification id”)
Code = input(“Enter code”)
while True:
Str = f.readline()
wd = Str.split()
Id1 = ______________ #line2
Code1= _____________ #line3
___________________ #line4
print(“ Identification id/ code INVALID”)
_________ #line5
(a) Give command to open the file in Line 1. (1)
COMPUTER SCIENCE-(B) \ 5 \ 8
SECTION- II
COMPUTER SCIENCE-(B) \ 7 \ 8
Table - Posting
P_id Department Place
1 History Agra
2 Mathematics Raipur
3 Computer Science Delhi
Table: Placement
P_id Department Place
1 History Agra
2 Math Mumbai
3 Computer Science Delhi
i. To show all information about the students of Computer science department
who were born in 1995.
COMPUTER SCIENCE-(B) \ 9 \ 8
OR
(II) Write a menu driven program to perform the following operations. Write
User Defined Functions for each option: (1+1+3)
(i) Create a file - A1.txt.
(ii) Display the file contents
(iii) To read “A1.txt” and count how many words are starting with “ing”.