Programming Languages

Overview of List and Set

Overview of list and set¶ There are 4 types of collections in Python. While list and set fundamentally contain homogeneous elements, dict and tuple contain heterogeneous elements.* Homogeneous means of same type. Examples of collections with homogeneous elements. Collection of employees – list Collection of unique employees – set Collection of integers – list Collection …

Overview of List and Set Read More »

Exception Handling in Functions

Exception Handling in Functions¶ Let us go through the details about exception handling in functions In [1]: def sum_n(n): try: return int((n * (n + 1) / 2)) except ValueError: print(f'{n} is not valid integer’) return In [2]: def sum_of_integers(lb, ub): try: return sum_n(ub) – sum_n(lb – 1) except Exception: print(f’Unable to get sum of integers between …

Exception Handling in Functions Read More »

Passing Functions are Arguments in Python

Passing Functions as Arguments¶ Let us understand how to pass functions as arguments using Python as programming language. The function which takes other functions as arguments is typically called as higher order function and the function which is passed as argument is called as lower order function. You need to define all the functions you …

Passing Functions are Arguments in Python Read More »