24CSE402 PYTHON PROGRAMMING
QUESTION BANK
Unit 1: Computational Thinking
1. Define computational thinking.
2. What is an algorithm?
3. Mention two building blocks of an algorithm.
4. What is pseudo code? Give an example.
5. Differentiate between a flowchart and pseudocode.
6. Define control flow with an example.
7. What is recursion?
8. What is iteration in algorithm design?
9. What do you mean by the "state" in algorithms?
10. Write any two characteristics of a good algorithm.
Unit 2 Data Types, Expressions, Statements
1. What is the use of Python interactive mode?
2. Define int and float with example.
3. Write the syntax for tuple assignment in Python.
4. What is the precedence of operators?
5. Write any two differences between list and tuple.
6. What are expressions and statements?
7. Define Boolean data type with an example.
8. What is the output of type(3.14)?
9. Write a short note on comments in Python.
10. What is debugging?
Unit 3: Control Flow, Functions, Strings
1. What is a chained conditional? Give example.
2. Define break and continue statements.
3. What is the difference between while and for loop?
4. Define global and local variables.
5. What is function composition?
6. Give an example of a fruitful function.
7. What is string immutability?
8. What does len("hello") return?
9. Write syntax to slice a string in Python.
10. What is the use of pass statement?
Unit 4: Lists, Tuples, Dictionaries
1. Define a list and write an example.
2. What is list aliasing?
3. Write two list methods and their usage.
4. What is list comprehension?
5. Define tuple with example.
6. Write syntax for dictionary creation.
7. Mention any two dictionary methods.
8. What is list cloning?
9. Differentiate between list and dictionary.
10. What is mutability in lists?
Unit 5 Files, Modules, Packages
1. Write the syntax for opening a file in read mode.
2. What is the use of with statement in file handling?
3. Define exceptions in Python.
4. What is a module?
5. What is a package?
6. Write syntax for importing a module.
7. Define command line arguments.
8. What is the purpose of the try-except block?
9. Give an example of format() operator.
10. Mention two types of errors in Python.
PART B
1. Explain the building blocks of algorithms with examples: statements, state, control flow, and
functions.
2. Describe the various methods of representing algorithms: pseudocode, flowchart, and programming
languages.
3. Discuss algorithmic problem solving with examples.
4. Explain recursion and iteration with examples. Compare them.
5. Write algorithms for the following problems and explain the logic:
Finding the factorial of a number
Checking if a number is prime
UNIT 2
1. Discuss the Python interpreter and interactive mode. Also, explain debugging techniques.
2. Explain the data types in Python: int, float, boolean, string, and list, with examples.
3. What are variables, expressions, and statements in Python? Explain with examples.
4. Describe tuple assignment and operators and precedence with examples.
UNIT 3
1) Discuss different types of conditionals in Python with examples (if, if-else, if-elif-else).
2) Explain iteration in Python using while and for loops. Include break, continue, and pass.
3) Write about fruitful functions with return values, parameters, scope, and recursion.
4) Explain string slicing, immutability, and string functions/methods in detail with examples.
5) How are strings and lists used together in Python? Discuss with code examples.
UNIT 4
1) Describe list operations, list slicing, and list methods with examples.
2) Explain mutability, aliasing, and cloning of lists with examples.
3) Discuss tuple creation, tuple assignment, and using tuples as return values in functions.
4) Explain dictionary creation, operations, and methods with examples.
5) What is list comprehension? Write Python programs using list comprehension for different use
cases.
UNIT 5
1) Explain file handling in Python. How are text files opened, read, and written?
2) Discuss errors and exception handling in Python with examples using try, except, finally.
3) What is the use of the format() operator? Illustrate with examples.
4) Describe the creation and usage of modules and packages in Python.
5) Write a Python program to read a text file, count the number of lines, words, and characters. Explain
the code.
Some important programs to study
1. Write an algorithm and flowchart to find the largest of two numbers.
2. Write a Python program to find the factorial of a number using both iteration and recursion.
3. Write a Python program to generate the Fibonacci series up to n terms using iteration.
4. Write a Python program to add two numbers and display the result.
5. Write a Python program to demonstrate tuple assignment (e.g., swapping twovariables).
6. Write a program to display data types of int, float, boolean, string, and list variables using type().
7. Write a Python program to check whether a number is positive, negative, or zero using if-elif-else.
8. Write a function to find the maximum of two numbers and return the result.
9. Write a Python program to reverse a string and check if it is a palindrome.
10. Write a Python program to create a list, add elements, and sort it.
11. Write a Python program to count the frequency of each character in a string using a dictionary.
12. Write a Python function that returns multiple values as a tuple (e.g., min and max of a list).
13. Write a Python program to read a text file and count the number of lines and words.
14. Write a Python program to handle exceptions (e.g., divide by zero).
15. Write a Python module with basic math functions and use it from another file.