python tutorial - Python coding interview questions - learn python - python programming
python interview questions :41
How do you compile Python C/C++ extensions for different OS/versions of Python?
- We use Virtual Machines and a Hudson server.
- We have a Virtual Machine for each architecture we support (generally compiling doesn't stretch the resources allocated to them, so a VM is fine). I guess the configuration of each VM could be managed by something like Puppet or Chef to ensure it is a suitable build environment. You could of course use real machines if you have the hardware, but you'd want to avoid using machines which people are actually using (e.g. developer workstations).
Learn python - python tutorial - python-extensions - python examples - python programs
- We then use a multi-configuration project in Hudson to setup a build matrix. The build matrix allows us to (with a single click) build multiple python versions, on multiple architectures, but in theory you can build every and any combination you can setup in your matrix. Of course you could use Jenkins instead.
python interview questions :42
Why isn't __getattr__ invoked when attr == '__str__'?
- It's because the base class object already implements a default __str__ method, and our __getattr__ function is only called for missing attributes. To fix the example as it is we must use the __getattribute__ method instead, but beware of the dangers.
python interview questions :43
Which tool in Python will you use to find bugs if any?
- Pylint and Pychecker. Pylint verifies that a module satisfies all the coding standards or not. Pychecker is a static analysis tool that helps find out bugs in the course code.
python interview questions :44
How are arguments passed in Python- by reference or by value?
- The answer to this question is neither of these because passing semantics in Python are completely different. In all cases, Python passes arguments by value where all values are references to objects.
python interview questions :45
Explain the usage of decorators?
- Decorators in Python are used to modify or inject code in functions or classes. Using decorators, you can wrap a class or function method call so that a piece of code can be executed before or after the execution of the original code.
- Decorators can be used to check for permissions, modify or track the arguments passed to a method, logging the calls to a specific method, etc.
python interview questions :46
How can you check whether a pandas data frame is empty or not?
- The attribute df.empty is used to check whether a data frame is empty or not.
Learn python - python tutorial - data-frame - python examples - python programs
python interview questions :47
What will be the output of the below Python code def multipliers ()?
- The reason for this is that because of late binding the value of the variable i is looked up when any of the functions returned by multipliers.
python interview questions :48
What do you mean by list comprehension?
- The process of creating a list while performing some operation on the data so that it can be accessed using an iterator is referred to as List Comprehension.
python interview questions :49
What will be the output of the below code word = ‘aeioubcdfg'?
- In string slicing when the indices of both the slices collide and a “+” operator is applied on the string it concatenates them.
- Most of the people might confuse the answer with an index error because the code is attempting to access a member in the list whose index exceeds the total number of members in the list.
- The reason being the code is trying to access the slice of a list at a starting index which is greater than the number of members in the list.
python interview questions :50
What will be the output of the below code:def foo (i= )?
- Argument to the function foo is evaluated only once when the function is defined.
- However, since it is a list, on every all the list is modified by appending a 1 to it.