€
Total No. ofQuestions : Sl
P-t305
? sE,{T Nn. :
l-l'ntal
r---t
\a. of l)*gr: :J
[60ss]-307
ili:rh
. [Link].
^
C.t)Mp, ER scIENCE
G. 58351$: Python Programming
(ffi n*tern) (CBCS) (Semester - v)
Hours"f:)t ''.
ftme: 2 {Nlax- iltnrk: : -1-i
lnstiltctiotrs te the candidates :
2) Figuyrs to the right indicate full nnrks.
3) Toint number of questions nre .five.
a) How arc comments written in.l then?
h ) Give the use of index() irt,sfiing-:. -
c) Explain ttre rnnge{)'f,g14btian+hd its palameters.
d) How to create a vcrid tuii'etion in P1,'thon?
e) What is the differencb ietween pop() anil del in iist.
t) Compare list and tuple (an-v trvo points).
g) What doss the follorving functions retrun - clocki; and gnrtirnc( 1.
h)Listthesyntaxforlrandlingexception..,".=
t'
i) List ary trvq functions in math moclule. ,.,-
j) Explain the function enunrerate$.
P.?',.4.
u
*
.*s
Q2) Atttwpt any Four of the following: [4x2=8]
a) Which rnethods ar e used to read from a file? Explain any tw,o rvith exarnple.
b) What are the usage ot'di5rionary copy(), Bets0, items(.i and keysO
nreiho,li')
l:) l:rpluin uniorr rrnd irrlcrsetti'tn u'ith erurnple.
(l I [,xDlain thc lb]lorvrr:e slaltrrnenl
i) if b) ,' il'else' c) break dl continue
e) I-ist leatur:rys,of Pyl on.
Q3J Attempt an.l;-'Iwo of the following : [2x4=31
a) Write,a prGgranr to get a single string fronr hvo given strings. separated
by-pace and srvap the tilst two characters of each string
Sam@rnput: 'abc'. 'pqr' 't
()rnpyl pqc abr
b) Writ+,a'program to displa-v pou,-e1of 2 ai.1b a given number using
ano11\/nious tillctioh
Exanrple .-io I
\')
2 rlised to 0 is I
2 raised to I is 2 :.'
2 raised to 2 is 4 'l ,.
c ) Write a prograim to riart a;r entire te xt l'ile
Q4l Attempt anv Two of the ftrllowing: [2x4=81
a) Write a pvthon program to Count Vowels and Conso*ar1ts h,q String.
tr) Wlite u Pytlron script to print a dictionary where tt.; ke.1,s are numbers
betn'ecn I and l5 (both included) and the valuors'#e the square of the
ke5.s. ,l;:..
Sanrple Dictionary
trl: 1.2:4,3:9,4: 16,5:25. 6:36, 7:49,8:64.9:81, I 0':r100, l1 , l2l , 12: 144,
13: 169. 14:196. 15:225\1 -- ,. :-i.i:..
c) Write a Python function that acLrepts a.*[Link] counts the number of
uppcr urrd lower sase lclturs.
[60s5]-307
,/, /
*
p-! Attenrpt Auv one of the follorving:
a)
a - l-rLtc
b - Iralsc
r' fulsi
Ii I](]l,l ('r'lr:
llr'inl I i '
Clil ttot U r'l ll(,1 lr ill)(l !.
[Link];: (2)
clii-rr,rt lr ol ll or no1 h and a:
prirt (.1)
elsc:
I't.i,rl {.1,
b) dct I I (x^ l','[ ]t'
for i rit [Link](x):
[Link](i+i)
printl l )
1't (2)
il i3 f3.2.11)
1ti3)
coco
[60ss]-307
Total No. of Questions : 5] SEAT No. :
PA-1029 [Total No. of Pages : 3
[5902]-57
T.Y. [Link]. (Semester - V)
COMPUTER SCIENCE
CS-3510 : Python Programming
(2019 Pattern) (CBCS)
Time : 2 Hours] [Max. Marks : 35
Instructions to the candidates:
1) Figures to the right indicate full marks.
2) All Questions are compulsory.
3) Total number of questions are FIVE.
Q1) Attempt any Eight of the following (Out of Ten). [8 × 1 = 8]
a) What are the advantages of Python?
b) List out main differences between lists & tuple.
c) Python is a scripting language. Comment.
d) Demonstrate set with example.
e) What is dictionary? Give example.
f) What is regEx? give example.
g) What is user defined Module? Give example.
h) Python is case sensitive language. Comment.
i) What is dry run in Python?
j) What is lambda function? Give example.
Q2) Attempt any four of the following (Out of Five). [4 × 2 = 8]
a) Write a python program to calculate XY.
b) Write a python program to accept a number and check whether it is
perfect number or not.
P.T.O.
c) What is the use of seek( ) & tell ( ) functions?
d) Demonstrate list slicing.
e) A tuple is ordered collection of items. Comment.
Q3) Attempt any Two of the following (Out of Three). [2 × 4 = 8]
a) Write a short note on datatypes in Python.
b) Write a short note on exception handling.
c) What is a module? What is package? Explain with example.
Q4) Attempt any Two of the following (Out of Three). [2 × 4 = 8]
a) Write a recursive function in Python to display addition of digits in
single digit.
b) Write a program in python to accept 'n' integers in a list, compute &
display addition of all squares of these integers.
c) Write a Python program to count all occurences of "India" and
"Country" in a text file "[Link]".
Q5) Attempt any One of the following (Out of Two). [1 × 3 = 3]
a) What is the output of following code :
X=5
def f1( ) :
global X
X=4
def f2(a, b) :
global X
return a+b+X
f1( )
total = f2(1, 2)
print (total)
[5902]-57 2
b) What is the output of following code :
def f(X) :
def f1(a, b) :
print ("hello")
if (b==0) :
print ("NO")
return
return f(a, b)
return f1
@f
def f(a, b) :
return a%b
f(4, 0)
[5902]-57 3
Total No. of Questions : 5] SEAT No. :
P5155 [Total No. of Pages : 2
[5823]-507
T.Y. [Link].
COMPUTER SCIENCE
CS-3510 : Python Programming
(2019 Pattern) (CBCS) (Semester - V)
Time : 2 Hours] [Max. Marks : 35
Instructions to the candidates:
1) All questions are compulsory.
2) Figures to the right indicate full marks.
3) Total number of questions are five.
Q1) Attempt any 8 of the following : [8 × 1 = 8]
a) What is dry run in Python?
b) Give the purpose of selection statements in Python.
c) List the types of type conversion in Python.
d) What is the use of pass statement?
e) Explain the function enumerate( ).
f) Explain the extend method of list.
g) What are required arguments in function?
h) Explain any 2 functions in time module.
i) What are the types of file in Python?
j) Write the use of seek & tell function.
Q2) Attempt any 4 of the following : [4 × 2 = 8]
a) How to handle exception in Python?
b) Explain any 2 metacharacters used in regular expression.
c) Explain any 2 built-in list functions.
d) Explain backward indexing in strings.
e) Define identifiers.
P.T.O.
Q3) Attempt any 2 of the following : [2 × 4 = 8]
a) Write a Python program to check if a given number is Armstrong.
b) Write a Python program to display power of 2 using anonymous
function.
c) Write a Python program to print even length words in a string.
Q4) Attempt any 2 of the following : [2 × 4 = 8]
a) Write a Python program to check for Zero Division Error Exception.
b) Write a Python program to find gcd of a number using recursion.
c) Write a Python program to check if a given key already exists in a
dictionary.
Q5) Attempt any 1 of the following : [1 × 3 = 3]
a) Trace the output of the following :
sum = 0
for i in range (12, 2, –2) :
sum + = i
print sum
b) Trace the output of the following :
count = 1
def doThis ( ) :
global count
for i in (1, 2, 3) :
count + = 1
doThis( )
[5823]-507 2
Total No. of Questions : 5] SEAT No. :
P6396 [Total No. of Pages : 3
[6155]-57
T.Y. [Link]. (Computer Science)
CS-3510 : PYTHON PROGRAMMING
(Revised 2019 Pattern) (CBCS) (Semester - V)
Time : 2 Hours] [Max. Marks : 35
Instructions to the candidates:
1) All questions are compulsory.
2) Figures to the right indicate full marks.
3) Total number of questions are five.
Q1) Attempt any Eight of the following: [8×1=8]
a) What is indentation?
b) Write code to print the elements of the list 11 = [10, 20, 30, 40, 50]
c) What is a slice operator?
d) What is variable-length argument?
e) How to add multiple elements at the end of the list?
f) Explain the remove () method.
g) Write a lambda function to add 10 to a given integer.
h) How to raise an exception with arguments.
i) List the methods of re package.
j) What is a wb mode in file?
Q2) Attempt any four of the following: [4×2=8]
a) What is a package? Explain with example how to create a package.
b) What are the usage of tuples zip (), tuple(), count() and index() functions?
[6155]-57 1 P.T.O.
c) What is an anonymous function? How to create it? Explain with example.
d) Explain the following loops with example.
i) While
ii) For
e) How to perform input output operations? Explain with example.
Q3) Attempt any Two of the following: [2×4=8]
a) Write a program to accept a string from user and display the string in
reverse order eliminating the letter ‘s’ from the string.
b) Write a program to raise a user defined exception to check if age is less
that 18.
c) Write a Python program to check that a string contains only a certain set
of characters (in this case a-z, A-Z and 0-9).
Q4) Attempt any Two of the following: [2×4=8]
a) Write a Python program to add ‘ing’ at the end of a given string (length
should be at least 3). If the given string already ends with 'ing', add 'ly'
instead. If the string length of the given string is less than 3, leave it
unchanged.
b) Write a Python program to combine values in a list of dictionaries. Sample
data: [{'item': 'item 1', 'amount': 400}, {'item': 'item2', 'amount': 300},
{'item': 'item1', 'amount': 750}]
Expected Output: Counter ({'item1': 1150, 'item2': 300})
c) Write a Python program to extract year, month, date and time using
Lambda.
[6155]-57 2
Q5) Attempt any one of the following: [1×3=3]
a) Check1 = ['Learn', 'Quiz', 'Practice', 'Contribute']
Check2 = check1
Check3 = check1 [:]
Check2[0] = 'Code'
Check3[1] = 'Mcq'
Count = 0
For c in (check 1, check2 check3):
if c[0] == 'Code':
count + = 1
if c[1] == 'Mcq':
count + = 10
print (count)
b) Counter = {}
Def add To Counter (Country):
If country in counter:
Counter [country] + = 1
Else:
Counter [country] = 1
Add To Counter ('China')
Add To Counter ('Japan')
Add To Counter ('china')
Print (len(counter))
[6155]-57 3