Vijaykrishna Ram

Python – Catch Multiple Exceptions

Python always operates on an Exception based model. That is, any errors during the program execution are passed as Exceptions and returned to the programmer, which may be handled accordingly using Exception Handling techniques. Sometimes, it is possible that a process raises more than one possible exception, depending on the flow of control. Thus, we […]

Python – Catch Multiple Exceptions Read More »

Python Complex Numbers

A Complex Number is any number of the form a + bj, where a and b are real numbers, and j*j = -1. In Python, there are multiple ways to create such a Complex Number. Create a Complex Number in Python We can directly use the syntax a + bj to create a Complex Number.

Python Complex Numbers Read More »

Python Custom Exceptions

An Exception is raised whenever there is an error encountered, and it signifies that something went wrong with the program. By default, there are many exceptions that the language defines for us, such as TypeError when the wrong type is passed. In this article, we shall look at how we can create our own Custom

Python Custom Exceptions Read More »

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 setattr() Function Read More »

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 Template Strings Read More »

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 filter() function Read More »