Knc302 Python Programming 2023-24
Knc302 Python Programming 2023-24
BTECH
(SEM III) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3HRS M.MARKS: 50
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. What are the key components of the programming cycle in Python? 2
b. Discuss the concept of type conversion in Python and provide examples of its 2
usage.
c. Explain the syntax and working of the if-else statement in Python. Provide 2
examples demonstrating its usage.
d. What are nested loops in Python? Provide examples demonstrating their usage 2
e. Explain the concept of scope rules in Python functions. 2
f. Describe the concept of slicing in Python strings. 2
g. Discuss the efficiency of the Sieve of Eratosthenes algorithm compared to other 2
methods of generating prime numbers.
h. Define abstract data types (ADTs) and their significance in Python 2
97
0
programming.
20
i. Define simple search and discuss its time complexity. How can you estimate the 2
_0
6.
search time for simple search algorithms?
P2
19
j. Compare sorting algorithms in terms of efficiency? 2
4D
SECTION B
0.
23
P2
evaluation in Python. How are expressions evaluated, and what are the common
13
pitfalls?
c. Describe the concept of slicing in Python strings. How does slicing allow you to 10
4
len() function.
03
d. Discuss error handling techniques while working with file I/O operations. How 10
do you handle exceptions that may occur during file operations?
2-
e. Explain the binary search algorithm and its advantages over simple search. 10
|1
BTECH
(SEM III) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3HRS M.MARKS: 50
*
**
***
****
*****
4. Attempt any one part of the following:
a. A website requires the users to input username and password to register. 10
Construct a program to check the validity of password input by users.
Following are the criteria for checking the password:
1. At least 1 letter between [a-z]
2. At least 1 number between [0-9]
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
97
check them according to the above criteria. Passwords that match the criteria are
0
20
to be printed, each separated by a comma.
_0
6.
P2
19
4D
a. Construct a function ret_smaller(l) that returns smallest list from a nested list. If 10
0.
two lists have same length then return the first list that is encountered. For
23
P2
example:
3.
Q
|4
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]
7
ret_smaller([ [ -2, -1, 0, 0.12, 1, 2], [‘a’, ’b’, ’c’, ’d’, 3, 4, 5], [6 , 7, 8, 9, 10], [11,
1
5:
3. Filter all the strings that contains any of the following noun: Agra,
02
2|Page
QP24DP2_097 | 12-03-2024 13:55:17 | 43.230.196.200