Python PYQ BANK FORMAT
Python PYQ BANK FORMAT
UNIT-1
A.SHORT ANSWER TYPE QUESTIONS
UNIT-2
A.SHORT ANSWER TYPE QUESTIONS
makePairs([1,3,5,7],[2,4,6,8])
returns [(1,2),
(3,4),(5,6),
(7,8)]
makePairs([],[])
returns []
2017,22 199 CO2
Write a program factors(N) that returns a
list of all positive divisors of N (N>=1). For
example:
factors(6) returns [1,2,3,6]
factors(1) returns [1]
factors(13) returns [1,13]
CO2
Explain all the conditional statement in python using 2018 48
small code example ?
CO2
Explain expression evaluation & float representation 2019,22 59
with example?
Write a python program for how to check if a given
number is Fibonacci number.
CO2
Explain the purpose and working of loops? Discuss 2018, 130
break and continue with example. Write a python
program to convert time from 12 hour to 24 hour
3
SHEAT COLLEGE OF ENGINEERING & MANAGEMENT
Affiliated to Dr. A. P. J Abdul Kalam Technical University, Lucknow
College Code -384
format.
UNIT-3
python?
What is the difference between python lists and 2020 153, 98 CO3
arrays?
Differentiate fruitful functions and void functions. 2018 215 CO3
triangle(3) prints:
4
SHEAT COLLEGE OF ENGINEERING & MANAGEMENT
Affiliated to Dr. A. P. J Abdul Kalam Technical University, Lucknow
College Code -384
*
**
***
triangle(5) prints:
*
**
***
****
*****
UNIT-4
A.SHORT ANSWER TYPE QUESTIONS
countSquares(5) returns 2
# 1, 4 are
perfect squares
<= 5
countSquares(55) returns 7
# 1, 4, 9, 16, 25, 36, 49 <=
55
CO4
Write a Python function, 2021 89, 155
alternating(lst), that takes as
argument a sequence lst. The function
returns True if the elements in lst are
alternately odd and even, starting with
an even number. Otherwise it returns
False. For example:
alternating([10, 9, 9, 6])
returns False
alternating([10, 15, 8]) returns
True alternating([10]) returns
True alternating([]) returns True
alternating([15, 10, 9]) returns
False
2017,19,21 70,80 CO4
Show an example where both Keyword
arguments and Default arguments are used
for the same function in a call. Show both the
definition of the function and its call.
UNIT-5
A.SHORT ANSWER TYPE QUESTIONS
program?
Question:- Write a python program for how to check if a given number is Fibonacci number?
Answer:-
Program:-
8
SHEAT COLLEGE OF ENGINEERING & MANAGEMENT
Affiliated to Dr. A. P. J Abdul Kalam Technical University, Lucknow
College Code -384
def fibonacci_with_list(n):
fib_series = [0, 1]
fib_series.append(fib_series[-1] + fib_series[-2])
return fib_series
# Example usage:
n = 10
result = fibonacci_with_list(n)
Output :-