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 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
2. Attempt any three of the following:
3.
Q
a. What are Boolean expressions in Python? Provide examples of Boolean 10
|4
expressions and explain their significance in programming. Discuss the concept
of Boolean type conversion in Python and provide examples of its usage.
7
b. Explain the representation of floating-point numbers in Python. How does 10
1
5:
Python handle floating-point arithmetic? Discuss the process of expression
:5
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
extract substrings? Give examples illustrating slicing operations. How do you
02
determine the length of a string in Python? Provide examples demonstrating the
-2
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
Discuss how to estimate the time complexity of binary search.
SECTION C
3. Attempt any one part of the following:
a. Discuss why Python is called as dynamic and strongly typed language? 10
Construct a program to find the sum of all Odd and Even numbers up to a number
specified by the user.
b. Construct a Python program to construct the following pattern, using a 10
nested for loop.
1|Page
QP24DP2_097 | 12-03-2024 13:55:17 | 43.230.196.200
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 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
b. Explore the working of while, and for loop with examples. 10
6.
P2
5. Attempt any one part of the following:
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:
12, 13, 14, 15]]) returns [6 , 7, 8, 9, 10]
:5
b. Construct following filters: 10
13
1. Filter all the numbers
2. Filter all the strings starting with a vowel
4
3. Filter all the strings that contains any of the following noun: Agra,
02
Ramesh, Tomato, Patna.
-2
Create a program that implements these filters to clean the text.
03
6. Attempt any one part of the following:
2-
a. Generate prime numbers with the help of Sieve of Eratosthenes. 10
|1
b. Write a Python program to check Armstrong number using object oriented 10
approach.
7. Attempt any one part of the following:
a. Write a python program for implementing Tower of Hanoi. 10
b. Write a python program for implementing merge sort. 10
2|Page
QP24DP2_097 | 12-03-2024 13:55:17 | 43.230.196.200