Python questions and answers Part 2

What is Python? - Python is a modern powerful interpreted language with objects, modules, threads, exceptions, and automatic memory managements......
How python is interpreted - Python program runs directly from the source code. Each type Python programs are executed code is required.......
Local and global variables - If a variable is defined outside function then it is implicitly global. If variable is assigned new value inside the function means it is local.......
Dictionary in Python - Python's built-in data type is dictionary, which defines one-to-one relationships between keys and values.......
Global variables in Python - We can create a config file & store the entire global variable to be shared across modules or script in it.......
Pass optional from one function to another - Gather the arguments using the * and ** specifiers in the function's parameter list. This gives us positional arguments as a tuple and the keyword arguments.......
Indexing and slicing operation in sequences - Different types of sequences in python are strings, Unicode strings, lists, tuples, buffers, and xrange objects.......
The lambda form: Using lambda keyword tiny anonymous functions can be created.......
Role of repr function - Python can convert any value to a string by making use of two functions repr() or str(). .......
Pickling and unpickling - pickle is a standard module which serializes & de-serializes a python object structure........
What is LIST comprehensions features of Python used for? - LIST comprehensions features were introduced in Python version 2.0, it creates a new list based on existing list........
How is memory managed in python? - 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.......
How do you make a higher order function in Python? - A higher-order function accepts one or more functions as input and returns a new function. Sometimes it is required to use function as data........
How to copy an object in Python - There are two ways in which objects can be copied in python. Shallow copy and Deep copy........
Methods or attributes of an object in python - Built-in dir() function of Python ,on an instance shows the instance variables as well as the methods and class attributes defined by the instance's class and all its base classes alphabetically. ......
How do I convert a string to a number? - Python contains several built-in functions to convert values from one data type to another data type.......
What is a negative index in python? - Python arrays & list items can be accessed with positive or negative numbers (also known as index)........
How do you make an array in Python? - The array module contains methods for creating arrays of fixed types with homogeneous data types. Arrays are slower then list......
There are two ways in which Multidimensional list can be created: By direct initializing the list as shown below to create multidimlist below......
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.........
How to send mail from a Python script - The smtplib module defines an SMTP client session object that can be used to send mail to any Internet machine.......
Thee standard module random implements a random number generator. There are also many other in this module, such as: uniform(a, b) returns a floating point number in the range [a, b]........
Python scripts can be executed in two ways: Suppose I want to execute script1.py We can open the script1.py in IDE editor & run the script in the frontmost window of the python IDE by hitting the run all button.......
How to make Forms in python - As python is scripting language forms processing is done by Python. We need to import cgi module to access form fields using FieldStorage class.......
A cookie is an arbitrary string of characters that uniquely identify a session........
Sessions are the server side version of cookies. While a cookie preserves state at the client side, sessions preserves state at server side........
How exceptions are handled in python? - Errors detected during execution of program are called exceptions. Exceptions can be handled using the try..except statement.......
Unicode is a system to represent characters from all the world's different languages.......
List is like array, it can be used to store homogeneous as well as heterogeneous data type (It can store same data type as well as different data type). .....
Disadvantages of Python are: Python isn't the best for memory intensive tasks........