Skip to main content

Python Built-in Functions (without Import)

🧠 Python has a variety of built-in functions (so-called built-in functions) and standard methods that you can use directly without importing anything. They are the toolkit for every Python beginner – and perfect for your students!


🧰 Python Built-in Functions (without Import)
#

Here are the most important built-in functions with brief explanations:

🔧 Function 🧩 Description 🧪 Example
print() Outputs text to the screen print("Hello World")
input() Gets input from the user name = input("What's your name? ")
len() Returns the length of an object len("Python")
type() Shows the data type of a value type(42)
int() Converts to an integer int("5")
float() Converts to a float float("3.14")
str() Converts to a string str(100)
bool() Converts to a boolean value bool("") → False
list() Creates a list list("abc") → ['a', 'b', 'c']
dict() Creates a dictionary dict(name="Lena", age=12)
set() Creates a set (without duplicates) set([1, 2, 2, 3]) → {1, 2, 3}
tuple() Creates a tuple tuple([1, 2]) → (1, 2)
range() Generates a number sequence range(5) → 0,1,2,3,4
sum() Adds all numbers in a list sum([1, 2, 3]) → 6
max() Largest value max([3, 7, 2]) → 7
min() Smallest value min([3, 7, 2]) → 2
abs() Absolute value abs(-5) → 5
round() Rounds a number round(3.14159, 2) → 3.14
sorted() Sorts a list sorted([3, 1, 2]) → [1, 2, 3]
reversed() Reverses a sequence list(reversed([1, 2, 3])) → [3, 2, 1]
enumerate() Returns index + value for i, v in enumerate(["a", "b"])
zip() Combines multiple lists zip([1,2], ["a","b"])
help() Shows help for an object help(str)
id() Memory address of an object id(x)
eval() Executes a string as Python code eval("2 + 2") → 4
isinstance() Checks type of an object isinstance(5, int) → True

📦 Common Methods for Standard Data Types
#

🔤 String Methods
#

text = "Python"
text.upper()       # "PYTHON"
text.lower()       # "python"
text.startswith("Py")  # True
text.replace("Py", "My")  # "Mython"
text.split("t")    # ['Py', 'hon']

📋 List Methods
#

numbers = [1, 2, 3]
numbers.append(4)   # [1, 2, 3, 4]
numbers.pop()       # removes last element
numbers.sort()      # sorts the list
numbers.reverse()   # reverses the order

📘 Dictionary Methods
#

info = {"name": "Lena", "age": 12}
info.keys()        # dict_keys(['name', 'age'])
info.values()      # dict_values(['Lena', 12])
info.get("name")   # "Lena"
info.update({"class": 6})

🔢 Set Methods
#

s = {1, 2, 3}
s.add(4)
s.remove(2)
s.union({5, 6})     # {1, 3, 4, 5, 6}

🧠 Tip for Students:
#

Functions = Tools that you call
Methods = Tools that you use on an object