Latest Posts From Vijaykrishna Ram

Python setattr() Function

Python setattr() function is used to set the attribute of an object, given its name. While being a very simple function, it can prove to be very useful in the context of Object Oriented Programming in Python. Let us look at how we could use this function in our Python programs. setattr() Function Syntax It […]

Python Template Strings

Python’s Template String Class provides a way for simple string substitution, wherein the template fields are substituted with suitable replacement strings provided by the user. Sometimes, it may be a preference to have an easier to replace string, rather than using other format strings for substitution. Template Strings are used exactly for this purpose, to […]

Python // operator – Floor Based Division

The // operator in Python 3 is used to perform floor-based division. This means that a // b first divides a by b and gets the integer quotient, while discarding the remainder. This means that the result of a//b is always an integer. Python // Operator Examples Here are a few examples to illustrate the […]

Python filter() function

Python’s filter() function is used to filter the elements of an iterable (sequence) with the help of a predicate that tests each element on the iterable. A predicate is a function that always returns True or False. We cannot use a generic function with filter(), since it returns all elements only if a suitable condition […]

Python argparse Module – Parse Command-line Arguments Easily

When writing command-line scripts in Python, we might have come across a situation wherein we would need to add more command-line options for our program. Doing the argument parsing by ourselves tend to be very tedious and time-consuming, and often slow us down a lot. Python’s argparse module provides a solution to this problem. The […]

Python random Module – Generate Random Numbers/Sequences

This article is about the random module in Python, which is used to generate pseudo-random numbers for various probabilistic distributions. Python random Module Methods 1. seed() This initializes a random number generator. To generate a new random sequence, a seed must be set depending on the current system time. random.seed() sets the seed for random […]