Skip to content
Home » Built-in Functions

Built-in Functions


Built-in Functions in Python

Built-in functions are predefined functions that come with Python.
They are always available without importing any module.

Python provides over 70 built-in functions, and they help in:

✔ Input/output
✔ Type conversion
✔ Mathematical operations
✔ Working with data structures
✔ Memory and object handling
✔ Error handling

Built-in functions make programming easier and faster because you don’t need to write code from scratch.


1. Input/Output Built-in Functions

1. print()

Displays output on the screen.

print("Hello")

2. input()

Takes input from the user (always as a string).

name = input("Enter name: ")

2. Type Conversion Functions

Used to convert one data type to another.

FunctionConversion
int()Converts to integer
float()Converts to float
str()Converts to string
bool()Converts to boolean
list()Converts to list
tuple()Converts to tuple
set()Converts to set
dict()Converts to dictionary

Examples:

int("10")
float("3.14")
list("python")

3. Mathematical Built-in Functions

1. abs()

Returns absolute value.

abs(-10)   # 10

2. pow(a, b)

Returns a^b.

pow(2, 3)  # 8

3. round(x, n)

Rounds number to n decimal places.

round(3.14159, 2)   # 3.14

4. min() and max()

Returns minimum or maximum.

min(2,5,1)
max([1,9,3])

5. sum()

Returns sum of elements.

sum([1,2,3,4])

4. Sequence and Collection Built-in Functions

1. len()

Returns the length of a sequence.

len("Python")

2. sorted()

Returns a sorted list without modifying original.

sorted([3,1,2])

3. reversed()

Returns reverse iterator.

list(reversed("abc"))   # ['c','b','a']

4. enumerate()

Returns index + element.

for i, val in enumerate(["a","b"]):
    print(i, val)

5. range()

Generates number sequence (used in loops).

range(1, 10, 2)

5. Object and Memory Related Built-in Functions

1. type()

Returns the type of a variable.

type(10)

2. id()

Returns unique identity (memory address).

id("abc")

3. isinstance(object, type)

Checks if object belongs to a type.

isinstance(10, int)   # True

4. dir()

Returns list of attributes/methods of an object.

dir(list)

5. help()

Displays help documentation.

help(str)

6. Utility and Functional Built-ins

1. eval()

Evaluates a string expression.

eval("10 + 5")   # 15

2. exec()

Executes Python code dynamically.

exec("x = 10")

3. bin(), oct(), hex()

Convert numbers to binary, octal, or hex.

bin(10)
oct(10)
hex(10)

4. any() and all()

  • any() → True if any element is True
  • all() → True if all elements are True
any([0, False, 3])   # True
all([1, True, 5])    # True

7. Built-in Functions for Iterables

1. map(function, iterable)

Applies a function to each item.

list(map(str.upper, ["a","b"]))

2. filter(function, iterable)

Selects items where function returns True.

list(filter(lambda x: x%2==0, [1,2,3,4]))

3. zip()

Combines multiple iterables index-wise.

list(zip([1,2], ["a","b"]))

8. Input Validation and Error Handling Functions

1. abs()

For absolute value.

2. float()

For numeric validation.

3. int()

Converts valid numeric strings.


Most Common Built-in Functions for Exams

  1. print()
  2. input()
  3. len()
  4. min(), max()
  5. sum()
  6. type()
  7. range()
  8. list(), tuple(), dict()
  9. str()
  10. eval(), exec()
  11. sorted()
  12. id()
  13. help()
  14. dir()

Example Program Using Built-in Functions

Count vowels using built-in functions

s = "Education"
count = sum(1 for ch in s.lower() if ch in "aeiou")
print(count)

Sorting a list

nums = [5, 3, 9, 1]
print(sorted(nums))

Conclusion

Built-in functions are essential tools in Python.
They help simplify coding tasks, reduce complexity, and improve performance.
Understanding built-in functions is necessary before learning:

✔ Modules
✔ User-defined functions
✔ Data structures
✔ File handling