input: What is Python?

output: Python is a high-level, interpreted programming language known for its simplicity and readability. It supports multiple programming paradigms including procedural, object-oriented, and functional programming.


input: Explain recursion

output: Recursion is a programming technique where a function calls itself to solve a problem by breaking it down into smaller subproblems. Base cases prevent infinite recursion. Example: factorial(n) = n * factorial(n-1) for n > 1, else 1.


input: What are decorators in Python?

output: Decorators are functions that modify or wrap other functions or classes without permanently changing their source code. They use the @ symbol and are executed when the function is defined. Example: @staticmethod, @property, or custom decorators.


input: How do you handle exceptions in Python?

output: Exceptions are handled using try-except-else-finally blocks. The try block contains code that might raise an exception, except catches specific exceptions, else runs if no exception occurred, and finally runs regardless. Custom exceptions can be created by inheriting from Exception.


input: What is the difference between lists and tuples?

output: Lists are mutable (can be changed after creation) while tuples are immutable (cannot be changed). Lists use square brackets [] and tuples use parentheses (). Both can contain mixed data types. Tuples are faster and can be used as dictionary keys.