IBM – Python Interview Questions
Here is the list of Python Interview Questions which are recently asked in IBM company. These questions are included for both Freshers and Experienced professionals. Our Python Training has Answered all the below Questions.
1. What is Python?
Python is a high-level, interpreted, interactive and object-oriented scripting language that is used to create user interface applications for web development (server side), software development, mathematics, operation and so on. . It uses English keywords frequently with fewer syntactical constructions than other languages.
2. What are the benefits of Python?
Easier to learn, write and understand the code - Python is really easy to pick up and learn similar to English language, so lot of people recommend Python to beginners.
Improved Productivity - Due to the simplicity of Python, developers can focus on solving the problem by writing less code and more time on productivity.
Interpreted Language - Python executes the code directly in a line by line manner.
Dynamically Typed - It automatically assigns the data type during execution.
Free and Open-Source – Python is a OSI approved open-source which makes it free to use.
Vast Libraries Support - The standard library of Python is huge with almost all the functions needed for your task without the use of external libraries.
Portability - You only write once and run it anywhere.
3. What are the key features of Python?
- Easy to Code, Read
- Expressive, Free and Open-Source
- Portable, high-level language
- Embeddable, Object-Oriented
- Large Standard Library
- Dynamically Typed with GUI Programming
4. What type of language is Python? Programming or Scripting?
Python is considered a scripting language because of a historical blur between scripting languages and general purpose programming languages. In fact, Python is not a scripting language, but a general purpose programming language that also works nicely as a scripting language. It is also an interpreted and high-level programming language for the purpose of general programming requirements.
5. What are the applications of Python?
- Web and Internet Development
- Scientific and Numeric Applications
- Education and training programs
- Artificial intelligence and Machine learning
- Software and Game Development
- Business Application
6. What is the difference between list and tuple in Python?
The most important differences between list and tuple is that list is mutable, whereas a tuple is immutable. This means that lists can be changed, and tuples cannot be changed.
7. What are the global and local variables in Python?
There are two types of variables: global variables and local variables. The scope of global variables is the entire program whereas the scope of local variables is limited to the function where it is defined.
8. Define PYTHON PATH?
PYTHONPATH is an environment variable which the user can set to add additional directories that the user wants Python to add to the sys. Path directory list. ... So, when you import modules in your Python scripts, PYTHONPATH is also checked to see which directories might contain the imported module.
9. What are the two major loop statements?
The group of statements being executed repeatedly is called a loop. There are two loop statements in Python: for and while.
10. What do you understand by the term PEP 8?
PEP stands for Python Enhancement Proposal which is a design document that provides guidelines and best practices on how to write Python code. The primary focus of PEP 8 is to improve the readability and consistency of Python code.
11. How memory management is done in Python?
Memory management in Python involves a private heap containing all Python objects and data structures. The management of this private heap is ensured internally by the Python memory manager.
12. Define slicing in Python?
The slice() function returns a slice object. A slice object is used to specify how to slice a sequence. You can specify where to start the slicing, and where to end. You can also specify the step, which allows you to e.g. slice only every other item.
13. Which command is used to delete files in Python?
In Python, you can use the os. remove() method to remove files, and the os. rmdir() method to delete an empty folder. If you want to delete a folder with all of its files, you can use the shutil.
14. Define the term lambda?
In Python, a lambda function refers to a small anonymous function. We call them “anonymous functions” because technically they have no name. Unlike a normal function, we do not define it with the standard keyword def that we use in Python
15. Why do we use the split method in Python?
Split Function is In-Build function of Python String Data Type, The Main purpose of split data type is to separate the string into different elements, and the separated string will actually store in the format of List data type.
16. How memory management is done in Python?
17. Define modules in Python?
A module is a file containing Python definitions and statements. A module can define functions, classes, and variables. A module can also include runnable code. Grouping related code into a module makes the code easier to understand and use.
18. What are the built-in types available in Python?
Python uses five numeric types: Booleans, integers, long integers, floating-point numbers, and complex numbers. Except for Booleans, all numeric objects are signed.
19. What are Python Decorators?
Decorators are a very powerful and useful tool in Python since it allows programmers to modify the behaviour of function or class. Decorators allow us to wrap another function in order to extend the behaviour of the wrapped function, without permanently modifying it.
20. How do we find bugs and statistical problems in Python?
Pychecker and Pylint are the static analysis tools that help to find bugs in python.
Pychecker is an open source tool for static analysis that detects the bugs from source code and warns about the style and complexity of the bug.
21. What is the difference between .py and .pyc files?
py files contain the source code of a program. Whereas,. pyc file contains the bytecode of your program.
22. Define String in Python?
String is an array of sequenced characters and is written inside single quotes, double quotes or triple quotes. Also, Python doesn't have character data type, so when we write 'a', it is taken as a string with length 1.
23. What do you understand by the term namespace in Python?
A namespace is a system that has a unique name for each and every object in Python. An object might be a variable or a method. Python itself maintains a namespace in the form of a Python dictionary.
24. How do you create a Python function?
Function blocks begin with the keyword def followed by the function name and parentheses (( )). Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.
25. Write a program to display the Fibonacci sequence in Python?
def Fibonacci(n): # Check if input is 0 then it will # print incorrect input if n < 0: print("Incorrect input") # Check if n is 0 # then it will return 0 elif n == 0: return 0 # Check if n is 1,2 # it will return 1 elif n == 1 or n == 2: return 1 else: return Fibonacci(n-1) + Fibonacci(n-2) # Driver Program print(Fibonacci(9))
26. What is the output of the following code?
27. List the features of Django?
- Highly Secure Web Framework.
- Suitable For High Load Projects: Scalability.
- A Framework With Versatile Functioning.
- Overcoming Complex Task with Rapid Development.
- Increased Speed & App Performance.
- Created As Batteries-Included Framework.
28. Why should we use Django framework?
Django is an open-source framework for backend web applications based on Python — one of the top web development languages. Its main goals are simplicity, flexibility, reliability, and scalability. Django has its own naming system for all functions and components (e.g., HTTP responses are called “views”).
29. List out the inheritance styles in Django?
Abstract Base Class Inheritance: This style is used when you only want the parent class to hold information that you don't want to type out for each child model.
Multi Table Model Inheritance: This is used if you are subclassing an existing model and need each model to have its own database table.
Proxy Model Inheritance: Apply this if you only want to modify the Python level behaviour of the model, without changing the model’s fields.
30. Does Python make use of access specifiers
Python doesn't have any mechanism that effectively restricts access to any instance variable or method. Python prescribes a convention of prefixing the name of the variable/method with a single or double underscores to emulate the behaviour of protected and private access specifiers.
31. Write Python code to sort a numerical dataset?
# Python program to demonstrate sorting by user's choice # function to return the second element of the # two elements passed as the parameter def sortSecond(val): return val # list1 to demonstrate the use of sorting using second key list1 = [(1, 2), (3, 3), (1, 1)] # sorts the array in ascending according to second element list1.sort (key = sortSecond) print(list1) # sorts the array in descending according to second element list1.sort (key = sortSecond, reverse = True) print(list1)
TOP MNC's PYTHON INTERVIEW QUESTIONS & ANSWERS
Here we listed all Python Interview Questions and Answers which are asked in Top MNCs. Periodically we update this page with recently asked Questions, please do visit our page often and be updated in Python.
To become a Python Certified professional and join in your dream company, Enroll now for our Best Python Training. We help you to crack any level of Python Interviews and We offering Python Training with 100% Placements.