Robotics & Artificial Intelligence
Define the following built-in functions:
(a) abs()
(b) pow()
(c) len()
(d) type()
Python Functions
1 Like
Answer
(a) abs() — This function is used to return an absolute value (magnitude of the number). It returns the value as an int or a float type, depending upon the given argument.
For example,
a = abs(-99)
print(a)
Output: 99
(b) pow() — This function is used to find the power 'b' raised to a specified base 'a' (i.e., aᵇ). It will return the data of type int or float, depending upon the output.
For example,
a = pow(10, 3)
print(a)
Output: 1000
(c) len() — This function returns the length or the number of items of an object such as a string, list, tuple or dictionary.
For example,
wd = "Artificial Intelligence"
print(len(wd))
Output: 23
(d) type() — This function returns the data type of elements stored in any data type depending on the arguments passed to the function.
For example,
a = 10
print(type(a))
Output: <class 'int'>
Answered By
2 Likes