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

Python Programming Question Bank 2025

The document is a question bank for the Python Programming course (ACS102) for the academic year 2025-2026. It outlines course outcomes, knowledge levels based on Bloom's taxonomy, and includes detailed questions and topics for three units covering basics of Python programming, control structures, and collections. Each unit contains both part A and part B questions, focusing on various programming concepts and practical applications in Python.

Uploaded by

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

Python Programming Question Bank 2025

The document is a question bank for the Python Programming course (ACS102) for the academic year 2025-2026. It outlines course outcomes, knowledge levels based on Bloom's taxonomy, and includes detailed questions and topics for three units covering basics of Python programming, control structures, and collections. Each unit contains both part A and part B questions, focusing on various programming concepts and practical applications in Python.

Uploaded by

sasi081182
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

QUESTION BANK

SUBJECT CODE: ACS102 YEAR / SEM: I/I


SUBJECT NAME: PYTHON PROGRAMMING
ACADEMIC YEAR: 2025-2026

Course Outcomes
After successful Completion of the Course, the Students should be able to
Course
Course Outcomes
Outcome No

1 Develop algorithmic solutions to simple computational problems.

2 Develop and execute simple Python programs.

3 Write simple Python programs using conditionals and loops for solving problems.

4 Decompose a Python program into functions.


5 Represent compound data using Python lists, tuples, dictionaries etc.
6 Read and write data from/to files in Python programs.
Knowledge Level (Blooms Taxonomy)
K
Remembering Understanding Applying
K1 K2
(Knowledge) (Comprehension) 3 (Application of Knowledge)
K
Analysing Evaluating Creating
K4 K5
(Analysis) (Evaluation) 6 (Synthesis)

UNIT 1 - BASICS OF PYTHON PROGRAMMING


Overview of programming language- Python history-Interactive mode – script mode-
Tokens: Literal-Keyword-Delimiter-Identifier-Data types: Integer-Floating-Complex-
Boolean-String-Indentation-Input operation-Comments
BT
[Link]. Questions Topics Marks
Level
PART – A
What is meant by Programming
1 BTL 1 2
Programming?
Define the term Programming Programming
2 BTL 2 2
Languages
Give some examples for Programming
3 BTL 3 2
Programming Languages.
What is meant by interpreter? Intrepreter BTL 1 2
4
How will you invoke the Interactive
5 BTL 2 2
python interactive interpreter? mode
What are the commands that are Intrepreter
used to exit from the python
6 BTL 2 2
interpreter in UNIX and
windows?
Define a variable and write Variables
7 down the rules for naming a BTL 1 2
variable.
Write a snippet to display Intrepreter
8 “Hello World” in python BTL 6 2
interpreter.
List down the basic data types Data type
9 BTL 1 2
in Python.
Define keyword and enumerate Keyword
10 some of the keywords in BTL 2 2
Python.
What do you mean by an Operator
11
operand and an operator?
BTL 4 2
Illustrate your answer with
relevant example.
Illustrate the use of “ and ‘ in String
12 BTL 3 2
string with example.
What is a local variable? Variables BTL 1 2
13
What do you mean by Intrepreter
14 BTL 1 2
indentation?
What is the use of parentheses? Operator BTL 3 2
15
What do you meant by an Operator
16 BTL 1 2
assignment operators?
What is tuple? How literals of Literals
17
type tuples are written? Give BTL 3 2
example
List down the different types of Identation
18 BTL 1 2
indentations used in python.
What is a global variable? Variables BTL 1 2
19
What is the purpose of using Comments
20 BTL 4 2
comments in python program?
Outline the logic to swap the Swapping
21
content of two identifiers BTL 4 2
without using third variable.
State about print statement Statements
22
available in python language BTL 1 2
with example.
Compare Interpreter and Translator
23 BTL 4 2
Compiler.
Write a python program to Variables BTL 5 2
24
circulate the values of n
variables
What are the rules for writing an Identifier BTL 1 2
25
identifier?
PART-B
What is the role of an Interactive
1.
interpreter? Give a detailed note and script
on python interpreter and mode
interactive mode of operation.
(or) Sketch the structures of
BTL 1 16
interpreter and compiler. Detail
the differences between them.
Explain how Python works in
interactive mode and script
mode with examples. (16 Mark)
Illustrate values and different Data type
2.
standard data types with BTL 2 16
relevant examples. (16 Mark)
Define variables. List down the Variables
3.
rules for naming the variable BTL 1 8
with example. (8 Marks)
List down the different types of Identation
4.
indentation errors with suitable BTL 1 8
example. (8 Marks)
Explain briefly in python History of
5. BTL 2 8
history.(8 Marks). python
Write a Python program to Variables
6.
circulate the values of n BTL 5 8
variables. (8 Marks )
Write a python program to swap Variables
7. BTL 5 8
two variables. (8 Marks )
Write a python program to Floating value
8.
convert celsius to fahrenheit .
BTL 5 8
(Formula: celsius * 1.8 =
fahrenheit –32). (8 Marks )
Write a python program to Data type
9.
check whether a given year is a BTL 6 8
leap year or not. (8 Marks )
Write a python program to print Data type
10.
the maximum among ‘n’
randomly generate ‘d’ numbers BTL 5 8
by storing them in a list. (8
Marks )

Unit 2 CONTROL STRUCTURE, OPERATORS AND 9


FUNCTIONS
Statements: if, if-else, nested if, if-else - Iterative statements: while, for, Nested loops, else in loops,
break, continue and pass statements. Operators: Arithmetic-Membership-Identity-Bitwise Functions
Types, parameters, arguments: positional arguments, keyword arguments, parameters with default
values, functions with arbitrary arguments, Scope of variables: Local and global scope, Recursion.
PART-A
1 Write the syntax for if with example? If statement BTL 1 2

2 Write the syntax and flowchart for if else. If else


BTL 4 2
statement
3 Write the syntax for while loop with flowchart. While loop BTL 5 2

4 Explain ‘for loop’ with example. For Loop BTL 5 2

5 What are the different types of operators? Operators BTL 1 2

6 Explain Membership Operators operators. Operators BTL 4 2


7 What is local and global scope? Variables BTL 4 2

8 Mention the use of pass Pass BTL 3 2

9 Differentiate local and global variable? Variables BTL 1 2

10 Define recursion. Recursion BTL 1 2

11 What is parameter and list down its type? Parameter BTL 1 2

12 write a program to check the number is odd or If else


even. BTL 6 2
statement

13 Break
What is a break statement? BTL 2 2
statement

14 What is a continue statement? Continue


BTL 5 2
statement
15 How will you update list items? Give one
List BTL 5 2
example.
16 write a program to find factorial of given numbers For loop BTL 5 2

17 What is meant by rule of precedence? Give the Operator


order of precedence. BTL 1 2
Precedence

18 Mention the types of arguments in python. Argument


BTL 1 2
types
19 Do loop statements have else clauses? When will
it be executed? Looping BTL 2 2

20 Write a Python program to accept two numbers, If else


find the greatest and print the result. BTL 2 2
statement

21 How many functions are there in Python? Function BTL 2 2


22 What is the main function in Python? Function BTL 2 2

23 What is the difference between parameter and


argument? Argument BTL 3 2

24 What are the 4 types of arguments? Argument BTL 3 2

25 Give an argument example? Argument BTL 3 2

PART-B
Explain conditional statements in detail with Statements 16
1. 1 BTL 1
example(if, if..else, if..elif..else) (16 Mark)
Discuss iteration statement with example. (16 Iteration 16
2. BTL 2
Mark)
Explain in detail about operators in detail Operators 8
3. BTL 3
(8 Mark)
Explain about loop control statement(break, 8
continue, pass) Looping BTL 2
4.
(8 Marks)
Discuss with an example about local and global 16
variable Variable BTL 1
5.
(16 Mark)
Explain in detail about recursion with example.(8) Recursion 8
6. BTL 3

Write a Python program to find the factorial of the Recursion 8


7. BTL 3
given number with recursion.(8)
[Link] in detail about using for loop in 16
sequence. Looping
8. BTL 5
b. Explain the usage of else statements in loops

[Link] in detail about iterations with 16


example.(for, while) Iteration
9. BTL 3
b. Write a Python program to find the square root
of a number. (16 Mark)
[Link] to find gcd of given nnumber 16
[Link] to find exponentiation of given number Looping
10. BTL 4
using recursion
Unit 3 COLLECTIONS, STRINGS AND REGULAR 9
EXPRESSIONS
List: Create Access, Negative Indices, Slicing, Splitting, List Methods, and comprehensions Tuples:
Create, Indexing and Slicing, Operations on tuples. Dictionary: Create, add, traversing and replace
values, operations on dictionaries. Sets: Create and operations on set. Strings: Formatting, Comparison,
Slicing, Splitting, Stripping, Negative indices, String functions. Regular expression: Matching the
patterns, Search and replace

PART-A
[Link] QUESTIONS TOPICS BT LEVEL MAKS
1 What is a list?
List BTL 1 2

2 Relate String and List? List BTL 4 2


3 Solve a)[0] * 4
List BTL 5 2
b) [1, 2, 3] * 3.
4 Let list = [’a’, ’b’, ’c’, ’d’,
’e’, ’f’].
Indices BTL 5 2
Find a) list[1:3] b) t[:4] c)
t[3:] .
5 Mention any 5 list methods. List Methods BTL 1 2
6 State the difference between
List,Dictionary BTL 4 2
lists and dictionary.
7 How list differs from tuple. Tuple BTL 4 2
8 How to slice a list in
Slice BTL 3 2
Python.
9 Write python program for
swapping two numbers Swapping BTL 1 2
using tuple assignment?
10 What is list loop? List BTL 1 2
11 What is mapping? Tuple BTL 1 2
12 Give a function that can
take a value and return the
Dictionary BTL 6 2
first key mapping to that
value in a dictionary.
13 How to create a list in
Indexing BTL 2 2
python? Illustrate the use of
negative indexing of list
with example.
14 Demonstrate with simple
code to draw the histogram Looping BTL 5 2
in python.
15 How will you update list
List BTL 5 2
items? Give one example.
16 Can function return tuples?
Tuple BTL 5 2
If yes Give examples.
17 List
Define List Comprehension. BTL 1 2
Comprehension
18 What is the benefit of using
Tuple BTL 1 2
tuple assignment in Python?
19 Define dictionary with an
Dictionary BTL 2 2
example.
20 What is aliasing in list?
Alising BTL 2 2
Give an example.
21 What is [:] in Python? Slicing BTL 1 2
22 What is 2 :] in Python? Slicing BTL 2 2
23 State the difference between
Tuple,Dictionary BTL 4 2
tuple and dictionary.
24 How do you replace values
List BTL 3 2
in a list in Python?
25 What is traversing in
Traversing BTL 2 2
Python with an example?
PART-B
Explain in detail about lists,
list operations and list List BTL 4 16
1.
slices.(16 Mark)
Explain in detail about
mutability and tuples with a Tuple BTL 2 16
2.
Python program. (16 Mark)
What is tuple assignment?
Explain it with an example. Tuple BTL 3 8
3.
(8 Mark)
Discuss Tuple,Argument
4. BTL 2 16
a)Tuple as return values(8
Mark)
b)Variable length argument
tuples (8 Marks)
Explain in detail about
dictionaries and its
operations.(or)What is a Dictionary BTL 4 16
5.
dictionary in Python? Give
example. (16 Mark)
Illustrate set operations with Set
6. BTL 3 8
an example.(8 Mark)
Explicate string functions in
String BTL 4 8
7. detail.(8Mark)
Explain search and replace Regular
8. the elements in python(16 BTL 2 16
Expression
Mark)
Demonstrate with code the
various operations that can Tuple
9. BTL 4 16
be performed on tuples. (16
Mark)
(a) Define Dictionary in
python. Do the following
operations on dictionaries.
(16 Mark)
i) Initialize two dictionaries
with key and value pairs.
ii) Compare two
dictionaries with master key
list and print missing keys. Dictionary BTL 3 16
10.
iii) Find keys that are in
first and not in second
dictionary.
iv) Find same keys in two
dictionaries.
v) Merge two dictionaries
and create a new dictionary
using a single expression.

UNIT IV
Files: Open, Read, Write, Append, Tell, Seek and Close. Errors and Exceptions: Syntax Errors,
Exceptions, Handling Exceptions, Raising Exceptions, Exception Chaining, User-defined Exceptions,
Defining Clean-Up actions
[Link]. Question Topic BTL Mark
Part A
1. What is the difference between reading a file in binary Files BTL1 2
mode and text mode in Python?

What does the `with` statement do when working with


2. Files BTL1 2
files in Python?
What is the difference between `read()` and `readline()`
3. Files BTL1 2
methods in file handling?
What will happen if you try to write to a file that was
4. Files BTL1 2
opened in read mode?
Write a Python code to open a file named `[Link]` in
5. Files BTL1 2
read mode and print its content.
6. What is the purpose of the `try-except` block in Python? Exception BTL1 2
What is the role of the `finally` block in exception
7. Exception BTL1 2
handling?
What is the output of the following code?
try:
print(5 / 0)
8. Exception BTL2 2
except ZeroDivisionError:
print("Cannot divide by zero!")

Predict the output of this code:


def test_exception():
try:
return 1
9. finally: Exception BTL2 2
return 2

print(test_exception())

What will be the output of the following code?


try:
raise KeyError("Key not found")
10. Exception BTL1 2
except KeyError as e:
print(e)

Predict the output of the following code:


try:
x = [1, 2, 3]
11. print(x[5]) Exception BTL2 2
except IndexError:
print("Index out of range!")

Predict the output of the following code:


try:
print("Start")
raise Exception("An error occurred")
12. except Exception as e: Exception BTL2 2
print(e)
finally:
print("End")
What is a user-defined exception in Python, and why
13. Exception BTL1 2
would you create one?
What will the following code print?
try:
x = {'a': 1}
print(x['b'])
14. except KeyError: Exception BTL2 2
print("Key not found!")
finally:
print("Execution completed.")

What will be printed by this code?


try:
lst = [10, 20, 30]
[Link](50)
15. except ValueError: Exception BTL2 2
print("Value not found!")
finally:
print("Finished!")

Why is it important to define clean-up actions in Python


16. Clean Up BTL2 2
code?
What happens if a `return` statement is present in both the
17. `try` and `finally` blocks? Exception BTL1 2

Predict the output of the following code:


def test():
try:
return "From try"
18. finally: Exception BTL2 2
return "From finally"

print(test())

What will be the output of the following code?


try:
print("Open connection")
19. raise Exception("Some error") Exception BTL2 2
finally:
print("Close connection")

Explain how to open a file in append mode and write a


20. Files BTL1 2
line of text.
21. Write Python code to count the number of lines in a file. Files BTL 3 2
22. How do you create a custom exception class in Python? Exception BTL 1 2
What happens if a user-defined exception is not raised in
23. Exception BTL 2 2
the program?
What will happen if you try to write to a file that was
24. Files BTL 1 2
opened in read mode?
25. Write Python code to count the number of lines in a file. Files BTL 3 2
Part – B
1. a) i) What is the default mode for opening a file in Python
using the `open()` function?
- a) Read mode (`'r'`)
- b) Write mode (`'w'`)
- c) Append mode (`'a'`)
- d) Binary mode (`'rb'`)

ii) Which of the following modes is used to open a file for


both reading and writing?
- a) `'r'`
- b) `'w+'`
- c) `'a'`
- d) `'x'`

iii) What does the `close()` method do in Python file


handling?
- a) Closes the file and flushes any unwritten data to
disk.
- b) Deletes the file.
- c) Reopens the file in write mode.
- d) Copies the file to a backup location.

iv) Which method is used to read the entire contents of a


file in Python as a string?
- a) `readline()` Files BTL2 16
- b) `readlines()`
- c) `read()`
- d) `readall()`

v) What will happen if you try to open a file in `'w'` mode


that already exists?
- a) It will raise an error.
- b) It will append content to the file.
- c) It will overwrite the existing file.
- d) It will open the file in read-only mode.

vi) In which mode is a file opened for both reading and


writing in binary format?
- a) `'rb'`
- b) `'wb'`
- c) `'rb+'`
- d) `'w'`

vii) Which of the following is a correct way to write a list


of lines into a file in Python?
- a) `[Link](list_of_lines)`
- b) `[Link](list_of_lines)`
- c) `[Link](lines)`
- d) `[Link](list_of_lines)`
viii) What does the `seek()` function do in file handling?
- a) Moves the file cursor to a specified position.
- b) Returns the current position of the file cursor.
- c) Closes the file after seeking data.
- d) Reads the file contents from the current position.

b) i) Write a Python program that:


- Opens a file named `[Link]` in write mode.
- Writes the following content to the file:
```
Line 1: Hello, World!
Line 2: Welcome to Python file handling.
Line 3: This is the third line.
```
- Closes the file after writing.

ii) Write a Python program that:


- Opens a file named `[Link]` in read mode.
- Reads all the contents of the file line by line and prints
each line to the console.
- Closes the file after reading.

2. a) Explain about the different types of Exceptions in


Python. b) Describe about Handling Exceptions BTL2 16
Exceptions in detail with examples.
3. Explain in detail about Python Files, its types, functions
and operations that can be performed on files with Files BTL3 16
examples.
4. a) Define what is meant by a "clean-up action" in Python
programming. Discuss the importance of clean-up
actions, especially in the context of resource management
(e.g., file handling, network connections, etc.).

b) Write a Python program that demonstrates the use of


both the try-except-finally block and the with statement to
handle clean-up actions. Your program should:
Clean Up BTL4 16
1. Read from a text file, handle potential errors (like
file not found), and ensure the file is always
closed properly.
2. Use the with statement to write some content to a
new file.

5. Write a python program to count the number of uppercase


Files BTL3 16
alphabets present in a text file “[Link]”
6. Write a program to read details of students for result
preparation. Incorporate all possible exception-handling Exceptions BTL 3 16
codes such as ValueError, IndexError, ZeroDivisionError,
User-defined Exception.
7.
Write a function show_words() in python to read the
contents of a text file ‘[Link]’ and display only such Files BTL 3 16
file which have exactly 5 words in them.
8.
Write a function to read a Time class object storing hours
and minutes. Raise a user-defined error if values other Exceptions BTL 3 16
than 0.23 is entered for hours and other than 0.59 is
entered for minutes
9. Write a program that reads a text file and creates another
file that is identical except that every sequence of File BTL 3 16
consecutive blank spaces is replaced by a single space.
10 A file contains a list of telephone numbers in the
following form:
Arvind 7258931
Sachine 7259197
File BTL 3 16
The names contain only one word the names and
telephone numbers are separated by white spaces.
Write a program to read a file and display its contents in
two columns.

UNIT V
Introduction – Basics of NumPy – N-dimensional Array in NumPy – Methods ans Properties,
Basics of Scipy – Broadcasting in NumPy Array Operations – Array Index in Numpy, Pandas - Introduction –
Series – Data Frame- Matplotlib Basics – Figures and Axes – Method subplot() – Axis Container.
[Link]. Question Topic BTL Mark
Part A
1 How to Create an empty and a full NumPy Array? NumPy BTL1 2
2 Find the most frequent value in a NumPy Array? NumPy BTL1 2
What is the difference between a python list and a NumPy
3 NumPy BTL1 2
Array/
4 How do you check the shape and size of a NumPy Array? NumPy BTL1 2
5 What is broadcasting in NumPy? NumPy BTL1 2
6 What are the methods of NumPy in Python? Methods BTL1 2
7 How can you reverse a NumPy array? Array BTL1 2
8 How does try and execute work? Try BTL2 2
9 How are NumPy arrays better than Pythons List? NumPy BTL2 2
10 What is SciPy?Why use SciPy? SciPy BTL1 2
11 Explain Constants in SciPy? SciPy BTL2 2
12 Mention the different types of Data Structures in Pandas? Pandas BTL2 2
13 Define dataframes in Pandas? Pandas BTL1 2
14 How do you create a basic plot in Matplotlib? Matplotlib BTL2 2

What is the difference between plot,axes, and fugure with an


15 Matplotlib BTL2 2
example?

How can you check weather a pandas DataFrame Is empty


16 Data Frames BTL2 2
or not?
17 What is subplots in matplotlib? Matplotlib BTL1 2
Why need data visualization?what are the benefits in it? Data
18 BTL2 2
visualization
19 Write the important functions of Matplotlib? Matplotlib BTL2 2
20 How to Copy NumPy array into another array? NumPy BTL1 2
Absolute Deviation and Absolute Mean Deviation using
21 NumPy BTL 3 2
NumPy
22 Variations in different sorting techniques in Python Sorting BTL 1 2
Convert an image to NumPy array and save it to CSV file NumPy
23 BTL 2 2
using Python? Array
24 How to install python pandas on macOS? Pandas BTL 1 2
25 Define seaborn? Pandas BTL 3 2
Part – B
1 (a).What is NumPy?why should we use it?(8 MarK)
(b).How do you convert pandas DataFrame to a NumPy
array? Pandas BTL2 16
(8 Mark)
2 (a). How can you reverse a NumPy array? (8 Mark)
(b). How do you find the data types of the elements stored in NumPy BTL2 16
the NumPy arrays?(8 Mark)
3 What is SciPy?. How does data analysis work with
SciPy BTL3 16
SciPy?(16 Mark)
4 Explain NumPy basic arithmetic operations?what are the
NumPy BTL4 16
rules for NumPy broadcasting? (16Mark)
5 [Link] NumPy array elements that doesnot satisfy the
given condition(8 Mark) NumPy BTL3 16
[Link] a program to illustrate matplotlib Bacics? (8 Mark)
6 Write a Python program for Python subplots Matplotlib?
Matplotlib BTL 3 16
(16 Mark)
7 (a). Describe methods and properties of Ndimensional in
array in NumPy. (8 Mark) NumPy BTL 3 16
(b). Describe Basics of Scipy. (8 Mark)
8 SciPy BTL 3 16
Write a program to illustrate multiple modules. (16 Mark)
9 Explain the following:
User defined
(a). Predefined Modules (8 Mark) BTL 3 16
function
(b). User defined Modules. (8 Mark)
10 Write a Python program to dump objects to a file using User defined
BTL 3 16
pickle. (8 Mark) function

You might also like