Python Automation Testing Interview Questions and Answers

Posted On:July 14, 2021, Posted By: Latest Interview Questions, Views: 2790, Rating :

Best Python Automation Testing Interview Questions and Answers PDF

1. What Is Python? What Are The Benefits Of Using Python?

Python is a programming language with objects, modules, threads, exceptions and automatic memory management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure and it is an open source.
2. How Python Can Be Used In Software Testing?
To generate test data; parse test results; generate reports; testing API calls etc.
Python to extract requirements from a Word document.
For testing tasks automation, setting up environments for tests, extracting performance data, etc…
Testers use Python extensively in many companies with Selenium for test automation.
For writing desktop applications used by testers.
Test data manipulation.
To build test environment
Testing with IronPython on .NET
3. What Python Frameworks Do You Know?
Framework called Web2py, PAMIE (Python automation Module for I. E.), The py.test framework.
4. What Tools That Helps Python Development Do You Know?
There are good tools for helping Python development such as Notepad++ with the PyNPP plugin and Eclipse with PyDev and PyUnit.
5. The Following Is Displayed By A Print Function Call: Yesterday Today Tomorrow Please Write An Example Of A Print Function?
6. The Following Is Displayed By A Print Function Call?
7. Please Write An Example Of A Print Function?
print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘-‘ + ‘you’)
8. What Does The Expression Len(”) Evaluate To?
9. Considering The Following Code: S = ‘catandapple’ Write An Expression That Evaluate To ‘apple’?
10. Write An Expression That Evaluate To True?
len(‘aaddgg’) == 6
11. What Are “tuples”?
Tuples are immutable sequences: they cannot be modified. Tuples use parentheses instead of square brackets: tup = (‘test’, 5, -0.2)
12. What Are The Rules For Legal Python Names?
Names must start with a letter or _.
Names must contain only letters, digits, and _.
13. Which Command Do You Use To Exit Help Window Or Help Command Prompt?
quitWhen you type quit at the help’s command prompt, python shell prompt will appear by closing the help window automatically.
14. Does The Functions Help() And Dir() List The Names Of All The Built_in Functions And Variables? If No, How Would You List Them?
No. Built-in functions such as max(), min(), filter(), map(), etc is not apparent immediately as they are available as part of standard module.To view them, we can pass the module ” builtins ” as an argument to “dir()”. It will display the built-in functions, exceptions, and other objects as a list.>>>dir(__builtins )
[‘ArithmeticError’, ‘AssertionError’, ‘AttributeError’, ……… ]
15. Explain How Python Does Compile-time And Run-time Code Checking?
Python performs some amount of compile-time checking, but most of the checks such as type, name, etc are postponed until code execution. Consequently, if the Python code references a user -defined function that does not exist, the code will compile successfully. In fact, the code will fail with an exception only when the code execution path references the function which does not exists.
16. What Is A “unittest” In Python?
The unit testing framework of Python is known as “unittest”.  It supports the sharing of setups, automation testing, shutdown code for tests, aggregation of tests into collections, among others.
17. Define “slicing”?
“Slicing” is a mechanism to select a range of items from sequence types like list, tuple, strings etc.
18. What Are Generators In Python?
Generators are the means to implement iterators. It is a normal function except that it yields “expression” in the “function”.
19. Define “docstring”?
“Docstring” is a Python documentation string. It is the means to document Python “functions”, “modules” and “classes”.
20. How Do You Copy An Object In Python?
copy.copy () or copy.deepcopy()
21. What Is A “negative Index”?
Python sequences can be indexed as positive and negative numbers. For ac positive index, 0 is the first number, 1 is the second etc.  For a negative index, (-1) is the last index and (-2) is the second etc.
22. How Do You Convert A Number Into A String?
By using the inbuilt function str().
23. What Is The Difference Between “xrange” And “range”?
“Xrange” returns the “Xrange” object while range returns the “list” irrespective of the size of the “range”.
24. Define “module” And “package”?
Each Python program file is a “module”, which imports other modules like “objects” and “attributes”.
A Python program folder is a “package” of “modules”.  A package can have “modules” or “subfolders”.
25. What Is Pep 8?
PEP 8 is a coding convention, a set of recommendation, about how to write your Python code more readable.
26. What Is Pickling And Unpickling?
Pickle module accepts any Python object and converts it into a string representation and dumps it into a file by using dump function, this process is called pickling.  While the process of retrieving original Python objects from the stored string representation is called unpickling.
27. How Python Is Interpreted?
Python language is an interpreted language. Python program runs directly from the source code. It converts the source code that is written by the programmer into an intermediate language, which is again translated into machine language that has to be executed.
28. How Memory Is Managed In Python?
Python memory is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have an access to this private heap and interpreter takes care of this Python private heap.
The allocation of Python heap space for Python objects is done by Python memory manager.  The core API gives access to some tools for the programmer to code.
Python also have an inbuilt garbage collector, which recycle all the unused memory and frees the memory and makes it available to the heap space.