Q1. What is pickling and unpickling?
Ans. 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.
Q2. How Python is interpreted?
Ans. 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.
Q3. How are arguments passed by value or by reference?
Ans. Everything in Python is an object and all variables hold references to the objects. The references values are according to the functions; as a result you cannot change the value of the references. However, you can change the objects if it is mutable.
Q4. What are generators in Python?
Ans. The way of implementing iterators are known as generators. It is a normal function except that it yields expression in the function.
Q5. In Python what are iterators?
Ans. In Python, iterators are used to iterate a group of elements, containers like list.
Q6. What is module and package in Python?
Ans. In Python, module is the way to structure program. Each Python program file is a module, which imports other modules like objects and attributes.
The folder of Python program is a package of modules. A package can have modules or subfolders.
Q7. What is the difference between Xrange and range?
Ans. Xrange returns the xrange object while range returns the list, and uses the same memory and no matter what the range size is.
Q8. Mention what are the rules for local and global variables in Python?
Ans. Local variables: If a variable is assigned a new value anywhere within the function's body, it's assumed to be local.
Global variables: Those variables that are only referenced inside a function are implicitly global.
Q9. How can you share global variables across modules?
Ans. To share global variables across modules within a single program, create a special module. Import the config module in all modules of your application. The Module will be available as a global variable across modules