Posts Tagged with 'Python'
Does Python support interfaces like Java does?
No. However, Abstract Base Classes (ABCs) are a feature from the abc module that let us declare what methods subclasses should implement. Python supports this module since version 2.7.
What is the MRO in Python?
MRO stands for Method Resolution Order. Talking of multiple inheritances, whenever we search for an attribute in a class, Python first searches in the current class. If found, its search is satiated. If not, it …
Can you explain the filter(), map(), and reduce() functions?
Python | filter(), map(), and reduce() Functions filter() function accepts two arguments, a function and an iterable, where each element of the iterable is filtered through the function to test if the item is accepted or …
Whenever you exit Python, is all memory de-allocated?
The answer here is no. The modules with circular references to other objects, or to objects referenced from global namespaces, aren’t always freed on exiting Python. Plus, it is impossible to de-allocate portions of memory …
What is the Dogpile effect?
Python | Dogpile effect In case the cache expires, what happens when a client hits a website with multiple requests is what we call the dogpile effect. To avoid this, we can use a semaphore lock. When …
What is the iterator in python?
Python | Iterator | (__iter__ and __next__) Iterators are objects that can be iterated upon. The iterator protocol for Python declares that we must make use of two functions to build an iterator- iter() and next(). …
How do yo handle exception in python?
Python | Exception Handling Python has many built-in exceptions that are raised when your program encounters an error. Try and Except Statement – Catching Exceptions: Try and except statements are used to catch and handle …
List primitive and non primitive data types?
Primitive data types are Integers, Float, Strings, and Boolean. Non-primitive data types are Array, List, Tuples, Dictionary, Sets, and Files.
How do you debug code in python?
Using PDB we debug code in python. Some pdb commands include- <b> — Add breakpoint <c> — Resume execution <s> — Debug step by step <n> — Move to next line <l> — List source code …
Difference between new_style and old_style class?
Python | new_style and old_style Old-style: With old-style classes, class and type are not quite the same things. If obj is an instance of an old-style class, obj __class__ designates the class, but the type(obj) is always …
Explain Global, Local and Nonlocal variables.
Python | Global, Local and Nonlocal variables Global variables are public variables that are defined in the global scope. A variable declared inside the function's body or in the local scope is known as a …
What are the tools present to perform statics analysis?
The two static analysis tools used to find bugs in Python are Pychecker and Pylint. Pychecker detects bugs from the source code and warns about its style and complexity. While Pylint checks whether the module …
What is the difference between / and // operator in Python?
Python | / and // Operator /: is a division operator and returns the Quotient value. e.g: 10/3 will return 3.33 // : is known as floor division operator and used to return only the value of …
How is Multithreading achieved in Python?
Python has a multi-threading package, but commonly not considered good practice to use it as it will result in increased code execution time. Python has a constructor called the Global Interpreter Lock (GIL). The GIL ensures …
What is the difference between append() and extend() methods?
Python | append() and extend() Function Both append() and extend() methods are methods used to add elements at the end of a list. append(element): append() method adds the given element at the end of the list. …