0% found this document useful (0 votes)
38 views14 pages

B.Tech Python Programming Exam Paper

Uploaded by

rajgahoi01
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)
38 views14 pages

B.Tech Python Programming Exam Paper

Uploaded by

rajgahoi01
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

Printed Pages: 2 Sub Code:KNC-402

Paper Id: 238061 Roll No.

[Link].
(SEM IV) THEORY EXAMINATION 2022-23
PYTHON PROGRAMMING

Time: 3 Hours Total Marks: 100

Note: Attempt all Sections. If require any missing data; then choose suitably.

SECTION A

1. Attempt all questions in brief. 2 x 10 = 20


a. Define the programming cycle for Python.
b. Describe the use of class `__init__()` method.
c. Explain features of any two Python IDEs.
d. Discuss the purpose of the break and continue statement in loops.
e. Explain mutable sequences in Python.
f. Explain the output of following function.
90

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

g. Discuss the special methods __le__ and __ne__.


h. Discuss various file opening modes of python.
17
Q

|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

2. Attempt any three of the following: 10x3=30


-2
08

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.

QP23EP2_290 | 01-08-2023 13:24:30 | [Link]


SECTION C
3. Attempt any one part of the following: 10x1=10
a. Discuss various categories of operators in python. Find and explain stepwise
solution of following expressions if a=3, b=5, c=10.

i) a &b<<2//5**2+c^b
ii) b>>a**2<<2 >> b**2^c**3

b. Discuss why python is interpreted language. Explain history and features of


python while comparing python version 2 and 3.

4. Attempt any one part of the following: 10x1=10


a. Write a python program to count the vowels present in given input string.
Explain the output of program through example.
b. Write a program that accepts sequence of lines as input and prints the lines
after making all characters in the sentence capitalized.
e.g. If Input:
Hello world
Practice makes perfect
Then, Output:
90

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

6. Attempt any one part of the following: 10x1=10


: 24

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

b. Illustrate through examples, how we can implement different type of


inheritance in python? Explain the static, instance and class method through
-2

suitable example.
08
1-

7. Attempt any one part of the following: 10x1=10


|0

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?

QP23EP2_290 | 01-08-2023 13:24:30 | [Link]


Printed Page: 1 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

Note: Attempt all Sections. In case of any missing data; choose suitably.

SECTION A

1. Attempt all questions in brief. 02 x 7 = 14


Q Question CO Level
no.
a. What are Python variables? Explain with examples. 1 K1,
पाइथन वे रएब ा होते ह? उदाहरण सिहत समझाइए। K2
b. Describe Python basic operators with suitable examples. 1 K1,
पाइथन के बेिसक ऑपरे टरों को उपयु उदाहरणों सिहत विणत कीिजए। K2
c. Explain different Python data types with examples. 1 K1,
पाइथन के िविभ डे टा कारों को उदाहरण सिहत समझाइए। K2
d. How are numeric data types declared and used in Python? 1 K1
पाइथन म ूमे रक डे टा टाइ को कैसे घोिषत िकया और उपयोग िकया जाताहै ?

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

number is even or odd using if and else statement. K2


if, else, और elif के उपयोग को समझाइये। if और else कथन का उपयोग करके दी गई

5.
5E

सं ा सम या िवषम है यह जां चने के िलए पायथन ो ाम िलख।

.5
g. Differentiate between for loop and while loop with syntax and examples. 2 K1,

17
P2

for लूप और while लूप म अंतर को िसंटै और उदाहरणों के साथ समझाइए। |1 K2


Q

SECTION B
PM

2. Attempt any three of the following: 07 x 3 = 21


1

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

Python म Nested Loops का उपयोग समझाइए। एक ो ाम िल खए जो ार (*) का


J

राइट-एं गल ि भुज ि ंट करे ।


9-

d. Explain string slicing and string operations in Python. 3 K3


|0

पाइथन म ं ग ाइिसंग और ं ग ऑपरे श को समझाइए।


e. Describe how tuples differ from lists in Python with examples. 3 K3
पाइथन म ू प और िल ् स म ा अंतर है ? उदाहरण सिहत बताइए।

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

4. Attempt any one part of the following: 07 x 1 = 07


1:

Q Question CO Level
no.
5

a. How can data be organized using complex data types in Python? 3 K2,
02

पाइथन म जिटल डे टा कारों का उपयोग करके डे टा को कैसे व त िकया जा K3


-2

सकताहै ?
ul

b. Explain file handling modes in Python. 3 K2


J

पाइथन म फ़ाइल हडिलंग मोड् स को समझाइए।


9-
|0

5. Attempt any one part of the following: 07 x 1 = 07


Q Question CO Level
no.
a. Write a program to read and write data from a text [Link] do readline() 4 K2
and readlines() work? Explain with examples.
एक ो ाम िल खए जोिक सी टे फ़ाइल से डे टा पढ़ और िलख सके। readline() और

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

readlines() कैसे काय करते ह? उदाहरण सिहत समझाइए।


b. What is the purpose of the seek() method in file handling?Demonstrate a 4 K2,K4
program that copies content from one file to another.
फ़ाइल संचालन म seek() मेथड का ा उपयोग है ? एक फ़ाइल से दू सरी फ़ाइल म
कंटट कॉपी करने वाला ो ाम िल खए।
6. Attempt any one part of the following: 07 x 1 = 07
Q Question CO Level
no.
a. Write a Python program using numpy to perform matrix operations. 5 K2,K4
Numpy का उपयोग करते ए मैिट ऑपरे श करने वाला पाइथन ो ाम िल खए।
b. Explain the use of matplotlib for data visualization. Write a program to 5 K4
visualize Line plots using these data.
x = [1, 2, 3, 4, 5]
y = [10, 20, 25, 30, 40]

4
Matplotlib का डे टा िवज़ुअलाइज़ेशन म उपयोग समझाइए। नीचे िदए गए डे टा का

13
90
उपयोग करते ए एक लाइन ॉट दिशत करने का ो ाम िल खए।

2.
िदयागयाडे टा:
_2

x = [1, 2, 3, 4, 5]

24
P1

y = [10, 20, 25, 30, 40]

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

program using Tkinter to accept and display student data.


पाइथन म GUI ो ािमंग ा होतीहै ? Tkinter का उपयोग करके एक GUI आधा रत
PM

ो ाम िल खए जो छा की जानकारी ले और दिशतकरे ।
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

1. Attempt all questions in brief.


Q no. Question Marks
a. Describe the concept of list comprehension with a suitable example 2
b. Differentiate between / and // operator with an example 2
c. Compute the output of the following python code: 2
def count(s):
for str in [Link]():
s = “&”.join(str)
return s
print(count(“Python is fun to learn.”))
d. How to use the functions defined in [Link] in [Link] 2
e. Describe the difference between linspace and argspace. 2
f. Explain why the program generates an error. 2
90

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

2. Attempt any three of the following:


17
Q

a. Illustrate Unpacking tuples, mutable sequences, and string concatenation with 7


|1

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

4. Return a list that starts from the middle of the list L.


02

5. Return a list that reverses all the elements starting from element at index
-2

0 to middle index only and return the entire list.


03

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-

square otherwise it returns -1.


|1

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

Food Calories Potassium fat


Meat 250 40 8
Banana 130 55 5
Avocados 140 20 3
Sweet
Potatoes 120 30 6
Spinach 20 40 1
Watermelon 20 32 1.5
Coconut
water 10 10 0
Beans 50 26 2
Legumes 40 25 1.5
Tomato 19 20 2.5
SECTION C
90

2
3. Attempt any one part of the following:

13
_2

a. Determine a python function removenth(s,n) that takes an input a string and an 7

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

b. Construct a program that accepts a comma separated sequence of words as input 7


|1

and prints the words in a comma-separated sequence after sorting them


alphabetically.
3 0

Suppose the following input is supplied to the program:


0:

without, hello, bag, world


:2

Then, the output should be:


13

bag, hello, without, world


4. Attempt any one part of the following:
4
02

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

Following are the criteria for checking the password:


03

1. At least 1 letter between [a-z]


2-

2. At least 1 number between [0-9]


|1

3. At least 1 letter between [A-Z]


4. At least 1 character from [$#@]
5. Minimum length of transaction password: 6
6. Maximum length of transaction password: 12
Your program should accept a sequence of comma separated passwords and will
check them according to the above criteria. Passwords that match the criteria are
to be printed, each separated by a comma
b. Explore the working of while, and for loop with examples. 7
5. Attempt any one part of the following:

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

b. Construct a program which accepts a sequence of words separated by whitespace 7


17
as file input. Print the words composed of digits only.
Q

|1

7. Attempt any one part of the following:


a. Construct a program to read [Link] dataset, remove last column and save it in 7
3 0

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

subtraction, multiplication, division and clear.


13
4
02
-2
03
2-
|1

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

पायथन म लै34डा फ़ं5नोंकेउपयोग का सं ि67 वण2न कर।

5.
5D

.5
f. Demonstrate how to assign a single value to a tuple. 1 K3
टपल (tuple) को एकलमान कैसे असाइन कर, इसे+दिश2त कर।
17
P2

g. Explain why numpy is used instead of python arrays for mathematical 5 K2


|1
Q

calculations?
गणना9क गणनाओंके िलए numpy का उपयोग #ोंिकया जाता है , इसे
PM

समझाएँ ?
40

SECTION B
2:

2. Attempt any three of the following: 07 x 3 = 21


3

Q no. Question CO Level


1:

a. Design a basic calculator in Python that supports addition, subtraction, 1 K3


5

multiplication, division.
02

पायथन म एक बे िसक कैलकुले टर िडज़ाइन कर जो जोड़, घटाव, गुणा, भाग का


-2

समथ2न करता हो।


ar

b. Define Membership and Identity Operators. 2 K4


M

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

c. Write a Python function to count the frequency of each character in a 3 K3


given string and return the output in a dictionary. Example:
char_frequency("HELLO") returns {"H":1, "E":1, "L":2, "O":1}
एक पायथन फ़ं5न िलख जो िदए गए FG ं ग म +Hे क वण2 की आवृिJ
(frequency) िगनता है और आउटपुट को एक िड5नरी म लौटाता
है ।उदाहरण: char_frequency("HELLO") लौटाता है {"H":1, "E":1, "L":2,
"O":1}
d. Write a program to reverse the contents of a file character by character, 4 K3
separating each character with a comma.
एक +ोLाम िलख जो िकसी फाइल की सामLी को वण2 दर वण2 उMा करे ,
+Hे क वण2 को कॉमा सेअलग करतेOए।
e. Create a pie chart using matplotlib to represent the following data: 5 K3
Languages Popularity
Python 30
Java 25

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:

3. Attempt any one part of the following: 07 x 1 = 07


5

Q no. Question CO Level


02

a. Write short notes on the following with examples: 1 K2


-2

a) Operator Precedence
ar

b) Python Indentation
c) Type Conversion
M

िन िल खत पर सं ि67 नोट िलख उदाहरण सिहत:


1-

a) ऑपरे टर+ाथिमकता (Operator Precedence)


|2

b) पायथनइं डटेशन (Indentation)


c) +कारपAरवत2न (Type Conversion)
b. Write a program to validate email addresses using regular expressions. 1 K3
Criteria:
1. Must contain @ symbol
2. Must contain domain name
3. Should not have spaces

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

िनयिमतअिभU Vयों(regular expressions) का उपयोग करके ईमे


ल पते
सHािपत करने के िलए एक +ोLाम िलख।मापदं
ड:
1. @ िचW होना चािहए
2. डोमे
न नाम होना चािहए
3. Dेस नहींहोना चािहए

4. Attempt any one part of the following: 07 x 1 = 07


Q no. Question CO Level
a. Write a program to create a hollow pyramid pattern given below: 2 K3
*
**
* *
* *
*********

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

Discuss break and continue with example.


लूY की आव1कता #ोंहोती है और पायथन म लूY के +कार #ाह/ , इसे
PM

समझाएँ । break और continue को उदाहरण सिहत समझाएँ ।


40

5. Attempt any one part of the following: 07 x 1 = 07


3 2:

Q no. Question CO Level


1:

a. Write a function to find the longest word in a given list of words. 3 K3


5

Example: longest_word([‘apple’, ‘banana’, ‘cherry’]) returns ‘banana’.


02

िदए गए शZोंकी सूची म सबसेलं बा शZ खोजनेके िलए एक फ़ं5न


-2

िलख।उदाहरण: longest_word(['apple', 'banana', 'cherry']) लौटाता है


ar

'banana'।
M

b. Distinguish between a Tuple and a List with examples. Explain with 3 K4


1-

examples atleast 4 built-in methods of Dictionary.


|2

टपल (Tuple) और िलF (List) के बीच अं तर DE कर।िड5नरी के कम से


कम 4 इन िबMमे थड् स (अं तिन2िहत िविध) केउदाहरण द।
6. Attempt any one part of the following: 07 x 1 = 07
Q no. Question CO Level
a. Discuss different types of file modes in Python? Explain with examples. 4 2
पायथन म िविभ\ +कार के फ़ाइल मोड पर चचा2 कर।उदाहरण सिहत
समझाएँ ।
3|Page
QP25DP2_290 | 21-Mar-2025 1:32:40 PM | [Link]
Printed Page: 4 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

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रत सीमा सेअिधकहै ।

7. Attempt any one part of the following: 07 x 1 = 07


Q no. Question CO Level
a. Discuss the role of event handling in Tkinter. How can you bind events 5 K2
to widgets? Provide examples.
Tkinter म इवट ह/डिलं ग की भूिमका पर चचा2 कर।आपइवट् स को िवजे ट्स से
कैसेबाँ ध सकतेह/? उदाहरण द।
b. Write a program to read data from a CSV file '[Link]', calculate the 5 K4
average marks for each student, and display the results.
एक +ोLाम िलख जो '[Link]' फ़ाइल सेडे टा पढ़े , +Hेक छा_ केऔसत

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

Paper Id: 233077 Roll No.

[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

1. Attempt all questions in brief. 1x10 = 10

(a) Explain the Programming Cycle for Python in detail.


(b) Describe the concept of List Slicing with a suitable example.
(c) Show the way to import the module in python.
(d) Differentiate between Python Arrays and lists?
(e) Define floor division with an example.
(f) Explain the difference between 'append' and 'extend' in Python?
(g) What is a dictionary in Python?

2
90

13
(h) What is object-oriented programming (OOP) in Python? Give an example.
_2

(i) What will be the output of the following python code

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(count1(‘I love India’))


:1
31

(j) What will be the output of the following code?


list1 = ['M', 'o', 'n', 'k', 'y']
:
13

print("@".join(list1))
3
02

SECTION B
-2

2. Attempt any three of the following: 5x3 = 15


03

(a) Demonstrate five different built in functions used in the string. Write a
1-

program to check whether a string is a palindrome or not.


|2

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

QP23DP2_290 | 21-03-2023 13:31:19 | [Link]


SECTION C
3. Attempt any one part of the following: 5x1 = 5

(a) Illustrate Unpacking Sequences, Mutable Sequences, and List


comprehension with examples.
(b) Explain the lambda function. How it is helpful in the higher order function.
Explain map() function with a suitable example.

4. Attempt any one part of the following: 5x1 = 5

(a) Discuss the different types of argument-passing methods in python. Explain


the variable length argument with any suitable example.
(b) Write short notes on the following with a suitable example
I) Encapsulation II) Inheritance

5. Attempt any one part of the following: 5x1 = 5

(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

function to print prime numbers between 1 to 100.

2.
P2

24
6. Attempt any one part of the following: 5x1 = 5

5.
3D

.5
P2

(a) Develop and write the python code of selection sort


17
41,65,43,91,12,14,62 elements. Also, explain its complexity.
to sort
Q

|1
(b) Explain Binary search with its python code and complexity.
9
:1

7. Attempt any one part of the following: 5x1 = 5


: 31
13

(a) Explain the importance of Exception handling in any object-oriented


programming language. Explain try exceptions and finally block with any
3

suitable example.
02

(b) Summarize the ‘Tower of Hanoi’ puzzle and write its recursive function to
-2

implement it.
03
1-
|2

QP23DP2_290 | 21-03-2023 13:31:19 | [Link]

You might also like