Course Progress35%
🍎 Python Basics Topic 35 / 100
⏳ 7 min read

Built-in Functions

Python comes with powerful ready-to-use functions. These are the most important ones every Python programmer uses daily.

"Python ships with over 60 built-in functions. You don't need to import anything — they are just there, ready to use."

— ShurAI

Type and Conversion

python
print(type(42))           # <class 'int'>
print(type("hello"))      # <class 'str'>

print(int("99"))           # 99   — string to int
print(float("3.14"))      # 3.14 — string to float
print(str(100))            # "100" — int to string
print(bool(0))             # False
print(bool("hello"))       # True
print(list("abc"))         # ['a', 'b', 'c']

Maths

python
nums = [5, 2, 9, 1, 7]

print(len(nums))           # 5   — count of items
print(sum(nums))           # 24  — total
print(max(nums))           # 9   — largest
print(min(nums))           # 1   — smallest
print(abs(-15))            # 15  — absolute value
print(round(3.7654, 2))   # 3.77
print(pow(2, 8))            # 256 — 2 to the power of 8

Sequences & Iteration

python
fruits = ["mango", "apple", "guava"]

# range() — number sequence
print(list(range(5)))        # [0, 1, 2, 3, 4]

# enumerate() — index + value
for i, fruit in enumerate(fruits, 1):
    print(f"{i}. {fruit}")    # 1. mango  2. apple  3. guava

# zip() — pair two lists together
names  = ["Riya", "Arjun", "Sneha"]
scores = [88, 75, 92]
for name, score in zip(names, scores):
    print(f"{name}: {score}")

# sorted() — returns sorted copy
print(sorted([3,1,4,1,5]))        # [1, 1, 3, 4, 5]
print(sorted(fruits, reverse=True)) # ['mango', 'guava', 'apple']

# reversed() — iterate in reverse
print(list(reversed(fruits)))     # ['guava', 'apple', 'mango']

Input, Output & Inspection

python
# input() — get user input
name = input("Your name: ")

# print() — display output
print("Hello", name)

# len() — length of anything
print(len("Python"))   # 6
print(len([1,2,3]))    # 3
print(len({"a":1}))    # 1

# id() — memory address (useful for debugging)
x = 42
print(id(x))           # unique number like 140234567890

# isinstance() — check if value is a certain type
print(isinstance(42, int))      # True
print(isinstance("hi", str))    # True
print(isinstance(3.14, int))    # False

Quick Reference Table

Function Does Example
len(x)Length / countlen([1,2,3]) → 3
range(n)Number sequencerange(3) → 0,1,2
sorted(x)Sorted copysorted([3,1,2]) → [1,2,3]
enumerate(x)Index + value pairsfor i, v in enumerate(lst)
zip(a, b)Pair two sequenceszip([1,2], ["a","b"])
isinstance(x,t)Type checkisinstance(5, int) → True
abs(x)Absolute valueabs(-9) → 9

"Before writing any function from scratch, ask: does Python already have this built in? Most of the time, it does."

— ShurAI

🧠 Quiz — Q1

What does len([10, 20, 30, 40]) return?

🧠 Quiz — Q2

What does zip(["a","b"], [1, 2]) produce when looped?

🧠 Quiz — Q3

What does isinstance("hello", int) return?

🧠 Quiz — Q4

What is the result of sorted([5, 2, 8, 1], reverse=True)?