Accenture Interview Questions On Python

2 What is NumPy and How is it Better than a List in Python?

Numpy is the core library in Python. It provides a high-performance multidimensional array object, and tools are working with that arrays. A numpy array is a grid of values, all of the esame type, and is indexed by a tuple of nonnegative integers. List is the core library in Python. A list is the Python equivalent of an array, but is resizeable and can contain elements of different types

When is Python Decorator used?

A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure. Decorators are usually called before the definition of a function you want to decorate.

PEP stands for Python Enhancement Proposal. PEP8 is a 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.

3 What are Dict and List comprehensions?

Python comprehensions are like decorators, that help to build altered and filtered lists, dictionaries, or sets from a given list, dictionary, or set. Comprehension saves a lot of time and code that might be considerably more complex and time-consuming.

Comprehensions are beneficial in the following scenarios:

  • Performing mathematical operations on the entire list
  • Performing conditional filtering operations on the entire list
  • Combining multiple lists into one
  • Flattening a multi-dimensional list
  • For example:

    # output => [4 , 9 , 25 , 49 , 121]

    # output => {11: 121, 2: 4 , 3: 9 , 5: 25 , 7: 49}

    4 What do file-related modules in Python do? Can you name some file-related modules in Python?

    Python comes with some file-related modules that have functions to manipulate text files and binary files in a file system. These modules can be used to create text or binary files, update their content, copy, delete, and more.

    Some file-related modules are os, os.path, and shutil.os. The os.path module has functions to access the file system, while the shutil.os module can be used to copy or delete files.

    Know about Python developer roles and responsibilities to begin a career as a Python developer.

    1 How to overload constructors or methods in Python?

    init__ () is a first method defined in a class. when an instance of a class is created, python calls __init__() to initialize the attribute of the object. Following example demonstrate further:

    Employee Details:

    ( Name:, Sarah, Code:, 99, Pay:, 30000.0) ( Name:, Asrar, Code:, 100, Pay:, 60000.0)

    6 Write a code to sort a numerical list in Python?

    The following code can be used to sort a numerical list in Python:

    1 What is type conversion in Python?

    Python provides you with a much-needed functionality of converting one form of data type into the needed one and this is known as type conversion.

    Type Conversion is classified into types:

    1. Implicit Type Conversion: In this form of type conversion python interpreter helps in automatically converting the data type into another data type without any User involvement.

    2. Explicit Type Conversion: In this form of Type conversion the data type inn changed into a required type by the user.

    Various Functions of explicit conversion are shown below:

    2 Which are the file related libraries/modules in Python?

    Modules are used to file containing Python statements and definitions. In this module provides code reusability. Define our most used functions in a module and import it, instead of copying their definitions into different programs

    Accenture Python Interview Questions || Arrays & Strings || Interview Insights || Unique Strings

    Related Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *