Computer Science
Computer Science
teri.
Roll No. Q.P. Code
91
2cs|2ss
Candidates must write the Q.P. Code on
thetitle page of the answer-book.
COMPUTER SCIENCE
rfeA4 H5:70
Maximum Marks: 70
Timeallowed : 3 hours
SECTION -A
(21 x 1= 21)
1
4 Which of the following is the correct identifier ?
global (B) Break
(A)
(C) def (D) with
1
following options :
6. Identify the invalid Python statement out of the
print ("A" ,10,end="*") (B) print ("A" , sep="*",1)
(A)
print ("A",10,sep="*") (D) print ("A" *10)
(C)
output
the statements given below and then choose the correct
6. Consider 1
from the given options :
L=['TIC', TAC']
print (L[::-1])
(B) ['TIC', 'TAC']
'CIT', 'CAT']
(A)
(D) ['TAC', "TIC']
'CIT']
(C) ['CAT' ,
variable on either
evaluates to True if the
following operator
7 Which of the memory location and False
points towards the same
operator
side of the
otherwise ? (B) is not
(A) is (D) or
P.T.0.
(C) and
Page 5 of 32
91
Consider the statements given below and then choose the correct output
from the given options : 1
D={'S01' :95, 's02':96 )
for I in D :
print(I,end=' #')
(A) S01#s02# (B) 95#96#
(C) sO1,954s02,96# (D) so1#95#S02#96#
10. Consider the statements given below and then choose the correct output
1
from the given options :
def Change (N):
N=N+10
print (N, end='$$')
N=15
Change (N)
print (N)
(A) 25$$15 (B) 15$$25
(C) 25$$25 (D) 2525$$
11. Consider the statements given below and then choose the correct output
1
from the given options :
N='5!
try:
print('WORD' + N, end='#)
except:
print('ERROR',end='#")
finally:
print('OVER')
(B) WORD5#OVER
(A) ERROR#
(D) ERROR{OVER
(C) WORD5# P.T.0.
91 Page 7 of 32
1
. Which of the following built-in function/method returns a dictionary?
(A) dict () (B) keys ()
(C) values () (D) 1tems ()
1
SQL?
13. Which of the following is a DML command in
UPDATE
(B) CREATE
(A)
(D) DROP
(C) ALTER
marks ?
(B) VARCHAR
(A) DATE
(D) CHAR
FLOAT Sup
(C)
1
1
19. Expand ARPANET. Afane Reiearch.
NeturR.
Projeet
ngert
Reason R) based questions. Mark
(A) and
Q. Nos. 20 and 21 are Assertion
the correct choice as
Reason (R) are true and Reason (R) is the
Both Assertion (A) and
(A)
Assertion (A).
correct explanation for
the
Reason (R) are true and Reason (R) is not
(B) Both Assertion (A) and
correct explanation for Assertion (A).
Reason (R) is false.
(C) Assertion (A) is true but,
Reason (R) is true.
Assertion (A) is false but,
(D)
in
records from more than one table
retrieve
(A) : We can 1
21. Assertion
MYSQL.
relationship between
establish a
. Forejign key is used to
Reason (R)
two tables.
P.T.0.
32
Page 11 of
91
SECTION - B (7 x 2= 14)
99 What does the return statement do in a function 2 Explain with the help
2
of an example.
2
23. Write one example of each of the following in Python :
(i) Syntax Error
(ii) Implicit Type Conversion
2
24. Consider the following dictionaries, D and Dl:
D={"Suman": 40, "Raj":55, "Raman": 60}
D1={ "Aditi" :30, "Amit" :90, "Raj":20}
(Answer using built-in Python functions only)
corresponding to
(a) Write a statement to display/return the value
(1)
the key "Raj" in the dictionary D.
OR
D1.
Write a statement to display
the length of the dictionary
(b)
statement to append all the key-value pairs of the
(ii) (a) Write a
dictionary D to the dictionary D1.
OR
"Amit"
delete the item with the given key
(b) Write a statement to
from the dictionary D1.
29. (a) Write a Python function that displays all the lines containing the
word 'vote' from a text file "Elections. txt". For example, if
the file contains : 3
In an election many people vote to choose their representative.
The candidate getting the maximum share of votes stands elected.
Normally, one person has to vote once.
The process of voting may vary with time and region.
Then the output should be:
In an election many people vote to choose their representative.
Normally, one person has to vote once.
OR
(b) Write a Python function that displays all the words starting and
ending with a vowel from a text file "Report. txt". The consecutive
words should be separated by a space in the output. For example, if
the file contains :
Once there was a wise man in a village.
He was an awesome story-teller.
He was able to keep people anchored while listening to him.
Then the output should be:
Once a a awesome able
30. (a) A stack, named Clrstack, contains records of some colors. Each
record is represented as a tuple containing four elements
ColorName, RED GREEN, BLUE. ColorName is a string, and
RED GREEN, BLUE are integers. For example, a record in the
stack may be ('Yellow' 237, 250, 68) 3x 1= 3
Write the following user-defined functions in Python to perform the
specified operations on ClrStack:
takes the
(i) push Clr (ClrStack, new Clr) : This function
stack ClrStack and a new record new Clr as arguments and
stack.
pushes this new record onto the
(iü) pop Clr (ClrStack) : This function pops the topmost record
from the stack and returns it. If the stack is already empty, the
function should display the message "Underflow".
the stack
(iü) isEmpty (ClrStack) : This function checks whether
function should return
is empty. If the stack is empty, the return False
True, otherwise the function should
OR
Page 17 of 32 P.T.O.
91
(b) Write the following user-defined functions in Python :
(i) Push_trail (N, myStack): Here N and mys tack are lists, and
myStack represents a stack. The function should push the last
5 elements from the list N onto the stack mystack. For
example, if the list N is [1,2,3,4,5,6, 7] , then the function
push_trail () should push the elements 3,4,5,6,7 onto the
stack. Therefore the value of stack willbe (3, 4,5,6,7].
Assume that N contains at least 5 elements.
3
31. (a) Predict the output of the following code :
def ExamOn (mystr) :
newstr
countt = 0
else:
newst r = newstr + i.lower
0
Coun t += 1
[:21
newst r = news t r + mystr
string is:", newstr)
Print ("The new
ExamOn ("Genx")
OR
P.T.0.
Page 19 of 32
91
(b) Write the output on execution of the following Python code:
def Change (X) :
for K,V in X.items () :
L1.append (K)
L2.append (V)
D={1;" ONE",2: "TWO",3:"THREE")
Ll=[]
L2=[]
L2
Change (D)
print (L1)
print (L2)
print (D)
SECTION -D (4 x 4 = 16)
32. Suman has created a table named WORKER with a set of records to
maintain the data of the construction sites, which consists of
WID,
WNAME, WAGE, HOURS, TYPE, and sITEID. After creating the table,
she entered data in it, which is as follows :
4
WID WNAME WAGE HOURS TYPE SIEID
WO1 Ahmed J 1500 200 Unski1led 103
W11 Naveen S h 520 100 Skilled 101
WO2 Jacob B 780 95 Unskilled 101
W15 Nihal K 560 110 Semiskilled NULL
W10 Anju S 1200 130 Skilled 103
91 Page 21 of 32 P.T.0.
(a) Based on the data given above, answer the following questions:
1) Write the SQL statement to disply the names and wages of
those workers whose wages are between 800 and 1500.
(iü) Write the SQL statement to display the record of workers
whose SITEID is not known.
(iii) Write the SQL statement todisplay WNAME, WAGE and HOURS of
all those workers whose TYPE is ' Skilled'.
(1v) Write the SQL statement to change the WAGE to 1200 of the
workers where the TYPE is "Semiskilled".
OR
(b) Considering the above given table wORKER, write the output on
execution of the following sQL commands :
) SELECT WNAME, WAGE*HOURS FROM WORKER WHERE
SITEID = 103;
(i1) SELECT COUNT (DISTINCT TYPE) FROM WORKER;
iii) SELECT MAX (WAGE), MIN (WAGE), TYPE FROM WORKER
GROUP BY TYPE;
(iv) SELECT WNAME,SITEID FROM WORKER WHERE
TYPE"Unskilled" ORDER BY HOURS ;
in a hospital.
33. A csv file "P record. csv" contains the records of patients 4
Each record of the file contains the following data:
Name of a patient
Disease
Number of days patient is admitted
Amount
the file may be :
For example, a sample record of
["Gunjan", "Jaundice",4,150001
specified operations
Write the following Python functions to perform the
on this file :
the data from the
(i) Write a function read data () which reads all
Cancer' patients.
fle and displays the details of allthe '
counts and returng the
(ü) Write a function count rec() which
file.
number of records in the
Page 23 of 32 P.T.0.
91
34. Assume that you are working in the IT Department of a Creative Art
Gallery (CAG),which sells different forms of art creations like Paintings,
Sculptures etc. The data of Art Creations and Artists are kept in tables
Articles and Artists respectively. Following are few records from
thesetwo tables: 4 x 1 = 4
Table: Articles
Code | A Code I Article DOC Price
PL001 A0001 Painting 2018-10-19 20000
Table: Artists
A Code Name Phone Email DOB
+ -+ ---.-.
j A0001 Roy 595923 cCrAG.Com 1986-10-12
I A0002 Ghosh 1122334 !ghosh@CrAG. com ! 1972-02-05 !
A0003 Gargi 121212 Gargi@CrAG. com 1996-03-22
A0004 Mustafa 33333333 |M£@CrAg. com 2000-01-01
Note : The tables contain many more records than shown here.
" DOC is Date of Creation of an Article.
As an employee of CAG, you are required to write the SQL queries for the
following :
(1) To display all the records from the Articles table in descending
order of price.
(i) To display the details of Articles which were created in the year
2020.
SECTION - E (2 x 5 = 10)
36. A file, PASSENGERS. DAT, stores the records of passengers
using the
following structure : 5
(PNR, PName, BRDSTN, DESTN, FARE]
where:
PNR Passenger Number (string type)
PName Passenger Name (string type)
BRDSTN Boarding Station Name (string type)
DESTN Destination Station Name (string type)
FARE Fare amount for the journey (float type)
Write user defined functions in Python for the following tasks:
) Create () - to input data for passengers and write it in the binary
file PASSENGERS.DAT.
(ü) SearchDestn (D) to read contents from the file PASSENGERS. DAT
and display the details of those Passengers whose DESTN matches
with the value ofD.
91 Page 27 of 32 P.T.O.
37. 'Swabhaav is a big NGO working in the field of
Psychological Treatment
and Counselling, having its Head Office in Nagpur. It is
planning to set
up a center in Vijayawada. The Vijayawada Center will have four blocks
ADMIN, PSYCHIATRY, PSYCHOLOGY, and ICU. You, as a Network
Expert; need to suggest the best network-related solutions for them to
resolve the issues/problems mentioned in questions (i) to (v), keeping the
following parameters in mind : 5x1=5
ADMIN PSYCHOLOGY
Block Block
Vijayawada Center
PSYCHIATRY ICU
Block Block
ADMIN PSYCHOLOGY 65 m
ADMIN ICU 65 m
som
PSYCHIATRY PSYCHOLOGY 100 -m
PSYCHIATRY ICU 50 m
PSYCHOLOGY ICU 50 m
PSYCHIATRY 40
PSYCHOLOGY 19
ICU 20
P.T.0.
91 Page 29 of 32
DA
OR
(b) Which type of Network (PAN, LAN,
MAN or WAN will be set
up among the computers connected with
Vijayawada Center ?
91 Page 3l of 32