0% found this document useful (0 votes)
18 views9 pages

Python Programming Exam Questions

The document is an examination paper for T.Y. B.Sc. Computer Science on Python Programming, consisting of five questions with varying marks. It includes instructions for candidates and covers topics such as Python features, built-in functions, and programming exercises. The paper is structured to assess both theoretical knowledge and practical programming skills.
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)
18 views9 pages

Python Programming Exam Questions

The document is an examination paper for T.Y. B.Sc. Computer Science on Python Programming, consisting of five questions with varying marks. It includes instructions for candidates and covers topics such as Python features, built-in functions, and programming exercises. The paper is structured to assess both theoretical knowledge and practical programming skills.
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.

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

-82
i) Compare for and while loop?
9.8

tic
.21

j) What is regular Expression.


sta
49

:44
2.1

:21

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


11
20

13
02

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


24
01

b) Explain built in string methods with example.


/20
9.8 AP

c) Explain following Statements.


3 /12

i) If ii) If else
CA
20

iii) break iv) Continue


.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

-82
b) try :
9.8

tic
.21

a=5
sta
49

b=0
:44
2.1

:21
11

print(a|b)
20

13
02

except Type Error :


24
01

Print(‘unsupported operation’)
/20
9.8 AP
/12

except zero division Error;


3
CA
20

print(‘Division by Zero not allowed’)


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

You might also like