Python Programming - Theory-Based Questions
Unit-I: Basics of Python
- Explain the programming cycle for Python.
- What is the role of the Python IDE in programming?
- Describe different types of Python variables and their properties.
- What are expressions in Python? Provide examples.
- Explain the precedence of arithmetic operators with an example.
- What is a Boolean expression? Discuss its use in Python programs.
Unit-II: Conditional Program Execution
- Write a Python program to demonstrate the use of `if`, `if-else`, and `nested if-else` statements.
- Compare and contrast the `for` loop and `while` loop in Python.
- What is a nested loop? Provide an example in Python.
- Explain the properties of lists in Python.
- How do you access and modify elements in a list?
- What are tuples? Explain their properties with an example.
- Discuss the difference between lists and tuples in Python.
- What are dictionaries? How can values be accessed and modified in a dictionary?
Unit-III: Strings and Functions
- What are string slices? Provide examples.
- Discuss the different methods available for string manipulation in Python.
- Define a function in Python. What are its components?
- Differentiate between global and local variables in Python with examples.
- What are anonymous functions? Provide an example of how they can be used.
- Describe the types of arguments that can be passed to a Python function.
Unit-IV: OOP Concepts
- Define classes and objects in Python with examples.
- What is the purpose of instance methods in Python?
- Explain the concept of inheritance with an example.
- Differentiate between polymorphism and method overloading in Python.
- What are exception classes? How can custom exceptions be created in Python?
- How does method overriding work in Python? Provide an example.
- Discuss the role of data hiding in Python object-oriented programming.
Unit-V: File Handling and Searching
- Explain the steps involved in opening and closing a file in Python.
- Write a Python program to read and write files.
- Discuss the differences between binary and text files in Python.
- Explain the concept of merge sorting with an example program.
- How does binary search differ from linear search in terms of implementation?
- Write a Python program to implement insertion sort.
- What is selection sort? Provide a step-by-step explanation of its working.