Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
community creator

min, max, type, len functions in Python

pavani

Functions can be of two types, user-defined or built-in. Since our topic sticks to built-in functions, let’s discuss them briefly.

Built-in function examples

  1. print(): prints stuff on the screen
print("Hello World")
  1. abs(): returns the absolute value (except strings)
print(abs(-4/3))
  1. round(): returns the rounded value of the numeric value(rounding off the decimal value)
print(round(-4/3))
  1. min(): returns the smallest item of a list given in the arguments (in strings also)

  2. 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'))
  1. sorted(): list is sorted into ascending order, could be numbers or strings
arr = [3, 2, 5]
print(sorted(arr))
  1. len(): returns the number of elements in a list or the number of characters in a string
print(len('Hello World'))
  1. type(): returns the variable type
a = True
print(type(a))

RELATED TAGS

python
community creator
RELATED COURSES

View all Courses

Keep Exploring