0% found this document useful (0 votes)
10 views17 pages

Python PYQ

This document contains examination questions for a T.Y. B.Sc. Computer Science course on Python Programming. It includes a total of five questions with varying marks, covering topics such as Python syntax, functions, exception handling, and program writing. Students are instructed to attempt a specified number of questions from each section.

Uploaded by

pawarsatyam501
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)
10 views17 pages

Python PYQ

This document contains examination questions for a T.Y. B.Sc. Computer Science course on Python Programming. It includes a total of five questions with varying marks, covering topics such as Python syntax, functions, exception handling, and program writing. Students are instructed to attempt a specified number of questions from each section.

Uploaded by

pawarsatyam501
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

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

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

38
P6396 [Total No. of Pages : 3

ic-
[6155]-57

tat
T.Y. [Link]. (Computer Science)

8s
CS-3510 : PYTHON PROGRAMMING

7:1
30 1
(Revised 2019 Pattern) (CBCS) (Semester - V)

1
9:1
2/2 02
Time : 2 Hours] [Max. Marks : 35
1
Instructions to the candidates:
02
8 1 P0
1) All questions are compulsory.
2) Figures to the right indicate full marks.
A
9/1

3) Total number of questions are five.


8.7 CA

38
7.3

ic-
tat
Q1) Attempt any Eight of the following: [8×1=8]

8s
.24

7:1
a) What is indentation?
49

11
9:1
b) Write code to print the elements of the list 11 = [10, 20, 30, 40, 50]
02
30
01

c) What is a slice operator?


02
2/2
AP

d) What is variable-length argument?


9/1
CA

e) How to add multiple elements at the end of the list?


81

38
7.3

f) Explain the remove () method.


-
tic
8.7

sta
g) Write a lambda function to add 10 to a given integer.
.24

:18

h) How to raise an exception with arguments.


49

11
:17

i) List the methods of re package.


02
09
23
1

j) What is a wb mode in file?


8 1 P0
/20
12
A
9/
CA

Q2) Attempt any four of the following: [4×2=8]


7.3

a) What is a package? Explain with example how to create a package.


8.7

b) What are the usage of tuples zip (), tuple(), count() and index() functions?
.24
49

[6155]-57 1 P.T.O.
c) What is an anonymous function? How to create it? Explain with example.

38
d) Explain the following loops with example.

ic-
tat
i) While

8s
ii) For

7:1
30 1
1
e) How to perform input output operations? Explain with example.

9:1
2/2 02
1
02
8 1 P0

Q3) Attempt any Two of the following: [2×4=8]


A
9/1
8.7 CA

a) Write a program to accept a string from user and display the string in

38
reverse order eliminating the letter ‘s’ from the string.
7.3

ic-
tat
b) Write a program to raise a user defined exception to check if age is less

8s
.24

that 18.

7:1
49

11
c) Write a Python program to check that a string contains only a certain set
9:1
02

of characters (in this case a-z, A-Z and 0-9).


30
01
02
2/2
AP

Q4) Attempt any Two of the following: [2×4=8]


9/1
CA

a) Write a Python program to add ‘ing’ at the end of a given string (length
81

38
should be at least 3). If the given string already ends with 'ing', add 'ly'
7.3

-
instead. If the string length of the given string is less than 3, leave it
tic
8.7

sta
unchanged.
.24

:18

b) Write a Python program to combine values in a list of dictionaries. Sample


49

11
:17

data: [{'item': 'item 1', 'amount': 400}, {'item': 'item2', 'amount': 300},
02
09

{'item': 'item1', 'amount': 750}]


23
1

Expected Output: Counter ({'item1': 1150, 'item2': 300})


8 1 P0
/20
12
A

c) Write a Python program to extract year, month, date and time using
9/
CA

Lambda.
7.3
8.7
.24
49

[6155]-57 2
Q5) Attempt any one of the following: [1×3=3]

38
a) Check1 = ['Learn', 'Quiz', 'Practice', 'Contribute']

ic-
Check2 = check1

tat
8s
Check3 = check1 [:]

7:1
30 1
Check2[0] = 'Code'

1
9:1
2/2 02
Check3[1] = 'Mcq'
1
02
Count = 0
8 1 P0

For c in (check 1, check2 check3):


A
9/1
8.7 CA

if c[0] == 'Code':

38
count + = 1
7.3

ic-
if c[1] == 'Mcq':

tat
8s
.24

count + = 10
7:1
49

11
print (count)
9:1
02

b) Counter = {}
30
01
02

Def add To Counter (Country):


2/2
AP

If country in counter:
9/1
CA

Counter [country] + = 1
81

38
Else:
7.3

-
tic
8.7

Counter [country] = 1
sta
.24

Add To Counter ('China')


:18
49

11
:17

Add To Counter ('Japan')


02
09

Add To Counter ('china')


23
1

Print (len(counter))
8 1 P0
/20
12
A
9/
CA


7.3
8.7
.24
49

[6155]-57 3
Total No. of Questions : 5] SEAT No. :

82
PB1889 [Total No. of Pages : 2

ic-
[6237]-507

t
sta
T.Y. [Link].
COMPUTER SCIENCE

3
6:1
CS-3510 : Python Programming

1
3:3
4/2 21
(Revised 2019 Pattern) (CBCS) (Semester - V)

41
Time : 2 Hours] 0/0 10 [Max. Marks : 35

02
Instructions to the candidates:
0
9.8 AP

1) All questions are compulsory.


2) Figures to the right indicate full marks.
3) Total number of questions are five.
49 CA

23

82
ic-
Q1) Attempt any Eight of the following. [8×1=8]
.21

tat
3s
a) What in indentation?
2.1

6:1
b) List the features of Python?
11
20

3:3
c) What are break and continue statements?
02
41

d) List any two built-in exceptions?


02
01
4/2

e) What is the purpose of range ( ) function?


AP
0/0

f) What does the following function return - clock ( ) and gmtime ( ).


CA
23

-82
g) Compare for and while loop.
9.8

h) Define text and binary files. tic


.21

sta
49

i) Define list and dictionary.


:13
2.1

j) What is lambda function?


:36
11
20

13
02
24

Q2) Attempt any four of the following. [4×2=8]


01
/20

a) Explain built-in string methods with example.


9.8 AP
/04

b) How to list files and directories? Describe with example.


0
CA
23

c) Explain set union and intersection with example.


.21

d) What is recorsion? Explain with example.


49

e) What are the basic tuple operations? Explain with example.


2.1
20

[6237]-507 1 P.T.O.
Q3) Attempt any two of the following. [2×4=8]

82
a) Write a phython program to find factorial of a number.

ic-
b) Write a python program to check if a given number is Armstrong.

t
sta
c) Write a python program to check whether a given string is Palindrome or

3
not.

6:1
1
3:3
4/2 21
Q4) Attempt any two of the following. [2×4=8]

41
0/0 10
a) Write a python program to check if a given key already exists in a

02
dictionary.
0
9.8 AP

b) Write a python program to put even and odd elements of a list into two
different lists.
49 CA

23

c) Write a python program to count vowels and consonants in a string.

82
ic-
.21

tat
Q5) Attempt any one of the following. [1×3=3]

3s
a) Trace the output of the following
2.1

6:1
import tracebook
11
20

try:
3:3
02
41

x =8/0
02
01

print(x)
4/2

except:
AP
0/0

print (“error update”)


CA
23

traceback print-exc ( )

-82
9.8

Print (“Program Execution Successful”)


tic
.21

b) Trace the output of the following


sta
n = 50
49

:13
2.1

i=5
:36
11
20

s=0
13
02

while i < n :
24

st = i
01
/20

i + = 10
9.8 AP
/04

Print (“ i =” , i)
0

Print (“Sum = “, Sum)


CA
23
.21

  
49
2.1
20

[6237]-507 2
Total No. of Questions : 5] SEAT No. :

82
PC1585 [6328]-57 [Total No. of Pages : 2

ic-
[Link]. (C.S.)

t
sta
CS - 3510 : PYTHON PROGRAMMING

4
(Revised 2019 Pattern) (Semester-V)

1:4
1
3:2
Time : 2 Hours] [Max. Marks : 35

2/2 21
Instructions to the candidates:

41
3/1 10
1) All questions are compulsory.

02
2) Figures to the right indicate full marks.
0
9.8 AP

Q1) Attempt any Eight of the following : [8×1=8]


49 CA

20

82
a) Explain features of python.

ic-
b) What is purpose of range ( ) function.
.21

tat
4s
c) What is indentation.
2.1

1:4
d) Define anonymous function.
11
20

3:2
e) Compare List and dictionary.
02
41

f) Define text and binary files.


02
01
2/2

g) What is lamda function.


AP
3/1

h) Explain Exception with syntax.


CA
20

2
i) Compare for and while loop?

c-8
9.8

i
.21

j) What is regular Expression.


tat
4s
49
2.1

1:4

Q2) Attempt any Four of the following : [4×2=8]


11
20

3:2
02

a) What is package? How to create it? Explain with example.


41
02
01

b) Explain built in string methods with example.


2/2
AP

c) Explain following Statements.


3/1

i) If ii) If else
CA
20

iii) break iv) Continue


9.8
.21

d) What is difference between call by value and call by reference.


49

e) Explain set union and intersection with example.


2.1
20

[6328]-57 1 P.T.O.
Q3) Attempt any Two of the following : [2×4=8]

82
a) Write a python program to find sum of natural numbers.

t ic-
sta
b) Write a python function to check whether a number is perfect or not.

4
c) Write a python program to convert a list to a tuple.

1:4
1
3:2
2/2 21
41
3/1 10
Q4) Attempt any Two of the following : [2×4=8]

02
0
a) Write python program to accept the strings which contains all vowels.
9.8 AP

b) Write a python program to computer the number of characters, words


49 CA

20

and lines in file.

82
c) Write a python program to check number is odd or even.

ic-
.21

tat
4s
2.1

1:4
Q5) Attempt any One of the following : [1×3=3]
11
20

3:2
a) def myfun(name, msg = “Good morning”) :
02
41

print(“Hello”, name + ‘,’ + msg)


02
01
2/2

myfun(“Amar”)
AP
3/1

myfun(“Kiran”, “How do you do”)


CA
20

2
b) try :

c-8
9.8

i
.21

a=5 tat
4s
49

b=0
2.1

1:4
11

print(a|b)
20

3:2
02

except Type Error :


41
02
01

Print(‘unsupported operation’)
2/2
AP

except zero division Error;


3/1
CA
20

print(‘Division by Zero not allowed’)


9.8

print(‘out of try except blocks’)


.21


49
2.1
20

[6328]-57 2
Total No. of Questions : 5] SEAT No. :

82
PD1577 [Total No. of Pages : 2

ic-
[6468]-57

t
sta
[Link]. (Computer Science)

5
1:1
CS-3510 : PYTHON PROGRAMMING

1
3:3
(Revised 2019 Pattern) (Semester -V)

4/2 21
51
Time : 2 Hours] [Max. Marks : 35
9/0 10
Instructions to the candidates:

02
1) All questions are compulsory.
0
9.8 AP

2) Figure to the fight indicate full marks.


49 CA

21

82
Q1) Attempt any Eight of the following (out of Ten) [8×1=8]

ic-
.21

tat
a) What is the purpose of range ( ) function?

5s
b) What is a list? Explain with suitable example.
2.1

1:1
11
20

c) What is copysing ( ) function? 3:3


02
51

d) How are tuples created?


02
01

e) What is a uniform ( ) method?


4/2
AP

f) How to create a package?


9/0
CA
21

g) What is a ‘wb’ mode in file?

-82
9.8

h) What is the use of finally block?


tic
.21

sta
i) Give the use of index ( ) method of string.
49

:15

j) Python is a scripting language comment.


2.1

:31
11
20

13
02

Q2) Attempt any four of the following (out of five) [4×2=8]


25
01
/20

a) Explain the filter function with example


9.8 AP
/04

b) Explain any two list methods with example


9
CA
21

c) Explain any two basic string methods.


d) Explain the concept of slicing with suitable example
.21

e) What are modules? Explain with example how to import modules.


49
2.1
20

P.T.O.
P.T.O.
Q3) Attempt any two of the following (out of Three) [2×4=8]

82
a) Which methods are used to read from file? Explain any two of them with

ic-
example.

t
sta
b) Write a python program to check if a given string as palindrome or not.

5
c) Write a program to find GCD of number using recursion.

1:1
1
3:3
4/2 21
Q4) Attempt any two of the following (out of Three) [2×4=8]

51
9/0 10
a) List the various methods of re package explain any two methods in detail

02
with example.
0
9.8 AP

b) Write a python program to find sum of digits of a number (Accept number


from user)
49 CA

21

82
c) Write a python program to append the contents of file 2 to file 1. Acept

ic-
file names from user
.21

tat
5s
Q5) Attempt any one of the following (one of two) [1×3=3]
2.1

1:1
a) What will be the output of the following code
11
20

3:3
r = lambda q : q*2
02
51

s= lambda q : q*3
02
01

x=2
4/2
AP

x = r(x)
9/0

x = s(x)
CA
21

x = r(x)

-82
9.8

print (x)
tic
.21

b) What will be the output of the following.


sta
49

code
:15
2.1

count = 1
:31
11
20

13

def do This ( ) :
02
25

global count
01
/20

for i in (1 , 2, 3)
9.8 AP
/04

Count + =1
9
CA
21

do This ( )
print (Count)
.21
49


2.1
20

[6468]-57 2

You might also like