Author name: NIHARIKA NAGULA

get() method

The get() method in python is commonly used with dictionaries and can be used with other types like lists or custom classes. The get() method is versatile and primarily used to safety access dictionary values without raising errors for missing keys. It can be adapted for other data structures as needed. get() method with dictionaries …

get() method Read More »

reduce() in python

The reduce(fun,seq) function is used to apply a particular function passed in its argument to all of the list elements mentioned in the sequence passed along.This function is defined in “functools”module. import functools lis = [4, 3, 5, 6, 2] print(“The sum of the list elements is : “, end=””) print(functools.reduce(lambda a, b: a+b, lis)) …

reduce() in python Read More »

How to check data type in Python

Data types are essential determine the kind of values that can be stored in a variable and the operations that can be performed on them . Python has several built-in data types such as: integer(int),floating- point number(float),strings(str),lists(list),tuples(tuple),dictionaries(dict) Method 1: Using the type() Function The simplest way to check the data type of an object in …

How to check data type in Python Read More »

Scroll to Top