Python Interview Questions – Introduction
Q1. [Asked in TCS]: What is Python and why is it so popular?
Python is a high-level, interpreted programming language known for its simple syntax and readability. It supports multiple programming paradigms like object-oriented, procedural, and functional programming.
Python is popular because:
- It’s beginner-friendly
- It has a vast number of libraries and frameworks
- It’s used in various fields like web development, AI, data science, automation, and more
Q2. [Asked in Wipro]: What are some key features of Python?
Key features of Python include:
- Easy-to-read syntax
- Dynamically typed
- Interpreted language
- Large standard library
- Open-source and community-supported
- Cross-platform compatibility
Q3. [Asked in Infosys]: Is Python compiled or interpreted? Explain.
Python is an interpreted language. This means Python code is executed line by line by the Python interpreter, and it doesnโt need to be compiled before running. This helps in faster testing and debugging.
Q4. [Asked in Capgemini]: What do you mean by dynamically typed language? How does it apply to Python?
In a dynamically typed language like Python, you donโt need to declare the type of variable while writing the code. The interpreter automatically determines the data type at runtime.
Example:
x = 10 # integer
x = "Hi" # now x is a string
Q5. [Asked in Cognizant]: What is the difference between Python 2 and Python 3?
Python 3 is the future and actively maintained version, while Python 2 is deprecated.
Key differences:
| Feature | Python 2 | Python 3 |
|---|---|---|
| Print syntax | print "Hello" | print("Hello") |
| Division | Integer division | True division |
| Unicode | Not default | Default support |
Q6. [Asked in Accenture]: What are some real-world applications of Python?
Python is used in many domains:
- Web Development (Django, Flask)
- Data Science and AI (NumPy, Pandas, TensorFlow)
- Automation/Scripting
- Game Development
- Desktop Applications
- Cybersecurity
Q7. [Asked in Amazon]: What is the difference between a Python script and a Python interactive shell?
- Python Script: A file with
.pyextension that contains Python code and can be executed all at once. - Python Shell: An interactive environment (like IDLE or command line) where you can write and execute one line at a time.
Q8. [Asked in Google]: Can Python be used for both frontend and backend development?
Python is mostly used for backend development, especially with frameworks like Django or Flask. It’s not ideal for frontend (UI/UX) tasks, which are better handled by HTML, CSS, and JavaScript.
Q9. [Asked in IBM]: How does Python handle memory management?
Python handles memory using:
- Automatic Garbage Collection
- Reference Counting
- Private heap space for managing memory allocation
All this is managed internally by the Python memory manager.
Q10. [Asked in Microsoft]What are Python packages and modules?
- A module is a single Python file that can include functions, classes, or variables.
- A package is a collection of modules grouped together using a directory with an
__init__.pyfile.
