Category: Miscellenous
-
Closures
What is a Closure? A Python closure is a nested function which has access to a variable from an enclosing function that has finished its execution. Such a variable is not bound in the local scope. To use immutable variables (number or string), we have to use the non-local keyword. The main advantage of Python…
-
Generators
Python Generators Generators in Python are a convenient way to create iterators. They allow us to iterate through a sequence of values which means, values are generated on the fly and not stored in memory, which is especially useful for large datasets or infinite sequences. The generator in Python is a special type of function…
-
Iterators
Python Iterators An iterator in Python is an object that enables traversal through a collection such as a list or a tuple, one element at a time. It follows the iterator protocol by using the implementation of two methods __iter__() and __next__(). The __iter__() method returns the iterator object itself and the __next__()method returns the next element in the sequence by…
-
math Module
Python math Module The math module is a built-in module in Python that is used for performing mathematical operations. This module provides various built-in methods for performing different mathematical tasks. Note: The math module’s methods do not work with complex numbers. For that, you can use the cmath module. Importing math Module Before using the methods of the math module, you need to import…
-
Date and Time
A Python program can handle date and time in several ways. Converting between date formats is a common chore for computers. Following modules in Python’s standard library handle date and time related processing − What are Tick Intervals Time intervals are floating-point numbers in units of seconds. Particular instants in time are expressed in seconds…