Commonly Asked Python Telephonic Interview Questions
Commonly Asked Python Telephonic Interview Questions
Ans: Shallow copy and deep copy functions can be defined as below:
1. A shallow copy constructs a new compound object and
inserts references into it to the objects found in the original.
then
10.
How is memory managed in python? Paxterra, Cisco, Graphene,
Calsoft.
Memory management in Python involves a private heap containing all
Python objects and data structures. Interpreter takes care of Python heap
and that the programmer has no access to it.
The allocation of heap space for Python objects is done by Python
memory manager.
Python also has a build-in garbage collector which recycles all the unused
memory. When an object is no longer referenced by the program, the
heap space it occupies can be freed. The garbage collector determines
objects which are no longer referenced by the program frees the occupied
memory and make it available to the heap space.
The gc module defines functions to enable /disable garbage collector:
gc.enable()
-Enables
automatic
garbage
collection.
gc.disable() - Disables automatic garbage collection.
11.
What is garbage collection? Paxterra, Cisco, Graphene, Calsoft.
Ans: Garbage collection is a form of automatic memory management.
The garbage collector, or just collector, attempts to reclaim garbage, or
memory occupied by objects that are no longer in use by the program. OR
Garbage collection is the systematic recovery of pooled computer storage
that is being used by a program when that program no longer needs it. This
frees the storage for use by other programs or processes within a program.
12.
What is encapsulation?
Ans: http://www.swaroopch.com/notes/python/#_features_of_python
14.
What is the difference between list, tuple, dictionary and a set: Wipro,
HP, SanDisk, McAfee, Dell
Ans: A dictionary is an associative array or hash table that contains objects
indexed by keys.
Lists are sequences of objects.
http://www.dreamincode.net/forums/topic/82368-data-structuresin-python/
15.
Ans: Files named __init__.py are used to mark directories on disk as a Python
package directories. If you have the files mydir/spam/__init__.py
mydir/spam/module.py
and mydir is on your path, you can import the code in module.py as:
import spam.module
or
from spam import module
If you remove the __init__.py file, Python will no longer look for submodules
inside that directory, so attempts to import the module will fail.
The __init__.py file is usually empty, but can be used to export selected
portions of the package under more convenient names, hold convenience
functions, etc. Given the example above, the contents of the __init__ module
can be accessed as:
import spam.
16.
Ans. The TCP/IP protocol maps to a four layer conceptual model: application,
transport, Internet and network interface. This model is referred to as the
Internet Protocol Suite or the ARPA model.
NetworkInterface
The network interface layer is the equivalent of the OSI physical and data link
layers as it defines the host's connection to the network. This layer comprises
the hardware and software involved in the interchange of frames between
computers. The technologies used can be LAN-based (e.g. Ethernet) or WANbased (e.g. ISDN).
InternetLayer
The network layer uses the protocols to ensure the delivery of packets. These
are described below:
IP(InternetProtocol)
IP is the protocol responsible for addressing and routing packets (on the basis
of routing algorithms) between networks. It ensures the packets reach the
correct
destination
network.
ARP
The Address Resolution Protocol ( ARP) is responsible for obtaining hardware
addresses and matching them to their IP address when the destination
computer
is
on
the
same
network.
ICMP
The Internet Control Management Protocol ( ICMP) is responsible to report
errors and send messages about the delivery of a packet. It can also be used
to test TCP/IP networks. Two examples of ICMP messages include:
Destination unreachable - when a router cannot locate the
destination.
Time exceeded - when the Time To Live (TTL) of a packet reaches
zero.
TransportLayer:
In the Open Systems Interconnection (OSI) communications model, the
Transport layer ensures the reliable arrival of messages and provides error
checking mechanisms and data flow controls. The Transport layer provides
services for both "connection-mode" transmissions and for "connectionlessmode" transmissions. For connection-mode transmissions, a transmission may
be sent in the form of packets that need to be reconstructed into a complete
message at the other end. The Transport layer provides communication
between the source and destination computers, and breaks application layer
information into packets. TCP/IP provides two methods of data delivery:
Connection-orientated delivery using TCP
Connectionless delivery using UDP.
Application
Layer
The Application layer is the layer at which many TCP/IP services (high level
protocols) can be run (such as FTP, HTTP and SMTP). Two application
programming interfaces (APIs) are commonly used within the TCP/IP
environment:
sockets
NetBIOS
18.
Connect to a remote machine and execute a command using python:
Mindteck, McAfee, Wipro
Ans:
19.