Any 3 Built in method in Python
The Python interpreter has a number of functions built into it that are always available. They are listed here in alphabetical order. ... Convert an integer number to a binary string. The result is a valid Python expression. If x is not a Python int object, it has to define a __index__() method that returns an integer.
Python abs()
The abs() method returns the absolute value of the given number. If the number is a complex number, abs() returns its magnitude.
The syntax of abs() method is:
abs(num)
abs() Parameters
The abs() method takes a single argument:
- num - a number whose absolute value is to be returned. The number can be:
a. integer
b. floating number
c. complex number
Return value from abs()
The abs() method returns the absolute value of the given number.
- For integers - integer absolute value is returned
- For floating numbers - floating absolute value is returned
- For complex numbers - the magnitude of the number is returned
Python any()
The any() method returns True if any element of an iterable is True. If not, any() returns False.
The syntax of any() is:
any(iterable)
any() Parameters
The
any()
method takes an iterable (list, string, dictionary etc.) in Python.
Return Value from any()
any()
returns:True
if at least one element of an iterable is trueFalse
if all elements are false or if an iterable is empty
Python all()
The all() method returns True when all elements in the given iterable are true. If not, it returns False.
The syntax of all() method is:
all(iterable)
all() Parameters
The all() method takes a single parameter:
- iterable - any iterable (list, tuple, dictionary, etc.) which contains the elements
Return Value from all()
The all() method returns:
- True - If all elements in an iterable are true
- False - If any element in an iterable is false
Comments
Post a Comment