Built-in Functions
Python comes with dozens of built-in functions — no import needed. They help you transform, measure, or convert values in one line of code.
In this chapter, weєll group these functions by purpose — numbers, text, types, and collections.
- Give code examples using int, float, str, and bool to convert different types.
- Give code examples using abs and round with different numbers.
- Give code examples using lower, strip, replace, split, and join on strings.
- Give code examples using len, max, min, and sum with a list of numbers.
- Give code examples using enumerate, zip, map, and filter with lists.
Converting Data Types
These functions let you convert between basic types:
int()
— to integer;float()
— to float;str()
— to string;bool()
— to Boolean.
Useful when working with input, formatting, or expressions.
Working with Numbers
These help clean or adjust numeric values:
abs()
— absolute value (removes minus sign);round()
— rounds floats to nearest whole or to decimals.
Working with Strings
These are commonly used for cleaning and formatting text:
lower()
— make all letters lowercase;upper()
— make all letters uppercase;strip()
— remove spaces at the beginning and end;replace()
— replace part of a string with another;split()
— turn a string into a list of words;join()
— combine list items into one string.
Collection Inspection
These return information about a list, tuple, or other iterable:
len()
— count items;max()
— largest value;min()
— smallest value;sum()
— total of all numbers.
Collection Transformation
These are helpful when looping, combining, or transforming collections:
sorted()
— returns sorted list;enumerate()
— adds index numbers;zip()
— pairs items from multiple lists;range()
— creates a sequence of numbers;map()
— applies a function to each item;filter()
— keeps items that meet a condition.
Summary
- Python's built-in functions save you time and code;
- You can convert data, adjust text, transform collections, and get answers instantly;
- These tools become essential as you build more complex programs.
Try It Yourself
- Convert the string
"42"
to an integer usingint()
, and then to a float usingfloat()
; - Use
abs()
andround()
on the number-5.8
to clean and format it; - Take the string
" Hello, World! "
and applystrip()
,lower()
, andreplace()
to tidy and modify it; - Create a list of numbers:
[3, 7, 2, 9]
. Uselen()
,max()
, andsum()
to inspect it; - Use
enumerate()
to loop over the list and print both index and value. Then usemap()
to double each item.
Bedankt voor je feedback!
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 5
Built-in Functions
Veeg om het menu te tonen
Python comes with dozens of built-in functions — no import needed. They help you transform, measure, or convert values in one line of code.
In this chapter, weєll group these functions by purpose — numbers, text, types, and collections.
- Give code examples using int, float, str, and bool to convert different types.
- Give code examples using abs and round with different numbers.
- Give code examples using lower, strip, replace, split, and join on strings.
- Give code examples using len, max, min, and sum with a list of numbers.
- Give code examples using enumerate, zip, map, and filter with lists.
Converting Data Types
These functions let you convert between basic types:
int()
— to integer;float()
— to float;str()
— to string;bool()
— to Boolean.
Useful when working with input, formatting, or expressions.
Working with Numbers
These help clean or adjust numeric values:
abs()
— absolute value (removes minus sign);round()
— rounds floats to nearest whole or to decimals.
Working with Strings
These are commonly used for cleaning and formatting text:
lower()
— make all letters lowercase;upper()
— make all letters uppercase;strip()
— remove spaces at the beginning and end;replace()
— replace part of a string with another;split()
— turn a string into a list of words;join()
— combine list items into one string.
Collection Inspection
These return information about a list, tuple, or other iterable:
len()
— count items;max()
— largest value;min()
— smallest value;sum()
— total of all numbers.
Collection Transformation
These are helpful when looping, combining, or transforming collections:
sorted()
— returns sorted list;enumerate()
— adds index numbers;zip()
— pairs items from multiple lists;range()
— creates a sequence of numbers;map()
— applies a function to each item;filter()
— keeps items that meet a condition.
Summary
- Python's built-in functions save you time and code;
- You can convert data, adjust text, transform collections, and get answers instantly;
- These tools become essential as you build more complex programs.
Try It Yourself
- Convert the string
"42"
to an integer usingint()
, and then to a float usingfloat()
; - Use
abs()
andround()
on the number-5.8
to clean and format it; - Take the string
" Hello, World! "
and applystrip()
,lower()
, andreplace()
to tidy and modify it; - Create a list of numbers:
[3, 7, 2, 9]
. Uselen()
,max()
, andsum()
to inspect it; - Use
enumerate()
to loop over the list and print both index and value. Then usemap()
to double each item.
Bedankt voor je feedback!