B.Tech R22 Mid Question Bank Python 1
B.Tech R22 Mid Question Bank Python 1
MID-I Questions
Q.No Questions Marks BL CO Unit No
1 State any four applications of python. 2 L1 CO1 1
2 State the identifier rules in python. 2 L1 CO1 1
How would you determine whether any element is
3 2 L2 CO1 1
present in a given sequence?
4 List the Conditional statements in Python. 2 L2 CO1 1
Write a python program to print the prime numbers
5 2 L2 CO1 1
between 1 to 100.
Give an example to show the advantage of using else
6 2 L2 CO1 1
statement with for loop.
7 List out the ways of importing the array module. 2 L1 CO2 2
How would you determine length of an array and size
8 2 L3 CO2 2
of each element in an array ?
9 How to find size and shape of the numpy array? 2 L2 CO2 2
Write a python program to accept a string and display
10 2 L2 CO2 2
each word and its length.
11 Differentiate del, remove and pop on Python Arrays. 2 L2 CO2 2
Write a python program to find the largest and second
12 2 L1 CO2 2
largest element in an array.
Write an example to show passing of variable length
13 2 L2 CO3 3
arguments to a function.
14 Create a list using range() in python? 2 L3 CO3 3
Give an example to show the usage of List
15 2 L2 CO3 3
Comprehension.
Mid-II Questions
16 What is Tuple Packing and Unpacking. 2 L1 CO3 3
17 What is the difference between a tuple and a list? 2 L1 CO3 3
18 Write a code to sort dictionaries using a key. 2 L1 CO3 3
19 List File attributes in Python. 2 L1 CO4 4
20 List various ways of importing a module. 2 L1 CO4 4
21 Name some common exceptions in python. 2 L1 CO4 4
How do you handle the exception inside a program
22 2 L3 CO4 4
when you try to open a non-existent file.
23 Explain the purpose of the raise statement in Python. 2 L2 CO4 4
Write an example to show the purpose of finally
24 2 L2 CO4 4
block.
25 How is the constructor method defined in Python? 2 L1 CO5 5
26 Give the syntax of multilevel inheritance. 2 L2 CO5 5
Which metacharacter in regular expression matches
27 2 L1 CO5 5
any character other than the newline character.
Write the method which returns the name of the thread
28 2 L2 CO5 5
in threading module.
29 What is the purpose of the self keyword in methods? 2 L2 CO5 5
How do you implement abstract classes and methods
30 2 L2 CO5 5s
in Python?
PART-B
Mid-I Questions
Q.No Questions Marks BL CO Unit No
List and explain different arithmetic operators
1 supported by Python. Discuss about their 4 L2 CO1 1
precedence and associativity.
Explain the different datatypes available in Python.
2 Provide example of how to declare variables of these 4 L2 CO1 1
data types.
3 Explain in detail about python type conversion. 4 L2 CO1 1
Write a program to calculate the total amount to be
1
4 paid by the user after reducing the 10% 4 L3 CO1
discount on purchase more than 1000 rupees.
Explain about the following Decision control
5 Statements. 4 L2 CO1 1
i)if-else ii)nested if-else iii)if-elif-else
Illustrate the usage of while loop in python. Write a
6 python program to find sum of n natural numbers 4 L2 CO1 1
using while loop.
Explain in detail about the looping statements in
7 8 L2 CO1 1
Python with suitable examples.
Discuss the number data types in Python and Detail
8 the methods to convert from one number system to 8 L2 CO1 1
other.
Discuss the following statements with examples
9 8 L1 CO1 1
a) break b) continue c) pass d) return
Explain the importance of reshaping and flattening a
10 4 L2 CO2 2
numpy array with suitable example.
Write a Python program that removes all duplicate
11 4 L2 CO2 2
elements from an array and returns a new array.
Write a python program to compute addition,
12 4 L2 CO2 2
multiplication of matrices using numpy.
Explain about different string operations using
13 4 L2 CO2 2
suitable python program.
You have been given a task to find out the number
of characters, extracting a substring and reversing a
14 4 L2 CO2 2
string. Write the methods or operations to perform
the above task.
Explain about sorting a string. Write a python
15 program to check the given string is palindrome or 4 L3 CO2 2
not.
16 Demonstrate Array methods with suitable examples. 8 L2 CO2 2
Discuss various string handling methods with
17 8 L2 CO2 2
suitable examples.
Differentiate between Arrays and Lists with suitable
18 8 L2 CO2 2
examples.
Define what is a function. Explain about Function
19 declaration, definition and function call in 4 L2 CO3 3
Python.
Discuss the following with suitable example?
20 i) Lambda function ii) Map function iii) Reduce 4 L2 CO3 3
function
Define a List. Discuss how to perform operations on
21 4 L3 CO3 3
list in Python.
How can you sort a list of strings in Python? Write a
22 Python code snippet to sort a list of strings 4 L2 CO3 3
alphabetically.
Mid-II Questions
Explain how to create and access elements in Tuple.
23 Illustrate with an example and discuss how tuples 4 L2 CO3 3
differs from list in terms of mutability.
Convert a list of strings into a dictionary where each
24 string is a key and its length is a value. Write a 4 L3 CO3 3
python program for this conversion.
Discuss the following dictionary methods
25 4 L3 CO3 3
a)fromkeys() b) setdefault() c) update()
Demonstrate with an example to sort Dictionary
26 4 L2 CO3 3
Items.
Demonstrate seek() and tell() methods in file
27 4 L2 CO4 4
handling with an example.
Write a short note on different methods to read data
28 4 L2 CO4 4
from a file.
Explain Picking and unpicking with the help of an
29 4 L2 CO4 4
example.
Discuss any three common exceptions in Python
30 4 L2 CO4 4
with examples.
Develop a Python program to implement single try
31 block with multiple except blocks and trace the code 4 L2 CO4 4
for its execution?
Explain the purpose of ‘else’ and ‘finally’ blocks in
32 4 L2 CO4 4
exception handling with a python program.
33 Discuss various directory methods in OS module. 8 L2 CO4 4
Explain the utility of Assert and Raise keywords.
34 Show how to handle various exceptions with 8 L3 CO4 4
examples.
How can you create your own exceptions in Python?
35 Write a program to print the square root of a 8 L3 CO4 4
number, raise an exception if number is negative.
With the help of an example demonstrate multilevel
36 4 L2 CO5 5
inheritance and multiple inheritance.
Illustrate about init() method with the help of an
37 4 L2 CO5 5
example.
With the help of an example explain data
38 4 L2 CO5 5
encapsulation in python class.
Differentiate between re.search() and re.match() in
39 4 L3 CO5 5
regular expressions.
Discuss the following metacharacters a) \w b) \s
40 4 L3 CO5 5
c) \A d) ? e) {m}
41 Define the term multithreading. Give its advantages. 4 L2 CO5 5
Write short notes on abstract class. Differentiate
42 8 L3 CO5 5
between abstract class and interfaces.
Discuss re.Ignorecase and re.mutliline flags in
regular expressions. Write a python program to
43 8 L3 CO5 5
check that a string contains only a certain set of
characters. (in this case a-z, A-Z and 0-9)
44 Explain creating a thread using threading module. 8 L3 CO5 5