AKTU - QP20E290QP: Time: 3 Hours Total Marks: 100
AKTU - QP20E290QP: Time: 3 Hours Total Marks: 100
SECTION A
1. Attempt all questions in brief.
Q no. Question Marks CO
a. What is the use of “raise” statement? Describe with an example. 2 5
P
program.
0Q
1
13
e. Which of the following statements produce an error in Python? 2 1
29
x, y, z = 1,2,3 # s1
2.
0E
a, b = 4,5,6 # s2
24
P2
u = 7,8,9 # s3
5.
(List all the statements that have error.)
_Q
.5
f. Explain the role of precedence with an example. 17 2 1
TU
6
:5
x[0] *= 3
x[1][1] = 'bye'
1
02
P
d. Write a function lessthan(lst, k) to return list of numbers less 10
0Q 4
than k from a list lst. The function must use list comprehension.
1
13
Example:
29
2.
0E
24
e. Write a program factors(N) that returns a list of all positive divisors 10 2
P2
5.
of N (N>=1). For example:
_Q
.5
factors(6) returns [1,2,3,6] 17
factors(1) returns [1]
TU
6
:5
SECTION C
07
a. How can you create Python file that can be imported as a library as well 10 5
1
import library
and
M
2-
library.
makePairs([1,3,5,7],[2,4,6,8])
returns [(1,2),(3,4),(5,6),(7,8)]
makePairs([],[])
returns []
P
Q no. Question 0Q Marks CO
a. Explain why Python is considered an interpreted language. 10 1
1
13
29
2.
0E
Python program?
24
a = 0
P2
5.
b = 2
_Q
.5
c = 3 17
x = c or a
TU
print(x)
|1
AK
6
:5
:07
14
1
02
-2
ar
M
2-
|1
triangle(3) prints:
*
**
***
triangle(5) prints:
*
**
***
****
*****
P
countSquares(1) returns 1
0Q
1
# Only 1 is a perfect square <= 1
13
29
countSquares(5) returns 2
2.
# 1, 4 are perfect squares <= 5
0E
24
countSquares(55) returns 7
P2
5.
_Q
.5
17
7. Attempt any one part of the following:
TU
|1
in lst are alternately odd and even, starting with an even number.
Otherwise it returns False. For example:
:
14