Posts Tagged with 'Python'

You can do this by converting the list to a set using the set() method and comparing the length of this set with the length of the original list. If found equal, return True else …

Last updated 1 year, 8 months ago | 397 views

Tags:- Python

Python | What are decorators A decorator in Python is a function that modifies the behavior of an existing function or class without any modification to the original source code.  A decorator takes another function as its argument and returns yet …

Last updated 1 year, 8 months ago | 384 views

Tags:- Python

Python | What are unit tests Unit test is a testing technique to check a single component of code and ensures that it performs as expected. Unit tests are an important part of regression testing to ensure that …

Last updated 1 year, 8 months ago | 382 views

Tags:- Python

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

Last updated 1 year, 10 months ago | 430 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 1 year, 10 months ago | 380 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 1 year, 10 months ago | 414 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 1 year, 10 months ago | 377 views

Tags:- Python

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

Last updated 1 year, 10 months ago | 486 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 1 year, 10 months ago | 505 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 1 year, 10 months ago | 409 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 1 year, 10 months ago | 380 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 1 year, 10 months ago | 437 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 1 year, 10 months ago | 385 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 1 year, 10 months ago | 405 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 1 year, 10 months ago | 427 views

Tags:- Python