You are on page 1of 7

DELHI PUBLIC SCHOOL, GURGAON

MID TERM EXAMINATION (2021-22)


COMPUTER SCIENCE (083)
CLASS XII
Time: 3 Hrs M.M. 70
No. of Pages: 7
General Instructions:
• This question paper contains two parts A and B. Each part is compulsory.
• Part-A has 2 sections:
• Section – I Short Answers
• Section – II has two case studies questions. An examinee is to attempt any 4 out of the 5 subparts.
• Part - B is Descriptive Paper. It has three sections.
• Section-I is short answer questions of 2 marks each.
• Section-II is long answer questions of 3 marks each.
• Section-III is very long answer questions of 5 marks each.
• All programming questions are to be answered using Python Language only
Part -A
Section-I
Attempt any 15 questions from question number 1 to 21
1 Find the output of “3” *3. 1

a) 3 3 3
b) 9
c) '333'
d)[3,3,3]

2 Which one of the following will create a tuple? 1

a) tup1=tulpe()
b) tup1=[]
c) tup1=(“abc”,”xyz”)
d) tup1=[“abc”,”xyz”]

3 What will be the output of the expression 5*2**3/5-2 1

4 Identify the logical operators in Python from the following. 1


a) and
b) is
c) in
d) nor
5 Will the following code display any output .Justify your answer. 1
val=(‘an’,’or’)
val1=range(len(val))
for i in val1:
val[i]=val[i].lower()
print(val)

XII/Computer Science/1
6 Write a statement in Python to declare a function CUBE that takes an integer as an 1
argument and returns the cube of the number passed as parameter to the function.
7 Predict the output of the following code: 1
Str1 = "International Games"
Str1 = Str1.split()
Stringvalue = Str1[0][0] + ". " + Str1[1][4] + ". " + Str1[1][-4]
print (Stringvalue)
8 Identify the valid identifiers from the following: 1
Average, RegNo., break, SalesQ1
9 Megha wants to display the structure of the table shop, i.e, name of the attributes and their 1
respective data types that she has used in the table. Write the query to display the same.
10 Rashmi wants to ensure that nobody should be able to enter duplicate admission number while 1
inserting values in the table school. Help her to write appropriate constraint while writing the
create statement.
11 Which command in MySQL is used to remove tuples from a relation? 1
12 Identify DDL command from the following: 1
SELECT,ALTER, UPDATE, DROP
13 Given the following dictionary declaration: 1
details={"empid":"A1001" ,"ename":"Suresh" , "department":"Planning"}
write python statement to print the message: “Suresh – Planning” using dictionary details.
14 Rajan wants to import modules in his python code.Help him by telling two ways in 1
which he can do so.
15 Given String STR=”Examination”, choose the correct option(s) to print the substring 1
“min”
a) STR[3:6]
b) STR[3:6:-1]
c) STR[-8:-5:0]
d) STR[-8:-5:-1]
16 Amit wants to change the price of a book he has entered in store table.Identify the MySQL 1
command that will help him to perform the same.
a) insert
b) update
c) alter
d) none of the above
17 Which type of value does input() return? 1
a) Boolean
b) String
c) Int
d) Float
18 A list is given as SNO=[5,7,15,20,35,45] ,What will be the output of SNO[:2] + SNO[2:] 1
19 Write a statement to generate random integer number in the range 15 to 35(including both). 1
20 What will the following function print when called? 1
def addEm(x,y,z):
return x+y+z
print (x+y+z)
sum1=addEm(5,6,7)

XII/Computer Science/2
21 Identify the global variables from the following code: 1
x=5
def func(a):
b=a+1
return b
y=input("enter number")
z=y+func(x)
print(z)
Section-II
Both the case study-based questions are compulsory. Attempt any 4 sub parts from each
question. Each question carries 1 mark
22 Consider the following relation BOOK and answer the queries that follows: 4
SNO TITLE AUTHOR SUBJECT PUBLISHER QTY PRICE
1 DATA LIPSCHUTE DS McGraw 4 217.00
STRUCTURE
2 TURBO C++ ROBERT PROG GALGOTIA 5 270.00
LAFORE
3 DBASE PALMER DBMS PUSTAK 7 130.00
DUMMIES MAHAL
4 GUIDE FREED NET ZPRESS 3 200.00
NETWORK
5 BASIC FOR NORTON PROG BPB 3 40.00
BEGINEERS
6 MASTERING COWART OS BPB 1 225.00
WINDOWS

(a) To display the title of all books with PRICE between 100 and 300. 1
(b) To display TITLE and AUTHOR of the books having subject PROG and published by 1
BPB.
(c) To display list of all the books with price more than 130 in ascending order of QTY. 1
(d) To display average price of books published by BPB. 1
(e) To display maximum price of the book from the relation. 1
23 Rishi has written the following code in python. As a programmer, you have to help him to 4
successfully execute the program.

import _______ #Statement 1


c=5
_______ add(): # Statement 2
______ c # Statement 3
print(c)
c= pow(c,2)
____________ c #statement 4

d=add()
print("In main:", d) # statement 5

XII/Computer Science/3
(a) Name the module to be imported in Statement-1. 1
(b) Write the keyword used to declare the function in Statement-2. 1

(c) Fill in the blank in Statement-3 to use the variable c . 1

(d) Fill in the blank in Statement-4 to send back the value . 1

(e) Write the output which will come with Statement-5. 1

Part – B
Section-I
24 Consider the following nested list definition and then answer the questions based on it. 2
Data = [20, [“XYZ”, [20,30], [20.5, 'Summer', 'Collection']]]
(a) Write the print statement that will print the letter 'C' from 'Collection'.
(b) Write the print statement to print the list [20,30] from the given list.

25 Consider the table given below and write queries based on this table. 2

Table : Course

Field Type Null Key Default Extra


RegNo char(10) NO PRI
RegDate date YES NULL
Course_Name varchar(30) YES NULL
Address varchar(50) YES NULL

(a) Create a table with the above specifications.


(b) Write the format in which date will be entered.

26 Evaluate the following expressions: 2


(a) 47 // 5 + 10 **2 – 25+12
(b) 34 > 56 or 90 > 60 and not 21 > 10

27 What are the two different ways by which an element can be removed from a list?Explain with 2
the help of suitable example.

28 Rewrite the following code in Python after removing all error(s). Underline each 2
correction done in the code.

for val in "string"


if val == i:
Break:
print val
print "The end"

XII/Computer Science/4
29 What are the possible output(s) of the following code? Also specify the maximum and 2
minimum values that can be assigned to variable chance.

import random
chance = random.randint(0,3)
fruits= ["Apple", "Mango", "Banana","Kiwi"]
for x in fruits:
for y in range(0, chance,2):
print (x[y],end = "#")
print()

(i)A# (ii) A#p# (iii) Apple# (iv)# A#


M# M#n# Mango# #M#
B# B#n# Banana# #B#
K# K#w# Kiwi# #K#

30 What is a Foreign Key ? Explain with the help of an example. 2

31 Raman is confused when he should use break or continue statements of python. Explain the 2
usage of the two with the help of an example.
32 What is the difference between Count(*) and Count() in MYSQL? Give an example for each. 2

33 Find the output of the following Python code: 2

def convert(string):
newstr = ""
for i in string:
if i.isnumeric():
newstr = newstr + str(int(i)+1)
elif i.isupper():
newstr = newstr + chr(ord(i)+1)
else:
newstr = newstr + i
print("The new string is :",newstr)
convert(" 2 INDIA is MY Country")

Section- II
34 What are the different ways in which arguments can be passed to a function?Explain any 3
two with the help of an example.

35 Write a user defined function searchbook(bname) where bname is an argument in Python to 3


delete book number from a dictionary library on the basis of the bname , where bname is the
key. After deleting the found value display the entire contents of library.

XII/Computer Science/5
36 Write a function vowels () in Python, to count the number of vowels present in the string 3
entered by the user and passed as argument to the function.

37 Write a Python program to get a string made of the first 2 and the last 2 characters from a 3
given string. If the string length is less than 2, then display empty string.
Sample String : 'Board Examination'
Expected Result : 'Boon'
Sample String : 'An'
Expected Result : 'AnAn'
Sample String : ' i'
Expected Result : Empty String

Section III
38 In a Bank’s database, there are two tables ‘Customer’ and ‘Bank’ as shown 5
below.
Customer
Acc_No Cust_Name Cust_City Open_Bal
2101001 Aditya New Delhi 10000
2201002 Nayan Amritsar 15000
2301003 Amar Nagpur 15000
2401004 Anoushka New Delhi 10000

Bank
Trans_Id Acc_No Transaction_Type Amount
Tr001 2301003 Deposit 15000
Tr002 2201002 Withdraw 20000
Tr003 2101001 Deposit 3500
Tr004 2301004 Deposit 26000
Tr005 2301003 Withdraw 24000
With reference to the above given tables, write commands in MYSQL for (a) – (e)
(a) Write a query to display names of customers who have deposited the money.
(b) Write a query to display customer’s name along with their transaction details.
(c) Write a query to display customer’s name whose city is “New Delhi”.

(d) Write a query to display the minimum opening balance.

(e) Write a query to display different values from transaction_type column.

39 Consider the following table Institute. Write commands in MYSQL for (a) to (d) and output 5
for (e) and (f)
Institute
Course_Code Professor_ID BranchName CourseFees
102 P0021 CS-JAVA 40000
103 P0022 Computer Graphics 16000
104 P0021 Internet Security 8000
105 NULL Machine Learning 15000
106 P0026 Networking 20000
107 NULL APP development 26000
(a) To display names of those branches whose fees is greater than 15000.
XII/Computer Science/6
(b) To display number of branches taught by each professor.
(c) To increase the fees of all courses by 500 for courses where professor is not allotted.
(d) To display details of those Branches which start with “C”.
(e) Select COUNT(DISTINCT (Professor_ID)) from Institute;
(f) Select MAX(CourseFees) from Institute where Fees between 16000 to 50000;

40 Consider the following code and answer the questions that follow: 5
Book={1:'Thriller', 2:'Mystery', 3:'Crime', 4:'Children Stories'}
Library ={'5':'Madras Diaries','6':'Malgudi Days'}
a) Ramesh needs to change the title in the dictionary book from ‘Crime’ to ‘Crime
Thriller’. Help him by writing command for this.
b) What will be the output of the following line of code:
print(list(Library))
c) What will be the result of following statements:
print( 2 in Book)
print(‘Madras Diaries’ in Library)
d) With reference to the above declared dictionaries:

Predict the output of the following code fragments


Code 1 Code 2
Library=Book Library=Book.copy()
Library.pop(2) Library.pop(2)
print(Library) print(Library)
print(Book) print(Book)

e)Write the statement(s) to modify the dictionary Book by appending the contents of
dictionary Library to it.

XII/Computer Science/7

You might also like