TYBSC (CS) - 3510 Python Programming
TYBSC (CS) - 3510 Python Programming
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
38
Instructions to the candidates :
7.3
ic-
1) All questions are compulsory.
tat
2) Figures to the right indicate full marks.
2s
.24
5:1
49
11
0:3
02
38
7.3
-
d) How to create a void function in Python? tic
8.7
sta
.24
11
:35
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
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
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
sta
.24
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
[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
38
print (3)
7.3
ic-
else:
tat
2s
.24
print (4)
5:1
49
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