Loading...
Follow Us:

Python

Python

1. What is Python?

A high-level, interpreted programming language known for its readability and versatility.

2. What are Python's built-in data types?

int, float, str, list, tuple, set, dict, and bool.

3. What is the difference between append() and extend()

append() adds an item to the end of a list; extend() adds items from an iterable.

4. What is a function in Python?

A block of code that performs a specific task and can be reused.

5. What is a lambda function?

An anonymous function defined with the lambda keyword.

6. What are control flow statements?

Statements that dictate the flow of execution (e.g., if, for, while).

7. What is list comprehension?

A concise way to create lists using a single line of code.

8. What is the purpose of the break statement?

To exit the nearest enclosing loop.

9. What is function overriding?

Redefining a method in a derived class.

10. What is a default argument?

A parameter that assumes a default value if no argument is passed.

11. What is scope in Python?

The visibility of variables in certain parts of the code (local, global, and nonlocal).

12. What is a module?

A file containing Python code (functions, classes, variables) that can be imported.

13. What is a package?

A directory that contains multiple modules and an __init__.py file.

14. What is the purpose of import?

To bring modules or packages into the current namespace.

15. What is an exception?

An error that occurs during program execution.

16. What is the purpose of the try and except blocks?

To catch and handle exceptions gracefully.

17. What is the difference between raise and assert?

raise triggers an exception; assert tests a condition and raises an AssertionError if false.

18. What is a custom exception?

A user-defined exception class that extends the base Exception class.

19. What is file handling in Python?

The process of reading from and writing to files using Python's built-in functions.

20. What is with statement?

A context manager that automatically handles resource management, such as file closing.

21. What is OOP?

Object-Oriented Programming, a paradigm based on objects that combine data and functionality.

22. What are the four pillars of OOP?

Encapsulation, inheritance, polymorphism, and abstraction.

23. What is a decorator?

A function that modifies the behavior of another function or method.

24. What is a generator?

A special type of iterator that generates values on the fly using the yield statement.

25. What is multithreading?

A technique that allows multiple threads to run concurrently within a single process.

26. What is multiprocessing?

A technique that allows multiple processes to run simultaneously, taking advantage of multiple CPU cores.

27. What is a REST API?

An architectural style for designing networked applications that use HTTP requests.

28. What is JSON?

A lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate.

29. What is web scraping?

The process of extracting data from websites using code.

30. What is a virtual environment?

A self-contained directory that contains a Python installation for a particular version of Python, used to manage project dependencies.

31. What are the benefits of using Python?

Readability, versatility, large community support, and a rich set of libraries.

32. What are Python's limitations?

Slower execution speed compared to compiled languages, higher memory consumption, and not suitable for mobile app development.

33. What is dynamic typing?

The type of a variable is determined at runtime, allowing for more flexibility.

34. What is the difference between shallow copy and deep copy?

A shallow copy creates a new object but inserts references into it; a deep copy creates a new object and recursively copies all nested objects.

35. What is Pythonic code?

Code that follows the idioms and conventions of the Python language.

36. What is metaprogramming?

Writing programs that manipulate or generate code at runtime.

37. What is the purpose of super()?

To call a method from the parent class.

38. What are class methods?

Methods that receive the class as the first argument instead of an instance.

39. What are static methods?

Methods that do not receive an implicit first argument and can be called on the class itself.

40. What is a proxy?

A design pattern that provides a surrogate or placeholder for another object.

41. What is a singleton?

A design pattern that restricts the instantiation of a class to one object.

42. What is duck typing?

A concept that determines an object's suitability based on its methods and properties rather than its type.

43. What is the difference between == and is?

== checks for value equality; is checks for identity (same object).

44. What is a callable in Python?

An object that can be called like a function (e.g., functions, methods, classes).

45. What is the purpose of the return statement?

To exit a function and optionally pass back an expression to the caller.


WhatsApp
Enquiry