This question paper contains 7 printed pages
Roll No.
S. No. of Question Paper 1367
Unique Paper Code 62347502
Name of the Paper Programmingwith Python
Name of the Course B.A. (Programme) Computer
Application : DSE-1
Semester
Duration :3 Hours Maximum Marks: 75
(Write your Roll No. on the top immediately on receipt of this question pajper.)
Question No. 1 is compulsory.
Attempt any 5 of Question Nos. 2 to 8.
Parts of a question must be answered together.
. (a) Which of the following is an invalid name ?
)my
my_string_1
(in) 2nd_string
(iii) foo
(iv) init
() in
(vi) it
(b Which of the following is an invalid statement ?
() abe =1,000,000
(1)a b c = 1000 2000 3000
(iii) a,b, c = 1000, 2000, 3000
(iv) a_b_c = 1,000,000
P.T.O
1457
WhAl lp follawin
into a or
uhile loop
ranslate the ollowiny
()
loop
foriinrange(sn(i)1 20
''
prinl )
while (1> 0):
print "1 = " ,
whils '"'rue statements2
(if any) in the given
f 007 0 ) ectify the error
Break
rlnt1) > s t r = "Hello Python"
t r [6|= "g"
search used ? Give
de foe(k) (#) Under what conditions is binary
k011
Given
the outline of binary search algorithm.
oo(q)
prlnt () testlist-[0, 1,2,8,13, 17,19,32, 42),
( What ia the otput of the tollowlng Python e Ilutsrato the operation of the binary search algorithm
ngmet " Justity your answer to search for the number 13.
( weekdays -
2 What the output of the following code segments ? 10
Taun', 'mon', 'tue', 'wed', 'thu',
'frl','Bun', 'mon' mon'
() alasa teat:
Plnt (weekdaya.,count ('mon')) def init(selt,a-"Hello World")
elt.a=a
weekdays def display (selt):
T'aun', 'mon', 'tue', 'wed', 'thu','trl' print (s0lf.a)
'sun', 'mon', "mon'| obJ=test ()
for *
PT'nt | 8 ,weekdays,count (x) obj.diaplay()
aet (weekdaya) |)
P.TO
4 1367
5
1367 list Functions
following
class test: What will be the output ofthe applying the 10
4. ?
def below
init_(self, a) : on list given
self.a=a 2, 4, 3]
L1=[1, 3, 2, 12,
L.append (10)
def display (self): L.count (2)
print (self.a) L.index (12)
obj=test () L.insert (2, 15)
obj.display() L.remove (2)
(ii) def power (x, y=2) function to compute the following series
Write a
5. (a)
for i in range ( y):
X
Sum-1+1/2+1/3-+.. .+1/n
return r
print power (3) 3
Evaluate the following expressions
print power (3, 3)
7*20+8/16*2+54
()
(v) X 2
(i) 5810+10-25*8//5
for i in range (x) :
x- 2 and 29>=29/9
ii) 10+6*2**2! =9//4-3
print (x)
What will be the output of the following code
(v)i 0 (c)
while i < 3: segment?
print (ii) for l e t t e r in 'geeks forgee ks' :
i + 1 i f letter == 'e' or letter ==
's'
else: continue
'Current Letter :', l e t t e r
print (0) print
code segments: 5
3 (a)) For the given array arr = (1,2,4,3], appiy 6. () Write the output of the following
bubble sort algorithm to sort the array elements and
also show. the modified list after each iteration. for l e t t e r in 'geeksforgeeks':
'e' or letter 's':
if letter ==
(b) What is a queue? Write a Python code to create an empy break
Letter :', letter
print 'Current
queue. Initialize front and rear suitably. 5 .
1367
6
following python code
Wrine output of the
def myfunc (a) :
2
a
return a GeeksforGeeks"
z = "ielcome to
print ayfunc (2 print z [2:5]
Write apython fanction to fnd the surn of all print z[4:10:2
mumiers provided by the s e r as the
print z[-5:-3
input.
Dilerentie between ype comverTsion and type
coercion i = 0
w e heio af an example (i)
while i < 5:
What wilbe he otpu the fiollowing code ?
print (i)
i +
def f(z, L=[1) : if i == 3:
for i in range (z): break
1.apperd (i*i) else:
print (1 print (0)
(2)
(3,[3,2,11)
(3
riRe te onpa of the folkouing python cde 5
Lis =
11, 2, 31
is1 [4, 5, 61
21 1is + 1ie1
pEint('1i3t after oncatenation is')
for i in
range (G,ler (1is2))
pint (1is2[i)),
pEint("ir")
Lis 1is
print ('1ist after conbining is') 1367 800
for in
tange(0,1en (1is3) i:
print (1i53[),