0% found this document useful (0 votes)
4 views8 pages

Python PYQ BANK FORMAT

The document is a question bank for a course at Sheat College of Engineering & Management, covering various units of Python programming. It includes short and long answer type questions, along with examples and explanations related to Python concepts such as interpreted language, short circuit evaluation, and Fibonacci series. Each question is categorized by unit, year, answer page number, and knowledge levels.

Uploaded by

csearun877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Python PYQ BANK FORMAT

The document is a question bank for a course at Sheat College of Engineering & Management, covering various units of Python programming. It includes short and long answer type questions, along with examples and explanations related to Python concepts such as interpreted language, short circuit evaluation, and Fibonacci series. Each question is categorized by unit, year, answer page number, and knowledge levels.

Uploaded by

csearun877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

1

SHEAT COLLEGE OF ENGINEERING & MANAGEMENT


Affiliated to Dr. A. P. J Abdul Kalam Technical University, Lucknow
College Code -384

QUESTION BANK FORMAT

UNIT-1
A.SHORT ANSWER TYPE QUESTIONS

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS
Which of the following statements produce 2017,19,21 43 CO1 K1
an error in Python?
x, y, z = 1,2,3 # s1
a, b = 4,5,6 # s2
u = 7,8,9 # s3
(List all the statements that have error.)
2019,17 81 CO1
Explain the role of precedence with an
example.
2020,21,22 98 CO1
Consider the program:
x = ['12', 'hello', 456]
x[0] *= 3
x[1][1] = 'bye'
Explain why this program generates an error.

B.LONG ANSWER TYPE QUESTIONS

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS
2018,19,21 38 CO1
Explain why Python is considered an
interpreted language.
2020,22 273 CO1
What is short circuit evaluation? What is
printed by the following Python program?
a = 0
b = 2
c = 3
x = c or a print(x)
2021 38 CO1
Explain why Python is considered an
interpreted language.
2
SHEAT COLLEGE OF ENGINEERING & MANAGEMENT
Affiliated to Dr. A. P. J Abdul Kalam Technical University, Lucknow
College Code -384

UNIT-2
A.SHORT ANSWER TYPE QUESTIONS

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS
2020, 40 CO2
In some languages, every statements ends with
semi-colon(;). What happens if you put a semi –
colon at a end of a python statement?
2017 38 CO2
How is python an interpreted language?

B.LONG ANSWER TYPE QUESTIONS

QUES. QUESTIONS YEAR ANSWER CO KNOWLED


NO. PAGE NO GE
LEVELS
2022,23 219 CO2
Write a function makePairs that takes as
input two lists of equal length and returns a
single list of same length where k-th element
is the pair of k-th elements from the input lists.
For example,

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

A.SHORT ANSWER TYPE QUESTIONS

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS
2019,21 120 CO3
Describe the behavior of “range (s, e)”
in Python.
2020, 228 CO3
Write a recursive Python function
“rprint” to print all elements in a list in
reverse.
rprint([]) prints nothing
rprint([1,2,3]) prints 3 2 1
What is the difference between list and tuples in 2018,19,21 153, 160 CO3

python?
What is the difference between python lists and 2020 153, 98 CO3

arrays?
Differentiate fruitful functions and void functions. 2018 215 CO3

B.LONG ANSWER TYPE QUESTIONS

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS
2018,20 155 CO3
Write a Python function,
searchMany(s, x, k), that takes as
argument a sequence s and integers x, k
(k>0). The function returns True if
there are at most k occurrences of x in s.
Otherwise it returns False. For example:
searchMany([10, 17, 15, 12],
15, 1) returns True
searchMany([10, 12, 12, 12],
12, 2) returns False
searchMany([10, 12, 15, 11],
17, 18) returns True
2019,21,22 167 CO3
Write a Python program, triangle(N),
that prints a right triangle having base and
height consisting of N * symbols as
shown in these examples:

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

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS

B.LONG ANSWER TYPE QUESTIONS

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS
2017,20,23 158,205 CO4
Write a Python program,
countSquares(N), that returns the
count of perfect squares less than or equal
to N (N>1). For example:
countSquares(1) returns 1
# Only 1 is a
perfect square <= 1
5
SHEAT COLLEGE OF ENGINEERING & MANAGEMENT
Affiliated to Dr. A. P. J Abdul Kalam Technical University, Lucknow
College Code -384

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

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS
2022, 239 CO5
What is the output of the following
6
SHEAT COLLEGE OF ENGINEERING & MANAGEMENT
Affiliated to Dr. A. P. J Abdul Kalam Technical University, Lucknow
College Code -384

program?

(lambda x,y : y - 2*x) (1, 11)


2021 205 CO5
Explain the use of lt function in a
class Python?
2022 185 CO5
How do you read an input from a user in
Python to be used as an integer in the rest of
the program? Explain with an example.
2019,20 120 CO5
Explain the use of “with” construct in
Python with an example program.

B.LONG ANSWER TYPE QUESTIONS

QUES. QUESTIONS YEAR ANSWER CO KNOWLEDGE


NO. PAGE NO LEVELS
2018,20,21 189 CO5
Describe the differences between a linear
search and a binary search?
2018,21 170 CO5
How can you create Python file that can be
imported as a library as well as run as a
standalone script?

 Question:- What is short circuit evaluation? What is short circuit evaluation?

Answer :- By short-circuiting, we mean the stoppage of


execution of boolean operation if the truth value of
expression has been determined already. The evaluation of
7
SHEAT COLLEGE OF ENGINEERING & MANAGEMENT
Affiliated to Dr. A. P. J Abdul Kalam Technical University, Lucknow
College Code -384

expression takes place from left to right. In python, short-circuiting


is supported by various boolean operators and functions.
Short-Circuiting in Boolean Operators
The chart given below gives an insight into the short-circuiting
case of boolean expressions. Boolean operators are ordered by
ascending priority.

or: When the Python interpreter scans or expression, it takes


the first statement and checks to see if it is true. If the first
statement is true, then Python returns that object’s value without
checking the second statement. The program does not bother with
the second statement. If the first value is false, only then Python
check the second value, and then the result is based on the second
half.
and: For an and expression, Python uses a short circuit technique to
check if the first statement is false then the whole statement must be
false, so it returns that value. Only if the first value is true, does it
check the second statement and return the value.
An expression containing and or stops execution when the truth
value of expression has been achieved. Evaluation takes place from
left to right.

Question:- Write a python program for how to check if a given number is Fibonacci number?

Answer:-

The Fibonacci series is a sequence of numbers in which each number


is the sum of the two preceding ones, usually starting with 0 and 1.
The sequence goes as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on.
This series is not only intriguing due to its inherent mathematical
properties but also widely used in various fields such as
mathematics, computer science, and nature.
Mathematical Logic
The Fibonacci series follows a simple mathematical logic. The first
two numbers in the sequence are 0 and 1. From the third number
onward, each number is the sum of the two preceding ones.
Mathematically, it can be expressed as:
Syntax :
F(n)=F(n−1)+F(n−2)

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]

for i in range(2, n):

fib_series.append(fib_series[-1] + fib_series[-2])

return fib_series

# Example usage:

n = 10

result = fibonacci_with_list(n)

print(f"Fibonacci series with {n} elements:", result)

Output :-

Fibonacci series with 10 elements: [0, 1, 1, 2, 3, 5, 8, 13, 21,


34]

You might also like