Posts Tagged with 'Python'

It means that a function can be treated just like an object. You can assign them to variables, or pass them as arguments to other functions. You can even return them from other functions.

Last updated 3 weeks, 1 day ago | 22 views

Tags:- Python

Python | Slicing  As the name suggests, ‘slicing’ is taking parts of sequences like lists, tuples, and strings. Syntax for slicing is [start : stop : step] The start is the starting index from where to slice a …

Last updated 3 weeks, 1 day ago | 20 views

Tags:- Python

Python is an interpreted language, that executes each statement line by line and thus type-checking is done on the fly, during execution. Hence, Python is a Dynamically Typed Language.   Typing refers to type-checking in programming …

Last updated 3 weeks, 1 day ago | 21 views

Tags:- Python

Python | Difference between @staticmethod and @classmethod A staticmethod is a method that knows nothing about the class or the instance it was called on. It just gets the arguments that were passed, no implicit first argument. …

Last updated 3 weeks, 1 day ago | 20 views

Tags:- Python

If bool(a) returns False, then x is assigned the value of b.

Last updated 3 weeks, 1 day ago | 22 views

Tags:- Python

Python | Docstring  A documentation string or docstring is a multiline string used to document a specific code segment. The docstring should describe what the function or method does.  

Last updated 3 weeks, 1 day ago | 18 views

Tags:- Python

yield is a keyword beares the ability to turn any function into a generator.  Much like the standard return keyword, but returns a generator object. It is also true that one function may observe multiple …

Last updated 3 weeks, 2 days ago | 13 views

Tags:- Python

Python | Module and Package Module: The module is a simple Python file that contains collections of functions and global variables and with having a .py extension file. It is an executable file and to organize all …

Last updated 3 weeks, 4 days ago | 19 views

Tags:- Python

Python | context manager Context managers allow you to allocate and release resources precisely when you want to. The most widely used example of context managers is the with() statement.  with open('some_file', 'w') as opened_file: opened_file.write('Hola!')   The …

Last updated 3 weeks, 4 days ago | 28 views

Tags:- Python

Python | namedtuple A namedtuple will let us access a tuple’s elements using a name/label. We use the function namedtuple() for this, and import it from collections. >>> from collections import namedtuple #format >>> result=namedtuple('result','Physics Chemistry …

Last updated 3 weeks, 4 days ago | 12 views

Tags:- Python

Python | Memory manage Python has a private heap space to hold all objects and data structures. Being programmers, we cannot access it; it is the interpreter that manages it. But with the core API, …

Last updated 3 weeks, 4 days ago | 19 views

Tags:- Python

Python | accessors, mutators, and @property What we call getters and setters in languages like Java, we term accessors and mutators in Python. In Java, if we have a user-defined class with the property ‘x’, we …

Last updated 3 weeks, 4 days ago | 19 views

Tags:- Python

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.

Last updated 3 weeks, 4 days ago | 21 views

Tags:- 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 …

Last updated 3 weeks, 4 days ago | 19 views

Tags:- Python

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 …

Last updated 3 weeks, 4 days ago | 21 views

Tags:- Python