0% found this document useful (0 votes)
39 views

MId B

This document contains instructions for a mid-term computer science examination. It has two parts - Part A and Part B. Part A has two compulsory sections - Section I containing short answer questions and Section II containing case study questions. Part B is divided into three sections containing different types of short, long and very long answer questions. The questions are from topics like Python programming, SQL, functions, file handling etc. and need to be answered keeping the instructions and marking scheme in mind.

Uploaded by

Krishna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

MId B

This document contains instructions for a mid-term computer science examination. It has two parts - Part A and Part B. Part A has two compulsory sections - Section I containing short answer questions and Section II containing case study questions. Part B is divided into three sections containing different types of short, long and very long answer questions. The questions are from topics like Python programming, SQL, functions, file handling etc. and need to be answered keeping the instructions and marking scheme in mind.

Uploaded by

Krishna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

COMPUTER SCIENCE-(B) \ 1 \ 8

Mid Term Examination


COMPUTER SCIENCE
MT-2022-12(B)

Time : 3 hrs. M. Marks : 70

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

13 Give any two features of MySQL. (1)


14 Identify the problem with the following SQL query
SELECT stream, count(*) FROM sales WHERE avg(perc) > 80 GROUP BY
stream; (1)
15 What will be the output of the following code.
def add(t1):
sum = 0
for val in t1:
if val % 10 % 2 == 0:
sum += val
else:
print(sum)
tup1 = (20,33,42,57)
print(add(tup1)) (1)
16 Write one statement to display the no. of characters present in the first line of a text
file text.txt. Assume text.txt is open in read mode. (1)
17 Differentiate between pop() and clear() method of dictionary (1)
18 Give one similarity and one difference between “a” and “w” mode. (1)
19 Explain any two functions of close() method. (1)
20 What is use of file handle? How it can be created in Python? (1)
21 Which statement is used in Python when null operation is required? Explain with
example. (1)
SECTION-II
Both the Case study-based questions are compulsory. Attempt any 4 sub
parts from each question. Each question carries 1 mark
22 ÁBC University is considering to maintain their data using SQL to store the data. As
a database administer, Abhay has decided that :
• Name of the database - University
• Name of the table - teacher
• The attributes of Teacher are as follows:
Codeno – numeric
Tno - numeric
Name – character of size 30
Age – numeric
Dept – character of size 30
Dateofjoin - Date
Basic – numeric
Gender – character of size
COMPUTER SCIENCE-(B) \ 4 \ 8

Table- Teacher

Codeno Tno Name Age Dept Dateofjoin BASIC Gender


101 1 Arpita 62 Sys 1998-10-21 5000 F
102 2 Zalib 22 Acct 1997-12-12 7000 M
103 3 Karan 32 Fin 1990-02-19 10000 M
104 4 Arunav 12 Sys 1998-11-01 1300 M
105 5 Zubina 30 Fin 1998-12-01 2250 F
106 6 Sahil 23 Sys 1999-12-12 5000 M

(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

(b) Line 2 should extract the Identification id (1)


(c) Line 3 should extract the Code (1)
(d) Fill in the blank in Line 4 to check the validity of Id and Code (1)
(e) Give command to close the file in line 5 (1)
Part – B
Section-I
24 Evaluate the following expressions:
a) 8+7 // 8 * 4 + 2 ** 3 + 3 ** 3
b) 9 > 4 or 4 > 11 and not ( 16 > 1 or 16 < 2 ) (2)
25 a) Explain two methods of data extraction from two or more tables.
OR
b) Differentiate between group conditions and individual tuple conditions with
example. (2)
26 Differerntiate between DDL and DML commands with example. (2)
27 a) Differentiate between built in functions and User defined functions with example.
OR
b) What do you mean by scope of an object. Explain the two types of scopes with
the help of suitable examples. (2)
28 Rewrite the following code in Python after removing all syntax error(s). Underline
each correction done in the code.
int, O2 = 5, “code”
for i in range(-1, -10)
if O2 * “3” == “codecodecode”:
int *= 2
elseif int // 2 != 0:
print (O2 + “A”)
elseif O2==”a”:
print(int + “10”)
else:
print(O2 * 2) (2)
29 What possible outputs(s) are expected to be displayed on screen at the time of
execution of the program from the following code? Also specify the maximum values
that can be assigned to each of the object pos.
import random
List1 = [“Math”,”Computer”,”Physics”,”English”]
for i in range(1,4):
pos= random.randint(3-i,i+1)
print( List1[pos], end=’#’)
COMPUTER SCIENCE-(B) \ 6 \ 8

(i) Physics#English#Computer# (ii) Physics#Physics#Physics#


(iii) Physics#English#Computer (iv) Physics#Physics#Physics (2)
30 Explain all four elements of iterative control structure in Python. (2)
31 What are jump statements? Explain with suitable examples for each. (2)
32 Differentiate between mutable and immutable datatypes. Give statements to prove
the immutability and mutability features of objects of any two datatypes. (2)
33 Find and write the output of the following Python code: (2)

SECTION- II
COMPUTER SCIENCE-(B) \ 7 \ 8

34 Write a User defined function to take a dictionary D1 as argument. Where D1 has


empno as keyfield and a list containing name and salary as value part. Transfer all
employee name to another list for those employees whose salary is more than 50000.
(3)
35 a) Write a function Count( ) in Python that counts the occurrences of uppercase
case consonants present in a text file “A1.TXT”.
If the contents of “A1.TXT” are as follows:
Class XII – Mid Term
Output - 4 (3)
OR
b) Write a function Count() in Python, which should should count and display the
occurrences of “he/ He/ HE” in a text file “Ä1.txt”
36 Write the outputs of the SQL queries (i) to (iii) based on the relations Teacher and
Posting given below: (3)
TABLE - Teacher
P_id T_ID Name Age Department Date_of_join Salary Gender
3 1 Jugal 34 Computer Sc 2017-01-10 12000 M
1 2 Sharmila 31 History 2008-03-24 20000 F
2 3 Sandeep 32 Mathematics 2016-12-12 30000 M
1 4 Sangeeta 35 History 2015-07-01 40000 F
2 5 Rakesh 42 Mathematics 2007-09-05 25000 M
1 6 Shyam 50 History 2008-06-27 30000 M
3 7 Shiv Om 44 Computer Sc 2017-02-25 21000 M
2 8 Shalakha 33 Mathematics 2018-07-31 20000 F

Table - Posting
P_id Department Place
1 History Agra
2 Mathematics Raipur
3 Computer Science Delhi

i. SELECT Place, count(*) FROM Posting GROUP BY Place;


ii. SELECT Sum(Salary), Avg(Salary) FROM Teacher;
iii. SELECT Teacher.Date_of_join,Teacher.Salary, Posting.Place FROM
Teacher, Posting WHERE Teacher.p_id = Posting.P-id AND
Teacher.Date_of_join>”2018-07-31";
COMPUTER SCIENCE-(B) \ 8 \ 8

37 a) Write a function Check(L1) in Python, where L1 is a list of numbers. From L1


create another list L2 such that L2 contains the sum of digits in each element of L1.
If L1= [12, 345, 77] then L2= [3, 12, 14]
OR
b) Write a function Count(L1) in Python where L1 is a list of numbers. Create
another list L2 from L1 such that L2 stores the product of even digits of each ele-
ment of L1. If the number does not have even digits then L2 should have 1
If L1= [11, 345, 5687] then L2= [1, 4, 48] (3)
SECTION-III
38 Consider a dictionary Student- having admno as key, sname, totalmarks, per and
stream as values. Write User Defined Functions for the following-
- Check() which accepts student dictionary as parameter and a string- strm
containing stream. The function should count and return the total number of
students of that stream with percentage more than 90.
- Check1() to accept student dictionary as parameter and return the average of
total marks of all Commerce students. (2½+2½)
39 Write SQL commands for the following queries (i) to (v) based on the relations
Student and Placement given below:
Table - Student
P-id Rno Name Class DOB Gender City Marks
1 1 Anand XI 1997-06-06 M Agra 430
2 2 Chetan XII 1994-05-07 M Mumbai 460
1 3 Geet XI 1997-05-06 F Agra 470
2 4 Preeti XII 1995-08-08 F Mumbai 492
3 5 Saniyal XII 1995-10-08 M Delhi 360
3 6 Maahi XI 2009-12-12 F Delhi 256
2 7 Neha X 1995-12-08 F Mumbai 324
3 8 Nishant X 1995-06-12 M Delhi 429

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

ii. To list gender wise average marks of students of Delhi.


iii. To list the details of all students whose name starts with “P” with their Marks
in ascending order.
iv. To display city wise total marks.
v. To display all details of student and their department for each student. (5)
40 Attempt any one (I or II)
(I) 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 lines are starting with “ing”.

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”.

You might also like