0% found this document useful (0 votes)
84 views2 pages

Python Programming Exam Question Bank

This document contains a question bank with 35 questions related to algorithms, Python programming concepts like data types, functions, files, exceptions, recursion, classes, and more. The questions are divided into two parts - Part A contains conceptual questions to test understanding of Python concepts while Part B focuses on writing Python programs and explaining concepts in detail with examples. This question bank can be used to prepare for model examinations to assess students' knowledge of problem solving using algorithms and Python programming.
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)
84 views2 pages

Python Programming Exam Question Bank

This document contains a question bank with 35 questions related to algorithms, Python programming concepts like data types, functions, files, exceptions, recursion, classes, and more. The questions are divided into two parts - Part A contains conceptual questions to test understanding of Python concepts while Part B focuses on writing Python programs and explaining concepts in detail with examples. This question bank can be used to prepare for model examinations to assess students' knowledge of problem solving using algorithms and Python programming.
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

KGISL INSTITUTE OF TECHNOLOGY

DEPARTMENT OF SCIENCE AND HUMANITIES


Problem Solving and Python Programming
Model Examinations Question Bank

PART A

1. Define Algorithm.
2. What is Recursion?
3. What is pickling in Python.
4. What is an exception? Give an example.
5. Define function composition.
6. Define Algorithm. State some of the properties of the good algorithm.
7. State the difference between Recursion and Iteration
8. Define File.
9. What is exception? Give an example.
10. Write a python program to find factorial of a given number
11. Compare mutable objects with immutable objects. Give examples
12. What is anonymous function in Python?
13. Classify global variable with a local variable.
14. What is a list? How to slice a list in Python?
15. What is tuple packing and unpacking?
16. Differentiate Arguments and Parameters.
17. List out the various data types available in python.
18. Mention few string Methods.
19. What is list comprehension? Give an example.
20. Define dictionary with example.

PART B

1. Outline the Towers of Hanoi problem. Suggest a Solution to the Towers of Hanoi problem with
relevant diagrams.
2. Explain the various symbols used in flowchart and draw a Flowchart to determine the square root of
number using Newton’s Method.
3. Give pseudo code and draw flowchart to accept three distinct numbers, find the greatest and print
the result
4. Explain in detail about various data types supported by Python language with examples.
5. Write a Python program to find whether a number is prime or not.
6. Explain briefly about various operators available in python
7. What are the steps involved in solving a problem using an algorithm? Discuss each step
briefly.
8. Write a Python program to store ‘n’ numbers in a list and sort the list using selection sort.
9. Explain in detail about tuples and its operations with examples.

10. Write a Python program to multiply two matrices.


11. Discuss the different modes for opening a file and closing a file.
12. Explain in detail about building blocks of an algorithm.
13. What are functions? Explain about the types of functions based on arguments.
14. Explain briefly about various conditional and looping statements with suitable examples.
15. Describe about strings and explain various string methods with syntax and example.
16. Explain in detail about various list methods with examples.
17. Elaborate on operators in Python.
18. Outline the operator precedence of arithmetic operators in Python.
19. Write a Python program to copy contents of one file to another .
20. Describe in detail how exceptions are handled in Python. Give relevant examples.
21. Write a Python program to rename a given file.
22. Explain with an example to while loop, break statement and continue statement in Python.
23. Write a Python program to generate first ‘N’ Fibonacci numbers.
24. Explain in detail about dictionaries and its methods with examples.
25. Explain in detail about tuple and its operations with examples
26. Explain in detail about data types supported y Python language with examples.

27. Write a Python program to find whether the given year is leap or not.
28. Explain in detail about dictionaries and its methods with examples for each method.
29. Discuss the different modes for opening a file and closing a File.
30. Give the pseudo code and flowchart for inserting a card in a list of sorted cards
31. Give the pseudo code and flowchart for finding minimum of a list.
32. Explain in detail about conditional statements in Python with necessary examples
33. Write a Python program to perform binary search.
34. Write a Python program to copy the contents of one file to another File.
35. Describe in detail how exceptions are handled in Python. Give relevant examples.
36. Write a python program to rename a given file and display it’s content in the Console

Common questions

Powered by AI

Python handles exceptions using try-except blocks, allowing programmers to manage errors gracefully and maintain control flow. The try block contains code that might cause an exception, while the except block handles the error. This mechanism is crucial for avoiding program crashes and provides a way to handle unforeseen errors, thus enhancing program robustness .

Understanding data types in Python is crucial because it affects memory usage and performance. Different data types like int, float, and str have varying memory allocations; incorrect type usage can lead to inefficient resource use and errors. Knowledge of data types helps in selecting appropriate operations and ensures reliable data manipulation, significantly impacting program reliability and efficiency .

Local variables are defined within a function scope and accessible only within that function, preventing unintended interactions with code outside the function. Global variables are defined outside any function and accessible throughout the program, allowing for shared state across functions. While global variables can simplify data sharing, excessive use can lead to code that is difficult to maintain and potential side effects from unintended variable modifications .

Mutable objects, such as lists and dictionaries, can be changed after creation, allowing for dynamic data manipulation. Immutable objects, like tuples and strings, cannot be altered, promoting data integrity by preventing accidental changes. These differences influence program design; mutable objects provide flexibility for algorithms requiring state changes, while immutable objects are suitable for fixed data scenarios, enhancing reliability and security of data handling .

In Python, parameters are the variables listed inside the parentheses in the function definition, while arguments are the values passed to the function when it's called. This distinction allows for flexible function design, enabling parameterized operations and reusability of functions. Understanding this helps in correct function usage, avoiding argument mismatch errors, and designing functions that can handle different data and scenarios effectively .

Recursion involves a function calling itself to solve smaller instances of a problem, useful for tasks like file directory traversal or recursive mathematical computations. Iteration uses loops to repeat code, often more efficient in terms of space for tasks such as summation. While recursion offers simpler, more elegant solutions for problems with natural recursive structures, it can lead to stack overflow if not careful with base cases. Iteration avoids recursion depth limits but can be less intuitive for problems that are naturally recursive .

Dictionaries in Python offer fast lookups, insertion, and deletion due to their hash table implementation. They store data as key-value pairs, allowing intuitive data management. Methods like get() provide default outputs for missing keys, update() merges entries, and keys(), values() allow easy iteration over their elements. This versatility in handling complex data structures enhances productivity and efficiency in data operations .

Tuple packing involves grouping multiple values into a single tuple, allowing for compact data storage. Unpacking extracts these values into separate variables. For example, a = (1, 2) is packing, and x, y = a is unpacking. This process is significant in Python because it simplifies variable assignments, enhances code readability, and efficiently passes multiple values between functions .

A good algorithm has key properties: definiteness, finiteness, input, output, and effectiveness. Definite steps ensure no ambiguity in execution. Finiteness ensures that the algorithm terminates after a finite number of steps. Acceptable input and output specify the kinds and limitations of data involved. Effectiveness means the steps are basic enough to be carried out. These properties ensure the algorithm's reliability and efficiency in problem-solving .

List comprehension in Python provides a concise way to create lists by embedding a loop and optional condition in a single line of code. For example, [x**2 for x in range(10) if x % 2 == 0] generates a list of squares of even numbers from 0 to 9. This method enhances code readability and is efficient in executing transformations and filtering operations on data collections .

You might also like