Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

How Memory Is Managed In Python?

Answer»
  • 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.

2.

How Python Is Interpreted?

Answer»

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.

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.

3.

What Is Pickling And Unpickling?

Answer»

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.

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.

4.

What Is Pep 8?

Answer»

PEP 8 is a CODING CONVENTION, a set of RECOMMENDATION, about how to write your Python code more readable.

PEP 8 is a coding convention, a set of recommendation, about how to write your Python code more readable.

5.

Define “module” And “package”?

Answer»
  • 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”.

6.

What Is The Difference Between “xrange” And “range”?

Answer»

“Xrange” returns the “Xrange” object while range returns the “LISTIRRESPECTIVE of the SIZE of the “range”.

“Xrange” returns the “Xrange” object while range returns the “list” irrespective of the size of the “range”.

7.

How Do You Convert A Number Into A String?

Answer»

By USING the INBUILT FUNCTION STR().

By using the inbuilt function str().

8.

What Is A “negative Index”?

Answer»

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.

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.

9.

How Do You Copy An Object In Python?

Answer»

copy.copy () or copy.deepcopy()

copy.copy () or copy.deepcopy()

10.

Define “docstring”?

Answer»

“Docstring” is a Python DOCUMENTATION string. It is the means to DOCUMENT Python “FUNCTIONS”, “modules” and “CLASSES”.

“Docstring” is a Python documentation string. It is the means to document Python “functions”, “modules” and “classes”.

11.

What Are Generators In Python?

Answer»

Generators are the MEANS to implement iterators. It is a NORMAL function EXCEPT that it YIELDS “expression” in the “function”.

Generators are the means to implement iterators. It is a normal function except that it yields “expression” in the “function”.

12.

Define “slicing”?

Answer»

“Slicing” is a MECHANISM to select a range of items from sequence TYPES like LIST, TUPLE, STRINGS etc.

“Slicing” is a mechanism to select a range of items from sequence types like list, tuple, strings etc.

13.

What Is A “unittest” In Python?

Answer»

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.

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.

14.

Explain How Python Does Compile-time And Run-time Code Checking?

Answer»

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.

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.

15.

Does The Functions Help() And Dir() List The Names Of All The Built_in Functions And Variables? If No, How Would You List Them?

Answer»

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’, ……… ]

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’, ……… ]

16.

Which Command Do You Use To Exit Help Window Or Help Command Prompt?

Answer»

quitWhen you type quit at the HELP’s COMMAND prompt, PYTHON shell prompt will appear by closing the help WINDOW automatically

quitWhen you type quit at the help’s command prompt, python shell prompt will appear by closing the help window automatically

17.

What Are The Rules For Legal Python Names?

Answer»
  1. NAMES MUST START with a letter or _.
  2. Names must contain only letters, DIGITS, and _.

18.

What Are “tuples”?

Answer»

TUPLES are IMMUTABLE SEQUENCES: they cannot be modified. Tuples use PARENTHESES INSTEAD of square brackets: tup = (‘test’, 5, -0.2)

Tuples are immutable sequences: they cannot be modified. Tuples use parentheses instead of square brackets: tup = (‘test’, 5, -0.2)

19.

Write An Expression That Evaluate To True?

Answer»

LEN(‘aaddgg’) == 6

len(‘aaddgg’) == 6

20.

Considering The Following Code: S = ‘catandapple’ Write An Expression That Evaluate To ‘apple’?

Answer»

s[-5:]

s[-5:]

21.

What Does The Expression Len(”) Evaluate To?

Answer»

0

0

22.

Please Write An Example Of A Print Function?

Answer»

PRINT(‘HELLO’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘-‘ + ‘you’)

print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘-‘ + ‘you’)

23.

The Following Is Displayed By A Print Function Call?

Answer»

hello-how-are-you

hello-how-are-you

24.

The Following Is Displayed By A Print Function Call: Yesterday Today Tomorrow Please Write An Example Of A Print Function?

Answer»

PRINT(‘yesterdayntodayntomorrow’)

print(‘yesterdayntodayntomorrow’)

25.

What Tools That Helps Python Development Do You Know?

Answer»

There are good tools for HELPING PYTHON development such as NOTEPAD++ with the PyNPP PLUGIN and ECLIPSE with PyDev and PyUnit

There are good tools for helping Python development such as Notepad++ with the PyNPP plugin and Eclipse with PyDev and PyUnit

26.

What Python Frameworks Do You Know?

Answer»

FRAMEWORK CALLED Web2py, PAMIE (Python AUTOMATION MODULE for I. E.), The py.test framework

Framework called Web2py, PAMIE (Python automation Module for I. E.), The py.test framework

27.

How Python Can Be Used In Software Testing?

Answer»
  1. To generate test data; parse test results; generate reports; testing API calls ETC.
  2. Python to extract requirements from a Word document.
  3. For testing tasks automation, setting up environments for tests, extracting performance data, etc…
  4. Testers use Python EXTENSIVELY in many companies with Selenium for test automation.
  5. For writing desktop APPLICATIONS used by testers.
  6. Test data manipulation.
  7. To build test ENVIRONMENT
  8. Testing with IronPython on .NET

28.

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

Answer»

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.

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.