Python Functions with Examples
Here is a clear and beginner-friendly list of common Python functions with examples,
grouped by category. This is useful for students, beginners, and interview preparation.
1️⃣ Built-in Python Functions (Most Used)
print()
print("Hello, World")
input()
name = input("Enter your name: ")
print(name)
len()
text = "Python"
print(len(text)) # Output: 6
type()
x = 10
print(type(x)) # Output: <class 'int'>
range()
for i in range(5):
print(i)
2️⃣ Math & Number Functions
abs()
print(abs(-10)) # Output: 10
max() / min()
numbers = [5, 10, 2]
print(max(numbers)) # 10
print(min(numbers)) # 2
sum()
numbers = [1, 2, 3]
print(sum(numbers)) # 6
round()
print(round(3.456, 2)) # 3.46
3️⃣ String Functions
upper() / lower()
text = "Python"
print([Link]())
print([Link]())
strip()
text = " hello "
print([Link]())
replace()
text = "I like Java"
print([Link]("Java", "Python"))
split()
text = "Python is easy"
print([Link]())
4️⃣ List Functions
append()
fruits = ["apple", "banana"]
[Link]("orange")
print(fruits)
insert()
[Link](1, "grape")
remove()
[Link]("banana")
sort()
numbers = [3, 1, 2]
[Link]()
print(numbers)
5️⃣ Dictionary Functions
keys() / values()
data = {"name": "Alex", "age": 25}
print([Link]())
print([Link]())
get()
print([Link]("age"))
6️⃣ Tuple & Set Functions
count() (Tuple)
t = (1, 2, 2, 3)
print([Link](2))
add() (Set)
s = {1, 2, 3}
[Link](4)
print(s)
7️⃣ File Handling Functions
open()
file = open("[Link]", "w")
[Link]("Hello Python")
[Link]()
read()
file = open("[Link]", "r")
print([Link]())
8️⃣ User-Defined Functions
Function without arguments
def greet():
print("Hello")
greet()
Function with arguments
def add(a, b):
return a + b
print(add(5, 3))
9️⃣ Lambda (Anonymous) Functions
add = lambda a, b: a + b
print(add(4, 6))
🔟 Useful Utility Functions
enumerate()
fruits = ["apple", "banana"]
for index, value in enumerate(fruits):
print(index, value)
zip()
names = ["A", "B"]
marks = [90, 85]
print(list(zip(names, marks)))
✅ Want more?
I can also:
Create a PDF version for download
Give 100 Python functions cheat sheet
Provide interview-focused examples
Explain functions in Malayalam
Provide real-world mini projects using functions
Just tell me 😊