TCS – Python Interview Questions
Here is the list of Python Interview Questions which are recently asked in TCS company. These questions are included for both Freshers and Experienced professionals. Our Python Training has Answered all the below Questions.
1. Is there a scanf() or sscanf() equivalent
No, scanf reads from the standard input stream stdin. fscanf reads from the named input stream. Sscanf reads from the character string s. Each function reads characters, interprets them according to a format, and stores the results in its arguments.
2. What's a negative index?
Python programming language supports negative indexing of arrays, something which is not available in arrays in most other programming languages. This means that the index value of -1 gives the last element, and -2 gives the second last element of an array. The negative indexing starts from where the array ends.
3. How do you make an array in Python?
The array can be handled in python by an array module to create an array with data type and value list specified in its arguments which is useful to manipulate only specific data type values.
4. What is self?
The self-parameter is a reference to the current instance of the class, and is used to access a variable that belongs to the class. It binds the attributes with the given arguments.
5. 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.
Need to change your career to Next Level ?
Click here - Python Interview Questions and Answers
6. Does Python make use of access specifiers
Most programming languages have three forms of access modifiers, which are Public, Protected and Private in a class. Python uses the '_' symbol to determine the access control for a specific data member or a member function of a class.
7. What are the two major loop statements?
Two major types of loops are FOR LOOPS and WHILE LOOPS. A For loop will run a present number of times whereas a While loop will run a variable number of times.
8. Differentiate between SciPy and NumPy?
NumPy stands for Numerical Python while SciPy stands for Scientific Python. Both of their functions are written in Python language. We use NumPy for homogenous array operations.
9. List the ways we add view functions to urls.py?
To tell the existence of index () view function in urls.py you need to do two things:- Add from blog import views towards the end of the import list.
- Create a new URL pattern by adding the following line at the beginning of the urlpatterns list. url(r'^$', views. index),
10. Where is the math.py (socket.py, regex.py, etc.) source file?
There are (at least) three kinds of modules in Python: Modules written in Python (.py);
Modules written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc);
Modules written in C and linked with the interpreter;

11. How do I read (or write) binary data?
The open () function opens a file in text format by default. To open a file in binary format, add 'b' to the mode parameter. Hence the "rb" mode opens the file in binary format for reading, while the "wb" mode opens the file in binary format for writing.
12. Define modules in Python?
A module allows you to logically organize your Python code. ... A module is a Python object with arbitrarily named attributes that you can bind and reference. Simply, a module is a file consisting of Python code. A module can define functions, classes and variables. A module can also include runnable code.
13. Why should we use Django framework?
Django is a high-level Python web framework that enables rapid development of secure and maintainable websites. Built by experienced developers, Django takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel.
14. What is the syntax for creating an instance of a class in Python?
When an instance method object is created by retrieving a user-defined function object from a class via one of its instances, its __self-attribute is the instance, and the method object is said to be bound. The new method's __func__ attribute is the original function object.
15. What are the built-in types available in Python?
When an instance method object is created by retrieving a user-defined function object from a class via one of its instances, its __self-attribute is the instance, and the method object is said to be bound. The new method's __func__ attribute is the original function object.
16. What is data abstraction in Python?
Abstraction in Python is the process of hiding the real implementation of an application from the user and emphasizing only on usage of it. Abstraction means displaying only essential information and hiding the details. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.
17. Are there any interfaces to database packages in Python?
The Python Database API (DB-API) defines a standard interface for Python database access modules. ... Nearly all Python database modules such as sqlite3, psycopg, and mysql-python conform to this interface
18. How can I execute arbitrary Python statements from C?
The highest-level function to do this is PyRun_SimpleString () which takes a single string argument to be executed in the context of the module __main__ and returns 0 for success and -1 when an exception occurred (including SyntaxError)
19. How can I evaluate an arbitrary Python expression from C?
Python's eval() allows you to evaluate arbitrary Python expressions from a ... You can use the built-in Python eval() to dynamically evaluate
20. How do I debug an extension?
The basic idea is to compile/link your C extension in your IDE and get main() to call a function int import_call_execute(int argc, const char *argv[]) that embeds the Python interpreter which then imports a Python module, say a unit test, that exercises your C extension code.
21. Where is Freeze for Windows?
CX_Freeze | .py to .exe.CX_Freeze is a set of scripts and modules for freezing Python scripts into executables, in much the same way that py2exe and py2app do. Get freeze using pip for windows
Book a Free Mock Interviews and Test your Python Knowledge with our Experts
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.
Related Blogs
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.