August 26, 2018

Sreekanth B

EMC Python Recent Asked Interview Questions Answers

When Is The Python Decorator Used?

Python decorator is a relative change that you do in Python syntax to adjust the functions quickly.

 What Is The Key Difference Between A List And The Tuple?

List Vs Tuple.
The major difference between a list and the tuple is that the list is mutable while tuple is not. A tuple is allowed to be hashed, for example, using it as a key for dictionaries.

 How Does Python Handle The Memory Management?

Python uses private heaps to maintain its memory. So the heap holds all the Python objects and the data structures. This area is only accessible to the Python interpreter; programmers can’t use it.
And it’s the Python memory manager that handles the Private heap. It does the required allocation of the heap for Python objects.
Python employs a built-in garbage collector, which salvages all the unused memory and offloads it to the heap space.

How Do You Count The Occurrences Of Each Item Present In The List Without Explicitly Mentioning Them?

Unlike sets, lists can have items with same values. In Python, the list has a <count()> function which returns the occurrences of a particular item.

Count The Occurrences Of An Individual Item.
weekdays = ['sun','mon','tue','wed','thu','fri','sun','mon','mon']

output: 3

How will you convert a string to a list in python?

list(s) − Converts s to a list.

What Is NumPy And How Is It Better Than A List In Python?

NumPy is a Python package for scientific computing which can deal with large data sizes. It includes a powerful N-dimensional array object and a set of advanced functions.

Also, the NumPy arrays are superior to the built-in lists. There are a no. of reasons for this.

NumPy arrays are more compact than lists.
Reading and writing items is faster with NumPy.
Using NumPy is more convenient than to the standard list.
NumPy arrays are more efficient as they augment the functionality of lists in Python.

What Are Different Ways To Create An Empty NumPy Array In Python?

There are two methods which we can apply to create empty NumPy arrays.

The First Method To Create An Empty Array.

import numpy

The Second Method To Create An Empty Array.

# Make an empty NumPy array

How will you check in a string that it is properly titlecased?

istitle() − Returns true if string is properly “titlecased” and false otherwise.

How will you check in a string that all characters are in uppercase?

isupper() − Returns true if string has at least one cased character and all cased characters are in uppercase and false otherwise.

How will you merge elements in a sequence?

join(seq) − Merges (concatenates) the string representations of elements in sequence seq into a string, with separator string.

How will you convert a string to a tuple in python?

tuple(s) − Converts s to a tuple.

What is the output of print str + “TEST” if str = ‘Hello World!’?

It will print concatenated string. Output would be Hello World!TEST.

What is the output of print tuple[1:3] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?

It will print elements starting from 2nd till 3rd. Output would be (786, 2.23).

What is the output of print tuple[2:] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?

It will print elements starting from 3rd element. Output would be (2.23, ‘john’, 70.200000000000003).

Explain how python is interpreted ?

- Python program runs directly from the source code.

- Each time Python programs are executed code is required.

- Python converts source code written by the programmer into intermediate language which is again translated into the native language / machine language that is executed. So Python is an Interpreted language.

- It is processed at runtime by the interpreter.

- The program need not be compiled before its execution.

- It is similar to PERL and PHP.

- Python is also interactive where it can prompt and interact with the interpreter directly to write the programs.

- It supports the object-oriented style of the technique which encapsulates the code within the objects.

How will you convert a string to a set in python?

set(s) − Converts s to a set.

Subscribe to get more Posts :