Stewdent.eu
▾

Built-in Functions

Python comes with dozens of ready-made functions you can use immediately without writing any extra code. Knowing the most common ones saves time and makes your programs more readable.

Last updated: 17 February 2026

★☆☆☆☆ Level 1computingprogrammingfunctionsbuilt-inpython4 min read

Report an error

You do not have to write every function yourself. Python comes with a large collection of built-in functions — tools that are always available, ready to use. You have already used some of them without realising it: print() and input() are built-in functions. This article introduces the most useful ones for beginners.

Input and Output

FunctionWhat it doesExample
print()Displays values on screenprint("Hello!")
input()Reads a line of text from the username = input("Your name: ")
name = input("What is your name? ")
print("Hello,", name)
Note

input() always returns a string, even if the user types a number. To do arithmetic with user input, you must convert it first: age = int(input("Age: ")).

Type Functions

These functions convert values from one type to another:

FunctionConverts toExample
int()Integerint("42") → 42
float()Decimal numberfloat("3.14") → 3.14
str()Stringstr(100) → "100"
bool()Booleanbool(0) → False

Maths Functions

FunctionWhat it doesExample
abs()Absolute valueabs(-7) → 7
round()Rounds a numberround(3.7) → 4
max()Largest value in a groupmax(3, 7, 2) → 7
min()Smallest value in a groupmin(3, 7, 2) → 2
sum()Adds up a list of numberssum([1, 2, 3]) → 6
pow()Raises to a powerpow(2, 8) → 256
scores = [85, 72, 91, 68, 77]
print(f"Highest: {max(scores)}")
print(f"Lowest:  {min(scores)}")
print(f"Total:   {sum(scores)}")
print(f"Average: {sum(scores) / len(scores)}")

Sequence Functions

FunctionWhat it doesExample
len()Length of a string or listlen("hello") → 5
range()Generates a number sequencerange(1, 6)
sorted()Returns a sorted copy of a listsorted([3,1,2]) → [1,2,3]
reversed()Returns an iterator in reverseused inside a loop
enumerate()Pairs each item with its indexused inside a for loop
fruits = ["banana", "apple", "cherry"]
for index, fruit in enumerate(fruits):
    print(f"{index}: {fruit}")

Output:

0: banana
1: apple
2: cherry
Tip

enumerate() is much cleaner than manually creating a counter variable. Whenever you need both the position and the value from a list, use enumerate().

type() — Checking the Type

When something behaves unexpectedly, check what type a value actually is:

x = input("Enter a number: ")
print(type(x))       # <class 'str'> — a reminder to convert it!
x = int(x)
print(type(x))       # <class 'int'>
Warning

Many beginner bugs come from forgetting that input() returns a string. Always convert the result before doing arithmetic with it.

help() — Your Documentation Lifeline

If you ever forget what a function does, call help() on it in the Python shell:

help(round)

This prints the official documentation for round directly in your terminal.

Practice Problems

What does len('computing') return? What type is the result?

Show answer
It returns 9 (the number of characters in the string 'computing'). The result is an integer.

A student writes: score = input('Enter score: ') and then average = score / 2. What error will occur and how should they fix it?

Show answer
A TypeError will occur because input() returns a string and you cannot divide a string by a number. The fix is to convert the input: score = int(input('Enter score: ')) or score = float(input('Enter score: ')).