B.Tech Python Programming Exam Paper
B.Tech Python Programming Exam Paper
[Link].
(SEM IV) THEORY EXAMINATION 2022-23
PYTHON PROGRAMMING
Note: Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
2
defprintalpha (abc_list, num_list):
13
for char in abc_list:
_2
2.
for num in num_list:
P2
24
print(char, num)
return
3E
5.
printalpha (['a', 'b', 'c'], [1, 2, 3])
.5
P2
|1
i. Compare assert, try-except and raise statements.
j. Write python function to perform linear search.
0
:3
: 24
13
SECTION B
3
02
a. Write Python code snippet to display n terms of Fibonacci series using recursion.
1-
b. Write and explain an algorithm through python code to generate prime numbers.
|0
c. Compare list and tuple data structure with suitable examples. Explain the concept
of list comprehension.
d. Explain the python implementation of stack ADT.
e. Describe python program to implement selection sort. Simulate your code on the
following data
2,52,1,5,2,54,62,64.
i) a &b<<2//5**2+c^b
ii) b>>a**2<<2 >> b**2^c**3
2
HELLO WORLD
13
_2
PRACTICE MAKES PERFECT
2.
P2
24
5. Attempt any one part of the following: 10x1=10
3E
5.
.5
P2
a. Discuss list data structure of python. Explain various inbuilt methods of list with
suitable example of each.
17
Q
b. Compare list and dictionary data structure. Explain various dictionary methods
|1
with suitable examples of each.
0
:3
a. Discuss the concept of Iterators in python. Explain, how we can create text file
13
in python? Describe python program to write the number of letters and digits in
given input string into a File object.
3
02
suitable example.
08
1-
a. Explain the Tower of Hanoi problem and its recursive solution in Python.
b. Write python program to implement merge sort algorithm. Discuss, how we can
compare the time complexity of two algorithms?
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM IV) THEORY EXAMINATION 2024-25
PYTHON PROGRAMMING
TIME: 3 HRS [Link]: 70
Note: Attempt all Sections. In case of any missing data; choose suitably.
SECTION A
4
13
e. 90
Write a Python program to demonstrate type casting between int, float, and string. 1 K2
int, float और string के बीच टाइप का ं ग िदखाने वाला एक पाइथन ो ाम िल खए।
2.
_2
f. Explain the use of if, else, and elif. Write a Python program tocheckthe given 2 K1,
24
P1
5.
5E
.5
g. Differentiate between for loop and while loop with syntax and examples. 2 K1,
17
P2
SECTION B
PM
Q Question CO Level
:1
no.
36
a. What are break, continue, and pass statements? Give code examples. 2 K2
break, continue, और pass े टमट् स ा ह? कोड उदाहरण दीिजए।
1:
b. Write a Python program using for loop and dictionary to display student grades. 2 K2
एक पाइथन ो ाम िल खए जो for लूप और िड नरी का उपयोग करके छा के े ड
5
02
िदखाए।
c. Discuss the use of nested loops in Python. Write a program to print a right-angled 2 K3
-2
triangle of stars.
ul
1|Page
QP25EP1_290 | 09-Jul-2025 1:36:11 PM | [Link]
Printed Page: 2 of 3
Subject Code: BCC402
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM IV) THEORY EXAMINATION 2024-25
PYTHON PROGRAMMING
TIME: 3 HRS [Link]: 70
SECTION C
3. Attempt any one part of the following: 07 x 1 = 07
Q Question CO Level
no.
a. Write a program to demonstrateCreate, Read, Update, and Delete(CRUD) 3 K2,
operations on a dictionary. K3
िड नरीपर Create, Read, Update, and Delete (CRUD) ऑपरे श दशाने वाला एक
ो ाम िल खए।
b. Explain commonly used string methods in Python. Write a program using K2,
the following operations on the given string: K4
text = " Machine Learning "
Use the following methods
lower()
upper()
4
strip()
13
90
replace()
2.
_2
find()
24
count()
P1
5.
5E
.5
text = " Machine Learning "
17
P2
िन मेथड् स का उपयोगकर: |1
Q
lower()
upper()
PM
strip()
replace()
1
find()
:1
count()
36
Q Question CO Level
no.
5
a. How can data be organized using complex data types in Python? 3 K2,
02
सकताहै ?
ul
2|Page
QP25EP1_290 | 09-Jul-2025 1:36:11 PM | [Link]
Printed Page: 3 of 3
Subject Code: BCC402
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM IV) THEORY EXAMINATION 2024-25
PYTHON PROGRAMMING
TIME: 3 HRS [Link]: 70
4
Matplotlib का डे टा िवज़ुअलाइज़ेशन म उपयोग समझाइए। नीचे िदए गए डे टा का
13
90
उपयोग करते ए एक लाइन ॉट दिशत करने का ो ाम िल खए।
2.
िदयागयाडे टा:
_2
x = [1, 2, 3, 4, 5]
24
P1
5.
7. Attempt any one part of the following: 07 x 1 = 07
5E
.5
Q Question CO Level
17
P2
no.
a. What is GUI programming in Python? Write a GUI-based Python 5 |1 K2,K4
Q
ो ाम िल खए जो छा की जानकारी ले और दिशतकरे ।
b. How do we use packages in Python programming? Explain the use of 5 K2,K4
1
:1
pandas.
Python ो ािमंग म पैकेज का उपयोग कैसे िकया जाताहै ? Pandas के उपयोग को
36
समझाइए।
1:
5
02
-2
J ul
9-
|0
3|Page
QP25EP1_290 | 09-Jul-2025 1:36:11 PM | [Link]
Printed Page: 1 of 3
Subject Code: BCC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3HRS [Link]: 70
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
2
x = [‘12’, ’hello’, 456]
13
_2
x[0] *= 3
2.
x[1][1]=’bye’
P2
24
g. Describe about different functions of matplotlib and pandas. 2
4D
5.
SECTION B
.5
P2
examples
b. Illustrate different list slicing constructs for the following operations on the 7
3 0
following list:
0:
L = [1, 2, 3, 4, 5, 6, 7, 8, 9]
:2
1. Return a list of numbers starting from the last to second item of the list
13
2. Return a list that start from 3rd item to second last item.
3. Return a list that has only even position elements of list L to list M.
4
5. Return a list that reverses all the elements starting from element at index
-2
Divide each element of the list by 2 and replace it with the remainder.
c. Construct a function perfect_square(number) that returns a number if it is a perfect 7
2-
For example:
perfect_square(1) returns 1
perfect_square (2) returns -1
d. Construct a program to change the contents of the file by reversing each character 7
separated by comma:
Hello!!
Output
H,e,l,l,o,!,!
e. Construct a plot for following dataset using matplotlib : 7
1|Page
QP24DP2_290 | 12-03-2024 13:20:30 | [Link]
Printed Page: 2 of 3
Subject Code: BCC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3HRS [Link]: 70
2
3. Attempt any one part of the following:
13
_2
2.
integer n>=0 and removes a character at index n. If n is beyond the length of s,
P2
24
then whole s is returned. For example:
4D
5.
removenth(“MANGO”,1) returns MNGO
removenth(“MANGO”,3) returns MANO
.5
P2
17
Q
a. A website requires the users to input username and password to register. Construct 7
a program to check the validity of password input by users.
-2
2|Page
QP24DP2_290 | 12-03-2024 13:20:30 | [Link]
Printed Page: 3 of 3
Subject Code: BCC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3HRS [Link]: 70
a. Construct a function ret smaller(l) that returns smallest list from a nested list. If 7
two lists have same length then return the first list that is encountered. For
example:
ret smaller([ [ -2, -1, 0, 0.12, 1, 2], [3, 4, 5], [6 , 7, 8, 9, 10], [11, 12, 13, 14, 15]])
returns [3,4,5]
ret smaller([ [ -2, -1, 0, 0.12, 1, 2], [‘a’, ’b’, ’c’, ’d’, 3, 4, 5], [6 , 7, 8, 9, 10], [11,
12, 13, 14, 15]]) returns [6 , 7, 8, 9, 10]
b. Construct following filters: 7
1. Filter all the numbers
2. Filter all the strings starting with a vowel
3. Filter all the strings that contains any of the following noun: Agra,
Ramesh, Tomato, Patna.
Create a program that implements these filters to clean the text.
6. Attempt any one part of the following:
a. Change all the numbers in the file to text. Construct a program for the same. 7
90
2
Example:
13
_2
Given 2 integer numbers, return their product only if the product is equal to or lower
2.
than 10.
P2
24
And the result should be:
4D
Given two integer numbers, return their product only if the product is equal to or
5.
lower than one zero
.5
P2
|1
an array. Save the last column to another array. Plot the first two columns.
0:
b. Design a calculator with the following buttons and functionalities like addition, 7
:2
3|Page
QP24DP2_290 | 12-03-2024 13:20:30 | [Link]
Printed Page: 1 of 4
Subject Code: BCC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2024-25
PYTHON PROGRAMMING
TIME: 3 HRS [Link]: 70
Note: Attempt all Sections. In case of any missing data; choose suitably.
SECTION A
1. Attempt all questions in brief. 2 x 07 = 14
Q no. Question CO Level
a. State how to handle exceptions in Python? Provide a simple example. 4 K1
पायथन म अपवादोंको कैसेसं भाल? एक सरल उदाहरण द।
b. What will be the output of the following Python code? 2 K3
def compute(x):
return [i**2 for i in x if i%2==0]
print(compute([1, 2, 3, 4, 5]))
िन िल खत पायथन कोड का आउटपुट #ा होगा?
def compute(x):
return [i**2 for i in x if i%2==0]
print(compute([1, 2, 3, 4, 5]))
c. Explain floor division with an example 2 K2
4
उदाहरण केसाथ मं िज़ल िवभाजन (floor division) समझाएँ ।
13
90
d. Describe the purpose of the ‘with’ statement in file handling? 4 K2
2.
फ़ाइलोंका +बं धन (फाइल ह/डिलं ग) म 'with' कथन केउ0े1 का वण2न कर।
_2
24
e. Briefly describe the use of lambda functions in Python. 3 K2
P2
5.
5D
.5
f. Demonstrate how to assign a single value to a tuple. 1 K3
टपल (tuple) को एकलमान कैसे असाइन कर, इसे+दिश2त कर।
17
P2
calculations?
गणना9क गणनाओंके िलए numpy का उपयोग #ोंिकया जाता है , इसे
PM
समझाएँ ?
40
SECTION B
2:
multiplication, division.
02
Given:
1-
a=3
|2
b=3
Distinguish between: (a is b) and (a = = b) ?
सद=ता और पहचान ऑपरे टर (Membership and Identity Operators)
पAरभािषतकर।
िदया गया:
a=3
b=3
(a is b) और (a == b) केबीचअं तरDEकर।
1|Page
QP25DP2_290 | 21-Mar-2025 1:32:40 PM | [Link]
Printed Page: 2 of 4
Subject Code: BCC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2024-25
PYTHON PROGRAMMING
TIME: 3 HRS [Link]: 70
4
13
C++ 20
90
JavaScript 15
2.
_2
Ruby 10
24
P2
5.
matplotlib का उपयोग करकेिन िल खत डे
टा का +ितिनिधP करनेकेिलए
5D
.5
एक पाई चाट2 बनाएं:
भाषाएँ लोकि+यता 17
P2
|1
पायथन 30
Q
जावा 25
PM
C++ 20
जावा RS 15
40
Tबी 10
2:
SECTION C
3
1:
a) Operator Precedence
ar
b) Python Indentation
c) Type Conversion
M
2|Page
QP25DP2_290 | 21-Mar-2025 1:32:40 PM | [Link]
Printed Page: 3 of 4
Subject Code: BCC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM III) THEORY EXAMINATION 2024-25
PYTHON PROGRAMMING
TIME: 3 HRS [Link]: 70
4
नीचेिदया गया खोखला िपरािमड पैटन2 बनानेकेिलए एक +ोLाम िलख:
13
90
*
2.
_2
**
24
* *
P2
5.
* *
5D
.5
*********
17
P2
b. Explain the why loops are needed and the types of loops in python. 2 K2
|1
Q
'banana'।
M
BTECH
(SEM III) THEORY EXAMINATION 2024-25
PYTHON PROGRAMMING
TIME: 3 HRS [Link]: 70
b. Write a program to read a CSV file and display the rows where a 4 K4
specific column value exceeds a given threshold.
एक +ोLाम िलख जोए क CSV फ़ाइल को पढ़े औरउन पंVयोंको +दिश2त करे
जहाँ एक िवशे ष कॉलम मान एक िनधा2Aरत सीमा सेअिधकहै ।
4
अंक की गणना करे औरपAरणाम +दिश2त करे ।
13
90
2.
_2
24
P2
5.
5D
.5
17
P2
|1
Q
PM
40
3 2:
1:
5
02
-2
ar
M
1-
|2
4|Page
QP25DP2_290 | 21-Mar-2025 1:32:40 PM | [Link]
Printed Pages: 02 Sub Code:KNC-302
[Link].
(SEM III) THEORY EXAMINATION 2022-23
PYTHON PROGRAMMING
Time: 3 Hours Total Marks: 50
Note: Attempt all Sections. If you require any missing data, then choose suitably.
SECTION A
2
90
13
(h) What is object-oriented programming (OOP) in Python? Give an example.
_2
2.
P2
24
def count1(s):
5.
3D
vowels = "AEIOUaeiou"
count = 0
.5
P2
for c in s:
if c in vowels: 17
Q
|1
count += 1
return count
9
print("@".join(list1))
3
02
SECTION B
-2
(a) Demonstrate five different built in functions used in the string. Write a
1-
(b) Explain the following loops with a flow diagram, syntax, and suitable
examples.
I) For II) while
(c) Explain the continue, break, and pass statements with a suitable example.
(d) Develop a program to calculate the reverse of any entered number.
(e) Explain the list Comprehension with any suitable example.
(a) Demonstrate the file handling procedure in detail. Write a python code to
create a file with ‘[Link]’ name and write your name and father’s name in this
2
file and then read this file to print it.
90
13
(b) Demonstrate the ‘Sieve of Eratosthenes’ theorem and write the python
_2
2.
P2
24
6. Attempt any one part of the following: 5x1 = 5
5.
3D
.5
P2
|1
(b) Explain Binary search with its python code and complexity.
9
:1
suitable example.
02
(b) Summarize the ‘Tower of Hanoi’ puzzle and write its recursive function to
-2
implement it.
03
1-
|2