You are on page 1of 8

Total No. of Questions : 5] SEAT No.

38
P-1306 [Total No. of Pages : 3

ic-
tat
[6055]-307

2s
T.Y.B.Sc.

5:1
31 1
1
0:3
COMPUTER SCIENCE

6/2 02
CS-3510: Python Programming
1
02
8 2 P0

(2019 Pattern) (CBCS) (Semester - V)


A
2/0
8.7 CA

Time : 2 Hours] [Max. Marks : 35

38
Instructions to the candidates :
7.3

ic-
1) All questions are compulsory.

tat
2) Figures to the right indicate full marks.

2s
.24

3) Total number of questions are five.

5:1
49

11
0:3
02

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


31
01
02

a) How are comments written in Python?


6/2
AP

b) Give the use of index() in string.


2/0
CA
82

c) Explain the range() function and its parameters.

38
7.3

-
d) How to create a void function in Python? tic
8.7

sta
.24

e) What is the difference between pop() and del in list.


:12
49

11
:35

f) Compare list and tuple (any two points).


02
10

g) What does the following functions return - clock() and gmtime().


23
1
8 2 P0
/20

h) List the syntax for handling exception.


06
A
2/
CA

i) List any two functions in math module.


7.3

j) Explain the function enumerate().


8.7
.24

P.T.O.
49
Q2) Attempt any Four of the following: [4 × 2 = 8]

38
a) Which methods are used to read from a file? Explain any two with example.

ic-
b) What are the usage of dictionary copy(), gets(), items() and keys()

tat
methods?

2s
c) Explain union and intersection with example.

5:1
31 1
d) Explain the following statement

1
0:3
6/2 02
i) if b) if else c) break d) continue
e)
1
List features of Python.
02
8 2 P0
A

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


2/0
8.7 CA

a) Write a program to get a single string from two given strings, separated

38
by space and swap the first two characters of each string
7.3

ic-
Sample input: ‘abc’, ‘pqr’

tat
Output: pqc abr

2s
.24

b) Write a program to display power of 2 upto a given number using


5:1
49

11
anonymous function
0:3
02

Example
31
01

N=2
02

2 raised to 0 is 1
6/2
AP
2/0

2 raised to 1 is 2
CA
82

2 raised to 2 is 4

38
7.3

c) Write a program to read an entire text file.


-
tic
8.7

sta
.24

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


:12
49

a) Write a python program to Count Vowels and Consonants in a String.


11
:35

b) Write a Python script to print a dictionary where the keys are numbers
02
10

between 1 and 15 (both included) and the values are the square of the
23
1

keys.
8 2 P0
/20

Sample Dictionary
06
A

{1: 1, 2:4, 3:9, 4: 16, 5:25, 6:36, 7:49, 8:64, 9:81, 10: 100, 11: 121, 12: 144,
2/
CA

13: 169, 14: 196, 15: 225}


c) Write a Python function that accepts a string and counts the number of
7.3

upper and lower case letters.


8.7
.24
49

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

38
a)

ic-
a = True

tat
b = False

2s
5:1
c = False

31 1
1
0:3
if not a or b:

6/2 02
print (1)
1
02
8 2 P0
elif not a or not b and c:
print (2)
A
2/0
8.7 CA

elif not a or b or not b and a:

38
print (3)
7.3

ic-
else:

tat
2s
.24

print (4)

5:1
49

b) def f 1(x, 1=[ ]):


11
0:3
for i in range(x):
02
31

1.append(i*i)
01
02

print(1)
6/2
AP

f1 (2)
2/0
CA

f1 (3,[3,2,1])
82

38
f1 (3)
7.3

-
tic
8.7

sta


.24

:12
49

11
:35
02
10
23
1
8 2 P0
/20
06
A
2/
CA
7.3
8.7
.24
49

[6055]-307 3
Total No. of Questions : 5] SEAT No. :

P5155 [Total No. of Pages : 2


[5823]-507
T.Y. B.Sc.
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. B.Sc. (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 "pledge.txt".

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

You might also like