Printed Page: 1 of 2
Subject Code: KNC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2021-22
PYTHON PROGRAMMING
Time: 3 Hours Total Marks: 50
Note: Attempt all Sections. If you require any missing data, then choose suitably.
SECTION A
1. Attempt all questions in brief. 2*5 = 10
Qno Questions CO
(a) Explain the Programming Cycle for Python in detail. 1
(b) What will be the output of the following Python code? 2
i=0
while i< 3:
print(i)
i += 1
else:
print(0)
(c) What will be the output of the following Python code? 3
def cube(x):
return x * x * x
1
x = cube(3)
13
0
print x
29
(d) How do we define an Interface for an ADT? 4
2.
2_
24
(e) How do you perform a search in Python? 5
2P
5.
SECTION B
.5
P2
2. Attempt any three of the following: 5*3 = 15
17
Qno Questions CO
Q
|1
(a) What do you mean by Python IDE? Explain in detail. 1
(b) How can you randomize the items of a list in place in Python? 2
6
:3
(c) Explain Tuples and Unpacking Sequences in Python Data Structure. 3
25
(d) What are File input and output operations in Python Programming? 4
(e) Solve the Tower of Hanoi problem for n= 3 disk and show all the steps. 5
:
13
SECTION C
2
02
3. Attempt any one part of the following: 5*1 = 5
Qno Questions CO
-2
(a) Write a program in Python to execute the Selection sort algorithm. 5
ar
(b) Explain why python is considered an interpreted language. 1
M
2-
4. Attempt any one part of the following: 5 *1 = 5
|2
Qno Questions CO
(a) Write a Python program to construct the following pattern, using a 2
nested for loop.
*
**
***
****
*****
QP22P2_290 | 22-Mar-2022 13:25:36 | 117.55.242.131
Printed Page: 2 of 2
Subject Code: KNC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2021-22
PYTHON PROGRAMMING
****
***
**
*
(b) Write a program to produce Fibonacci series in Python. 4
5. Attempt any one part of the following: 5*1 = 5
Qno Questions CO
(a) Write a Python program to change a given string to a new string where 3
the first and last chars have been exchanged.
(b) Write a Python program to add an item in a tuple. 3
6. Attempt any one part of the following: 5*1 = 5
Qno Questions CO
(a) How to create and import a module in Python? 4
(b) Explain the algorithm Sieve of Eratosthene used in Python 4
Programming.
1
13
0
29
7. Attempt any one part of the following: 5*1 = 5
2.
2_
Qno Questions CO
24
(a) Write a Recursive function in python BinarySearch(Arr,l,R,X) to 5
2P
5.
search the given element X to be searched from the List Arr having R
.5
P2
elements, where l represent slower bound and R represents the upper
17
bound.
Q
|1
(b) Explain the terms Merge List and Merge Sort in Python Programming. 5
6
:3
: 25
13
2
02
-2
ar
M
2-
|2
QP22P2_290 | 22-Mar-2022 13:25:36 | 117.55.242.131