Printed Page: 1 of 1
Subject Code: KNC402
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM IV) 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*4 = 10
Qno Questions CO
(a) Discuss why Python is called as dynamic and strongly typed language? 1
(b) How pass statement is different from a comment? 2
(c) Write a for loop that prints numbers from 0 to 57, using range function. 2
(d) What is the difference between Python Arrays and Lists? 3
SECTION B
2. Attempt any two of the following: 4*2 = 8
Qno Questions CO
(a) Write a python function named ComputeAverage to find average of a list of 3
numbers. It should handle the exception if the list is empty and return 0 in
that case.
(b) Implement the binary search technique. 5
(c) Explain the use of break and continue with a suitable example. 2
90
2
13
SECTION C
_2
3. Attempt any two part of the following: 4*2 = 8
2.
Qno Questions CO
P2
24
(a) What do you mean by operator precedence and associativity. Explain. 1
2E
5.
(b) Write short notes on 1
.5
P2
i. The programming cycle for python
17
ii. Type conversion in python
Q
(c) Write Python program to swap two numbers without using 1
|1
Intermediate/Temporary variables. Prompt the user for input.
4. Attempt any two part of the following: 4*2 = 8
6
Qno Questions CO
2
2:
(a) Write a program to check an input number is prime or not. 2
:3
(b) Write a program that accepts a sentence and calculate the number of digits, 2
13
uppercase and lowercase letters.
(c) Write a program to check an input year is leap year or not. 2
2
5. Attempt any two part of the following: 4*2 = 8
02
Qno Questions CO
-2
(a) There is a file named [Link]. Enter some positive numbers into the file 4
08
named [Link]. Read the contents of the file and if it is an odd number
write it to [Link] and if the number is even, write it to [Link]
2-
(b) Discuss Exceptions and Assertions in Python. Explain with a suitable 4
|0
example. Explain any two built-in exceptions.
(c) What is the significance of module in Python? What are the methods of 4
importing a module? Explain with suitable example
6. Attempt any two part of the following: 4*2 = 8
Qno Questions CO
(a) What do you mean by recursion? Write a recursive function to compute the 5
factorial of an input number N.
(b) Implement selection sort using Python 5
(c) What are different types of inheritance supported by Python? Explain. 4
QP22EP2_290 | 02-08-2022
Downloaded [Link] | [Link]
from : [Link]