Python Built-in Functions Explained — The Complete Beginner's Guide
Every time you write Python, you're already using tools that took expert engineers thousands of hours to build and test. Functions like print(), len(), and sorted() ship with every single Python installation on the planet. They're not magic — they're carefully written code that Python loads automatically before your script even starts. Understanding them deeply is the difference between writing 20 lines of code and writing 3.
What Exactly Is a Built-in Function — and Why Does Python Include Them?
A function is like a vending machine. You put something in (called an argument), press a button (call the function by name), and get something useful back (the return value). You don't need to know what's happening inside the machine — you just use it.
A built-in function is a vending machine that Python pre-installed for you. You didn't wire it up, you didn't stock it — it just works. Python includes them because the same basic operations come up in almost every program ever written: checking how long something is, converting a number to text, sorting a list, getting keyboard input from a user. Without built-ins, every developer on Earth would waste time re-writing these from scratch.
Python currently ships with 68 built-in functions. They live in a special namespace called 'builtins' that Python loads silently before your code runs. That's why you can call print() on line 1 of a brand new file without importing anything — it's already there.
# ----------------------------------------------------------- # Exploring Python's built-in functions for the first time # ----------------------------------------------------------- # print() sends text to the screen — the most-used built-in of all print("Hello, I am already built into Python!") # len() counts how many items are in something (string, list, etc.) course_name = "Python Fundamentals" character_count = len(course_name) # counts every character including the space print("Course name has", character_count, "characters") # type() tells you WHAT kind of data something is student_age = 21 print("The data type of student_age is:", type(student_age)) # should say <class 'int'> # abs() returns the absolute (positive) version of a number temperature_change = -7 print("Absolute temperature change:", abs(temperature_change)) # -7 becomes 7 # Notice: no import statement anywhere. These just work.
Course name has 19 characters
The data type of student_age is: <class 'int'>
Absolute temperature change: 7
The Built-ins You'll Use Every Single Day — Grouped by Job
Rather than dumping all 68 functions on you at once, let's organise them the way your brain actually works — by what job they do. Think of it like a toolbox: you have a section for measuring tools, a section for conversion tools, and a section for tools that work on collections.
The four groups that matter most for beginners are: output and input functions (talking to the user), type conversion functions (changing data from one form to another), inspection functions (understanding what you have), and math functions (doing number work). Every other built-in you'll ever meet fits into one of these buckets.
Let's walk through each group with real, working examples. Pay attention to the return values — some built-ins give you back new data (like int() giving you an integer), while others perform an action and return nothing useful (like print(), which returns None). This distinction trips up beginners constantly.
# ----------------------------------------------------------- # GROUP 1: OUTPUT & INPUT — talking to the user # ----------------------------------------------------------- # print() can take multiple values separated by commas first_name = "Maria" last_name = "Chen" print("Full name:", first_name, last_name) # print joins them with a space by default print(first_name, last_name, sep="-") # sep= changes the separator print("Line one", end=" | ") # end= changes what goes at the end print("Line two") # this continues on the same line # input() pauses the program and waits for the user to type something # Uncomment the next two lines to test it interactively: # user_city = input("What city are you in? ") # print("You are in:", user_city) print() # blank line for readability # ----------------------------------------------------------- # GROUP 2: TYPE CONVERSION — changing data from one form to another # ----------------------------------------------------------- # int() converts something INTO a whole number rating_as_text = "42" # this is text, NOT a number yet rating_as_number = int(rating_as_text) # now it IS a number we can do math with print("Rating doubled:", rating_as_number * 2) # float() converts something into a decimal number price_text = "9.99" price = float(price_text) # now we can do math with it print("Price with tax:", price * 1.2) # str() converts something INTO text user_score = 850 leaderboard_entry = "Score: " + str(user_score) # can't join text + number without str() print(leaderboard_entry) # bool() converts something into True or False print(bool(0)) # 0 is considered False print(bool(42)) # any non-zero number is True print(bool("")) # empty string is False print(bool("hello")) # non-empty string is True print() # ----------------------------------------------------------- # GROUP 3: INSPECTION — understanding what you have # ----------------------------------------------------------- shop_items = ["apple", "bread", "milk", "eggs"] # len() — how many items? print("Items in cart:", len(shop_items)) # 4 # type() — what kind of data is this? print("Type of shop_items:", type(shop_items)) # <class 'list'> # isinstance() — is this data a specific type? Returns True or False print("Is shop_items a list?", isinstance(shop_items, list)) # True print("Is shop_items a string?", isinstance(shop_items, str)) # False print() # ----------------------------------------------------------- # GROUP 4: MATH — number operations without importing anything # ----------------------------------------------------------- exam_scores = [72, 88, 91, 65, 79] print("Highest score:", max(exam_scores)) # 91 print("Lowest score:", min(exam_scores)) # 65 print("Total points:", sum(exam_scores)) # 395 print("Rounded pi:", round(3.14159, 2)) # 3.14 — second arg = decimal places print("Absolute:", abs(-50)) # 50
Maria-Chen
Line one | Line two
Rating doubled: 84
Price with tax: 11.987999999999999
Score: 850
False
True
False
True
Items in cart: 4
Type of shop_items: <class 'list'>
Is shop_items a list? True
Is shop_items a string? False
Highest score: 91
Lowest score: 65
Total points: 395
Rounded pi: 3.14
Absolute: 50
Built-ins That Work on Lists and Sequences — sorted(), range(), enumerate(), and zip()
Once you start working with lists (which happens within your first week of Python), four built-in functions become absolutely essential. These are the ones that separate people who struggle with Python from people who feel fluent.
range() generates a sequence of numbers — think of it like a counter that you can control. sorted() creates a new sorted list without touching your original. enumerate() gives you both the position AND the value when you loop through something, so you never have to manually track a counter variable. zip() pairs up two lists like a zipper, letting you work with related data side by side.
These four work best when combined with a for loop. If you haven't seen for loops yet, think of them as: 'do this action for each item in this collection.' The code below shows each one in a scenario you might actually encounter.
# ----------------------------------------------------------- # range() — generating a sequence of numbers # ----------------------------------------------------------- # range(start, stop, step) — stop is EXCLUSIVE (it doesn't include that number) print("Counting 1 to 5:") for number in range(1, 6): # starts at 1, stops BEFORE 6 print(number, end=" ") print() # new line after the loop print("Even numbers from 2 to 10:") for even in range(2, 11, 2): # start=2, stop before 11, step=2 print(even, end=" ") print() print() # ----------------------------------------------------------- # sorted() — sorting without destroying your original list # ----------------------------------------------------------- raw_temperatures = [34, 19, 27, 41, 22, 30] sorted_temperatures = sorted(raw_temperatures) # ascending by default reverse_sorted = sorted(raw_temperatures, reverse=True) # descending print("Original list (unchanged):", raw_temperatures) # still in original order! print("Sorted ascending: ", sorted_temperatures) print("Sorted descending: ", reverse_sorted) print() # sorted() also works on lists of strings — sorts alphabetically team_members = ["Zara", "Ahmed", "Liu", "Beatriz"] print("Alphabetical order:", sorted(team_members)) print() # ----------------------------------------------------------- # enumerate() — getting position AND value at the same time # ----------------------------------------------------------- podium_finishers = ["Kenji", "Amara", "Tobias"] print("Race results:") for position, name in enumerate(podium_finishers, start=1): # start=1 means count from 1 print(f" Position {position}: {name}") print() # ----------------------------------------------------------- # zip() — pairing two lists together like a zipper # ----------------------------------------------------------- student_names = ["Alice", "Bob", "Carol"] final_grades = [88, 74, 95] print("Student grades:") for name, grade in zip(student_names, final_grades): # pairs index-by-index status = "PASS" if grade >= 75 else "FAIL" # inline condition for label print(f" {name}: {grade} — {status}")
1 2 3 4 5
Even numbers from 2 to 10:
2 4 6 8 10
Original list (unchanged): [34, 19, 27, 41, 22, 30]
Sorted ascending: [19, 22, 27, 30, 34, 41]
Sorted descending: [41, 34, 30, 27, 22, 19]
Alphabetical order: ['Ahmed', 'Beatriz', 'Liu', 'Zara']
Race results:
Position 1: Kenji
Position 2: Amara
Position 3: Tobias
Student grades:
Alice: 88 — PASS
Bob: 74 — FAIL
Carol: 95 — PASS
The help() Function — Python's Built-in Manual That Most Beginners Don't Know About
Here's a built-in function that almost no beginner tutorial covers, yet it might be the most empowering one of all: help(). Pass any built-in function's name into help() and Python prints a complete manual entry for it, right in your terminal. No Googling required.
This matters because you will absolutely forget how sorted() works, or what arguments round() accepts, or what the difference between list() and tuple() is. Instead of breaking your flow to open a browser, just call help() and read the answer in 10 seconds.
There's also dir(), which lists every method available on an object. Pass it a string, a list, a number — anything — and it tells you every operation that thing can perform. Together, help() and dir() make Python almost self-documenting. Senior developers use these constantly. Now you can too.
# ----------------------------------------------------------- # help() — read Python's own documentation from inside Python # ----------------------------------------------------------- # To avoid printing 30 lines here, we'll demonstrate the CONCEPT # In your own terminal, type: help(sorted) # You'll see the full signature and description # A quick demo that DOES run cleanly: print("--- What does abs() do? ---") help(abs) # prints the official description of abs() print() # ----------------------------------------------------------- # dir() — list every operation something can perform # ----------------------------------------------------------- sample_text = "hello world" # Filter out the 'dunder' methods (the ones with double underscores) # to see just the readable method names useful_methods = [method for method in dir(sample_text) if not method.startswith("_")] print("Things you can do with a string:") print(useful_methods) print() # ----------------------------------------------------------- # A practical use-case: discovering built-ins you didn't know # ----------------------------------------------------------- numbers_list = [5, 2, 8, 1, 9, 3] # You already know max() and min(). But did you know about sorted()? # Let's verify what type sorted() gives back: result = sorted(numbers_list) print("sorted() returns type:", type(result)) # <class 'list'> print("Original unchanged: ", numbers_list) # [5, 2, 8, 1, 9, 3] # reversed() returns an ITERATOR, not a list — a common gotcha! reversed_result = reversed(numbers_list) print("reversed() returns type:", type(reversed_result)) # <class 'list_reverseiterator'> print("To get a list, wrap it: ", list(reversed(numbers_list))) # [3, 9, 1, 8, 2, 5]
Help on built-in function abs in module builtins:
abs(x, /)
Return the absolute value of the argument.
Things you can do with a string:
['capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
sorted() returns type: <class 'list'>
Original unchanged: [5, 2, 8, 1, 9, 3]
reversed() returns type: <class 'list_reverseiterator'>
To get a list, wrap it: [3, 9, 1, 8, 2, 5]
| Built-in Function | What Goes In | What Comes Out | Destroys Original? | Common Use Case |
|---|---|---|---|---|
| sorted(iterable) | Any list, string, or sequence | A brand new sorted list | No — original untouched | Sort data without losing original order |
| list.sort() | Called on a list directly | None (modifies in place) | Yes — original is changed | When you only need the sorted version |
| len(iterable) | Any string, list, tuple, dict | An integer (the count) | No | Check size before looping or slicing |
| range(start, stop, step) | Up to 3 integers | A range object (lazy sequence) | No | Controlling for loops |
| enumerate(iterable) | Any iterable + optional start | Pairs of (index, value) | No | Loop with automatic index tracking |
| zip(iter1, iter2) | Two or more iterables | Pairs of matched items | No | Combine parallel lists |
| int() / float() / str() | Compatible data value | Converted value in new type | No — returns new value | Sanitising user input from input() |
| max() / min() | A list or multiple arguments | The largest or smallest value | No | Finding extremes in exam scores, prices, etc. |
| sum(iterable) | A list of numbers | Their total as a number | No | Totalling prices, scores, distances |
| isinstance(obj, type) | An object and a type | True or False | No | Defensive checks before type-specific operations |
🎯 Key Takeaways
- Python's 68 built-in functions are pre-loaded before your script runs — you never need to import them. They exist because the same fundamental operations appear in virtually every Python program ever written.
- input() always returns a string, full stop. Wrap it with int() or float() any time you need to do arithmetic on user input — skipping this step causes one of the most common TypeError crashes beginners encounter.
- sorted() returns a new list and never touches the original; list.sort() modifies in place and returns None. Getting this backwards silently overwrites your data with no error message — a hard-to-debug bug.
- range(start, stop) is exclusive of the stop value — range(1, 5) gives 1, 2, 3, 4. For loops that are one iteration short are almost always caused by this. Add 1 to your intended endpoint to fix it.
- help() and dir() are built-in functions that turn Python into a self-documenting language. Use help(any_function) to read the official description without leaving your editor, and dir(any_object) to discover every method available on it.
⚠ Common Mistakes to Avoid
- ✕Mistake 1: Forgetting that input() always returns a string — If you write age = input('Enter age: ') and then try age + 5, Python throws: TypeError: can only concatenate str (not 'int') to str. Fix it by wrapping with int(): age = int(input('Enter age: ')). For decimals, use float() instead.
- ✕Mistake 2: Confusing sorted() with .sort() and losing data — Calling my_list.sort() modifies the list in-place and returns None. So if you write new_list = my_list.sort(), new_list is None and your original list is permanently reordered. Fix: use new_list = sorted(my_list) when you need to preserve the original.
- ✕Mistake 3: Using range() and expecting it to include the stop value — range(1, 5) produces [1, 2, 3, 4], not [1, 2, 3, 4, 5]. This silently produces wrong loop counts — no error, just missing the last item. Fix: always add 1 to your intended end value: range(1, 6) to count from 1 through 5 inclusive.
- ✕Mistake 4: Calling print() and assuming the return value is useful — print() always returns None. So if you write result = print('hello'), result is None, not 'hello'. Built-ins that perform actions (print, list.sort, list.append) return None. Built-ins that compute something (len, max, sorted) return useful data. Learn which group each function falls into.
Interview Questions on This Topic
- QWhat is the difference between sorted() and list.sort() in Python? When would you choose one over the other?
- QWhy does input() always return a string, and what error would you get if you forgot to convert it before doing arithmetic?
- QIf I call print(len('hello')), how many function calls are happening on that single line, and in what order does Python evaluate them?
Frequently Asked Questions
How many built-in functions does Python have?
Python 3 ships with 68 built-in functions. They're all available without any import statement because Python loads them automatically via a special module called 'builtins' before your code runs. You can see the full list by running print(dir(__builtins__)) in any Python environment.
What is the difference between a built-in function and a regular function in Python?
A regular function is one you define yourself using the def keyword, or one that lives inside a module you have to import (like math.sqrt). A built-in function is pre-written by the Python core team, compiled into Python itself, and available everywhere with no import needed. Built-ins are typically faster than pure Python equivalents because many are implemented in C under the hood.
Can I overwrite a built-in function by accident?
Yes, and it's a sneaky bug. If you write list = [1, 2, 3], you've just overwritten the built-in list() function with a variable — now calling list('hello') will throw a TypeError because list is no longer a function in that scope. The fix is to never use built-in names (list, type, input, id, str, int, etc.) as variable names. Use descriptive names instead, like student_list or item_count.
Written and reviewed by senior developers with real-world experience across enterprise, startup and open-source projects. Every article on TheCodeForge is written to be clear, accurate and genuinely useful — not just SEO filler.