Functions can be of two types, user-defined or built-in. Since our topic sticks to built-in functions, let’s discuss them briefly.
print()
: prints stuff on the screenabs()
: returns the absolute value (except strings)round()
: returns the rounded value of the numeric value(rounding off the decimal value)min()
: returns the smallest item of a list given in the arguments (in strings also)
max()
: the opposite of the minimum – in other words – it returns the largest value of the list given in the argument
print(min(3, 2, 5))print(max('c', 'a', 'b'))
sorted()
: list is sorted into ascending order, could be numbers or stringsarr = [3, 2, 5]print(sorted(arr))
len()
: returns the number of elements in a list or the number of characters in a stringprint(len('Hello World'))
type()
: returns the variable typea = Trueprint(type(a))