Built-In Functions
Built-in functions in Python are predefined and available for use without any additional setup. One example is the print() function, which you have already used. You do not need to define it, write its body, or specify its return value β you simply call it and provide inputs.
Here are some of the most commonly used built-in functions:
print(): Outputs a specified message or variable to the console.
1print("My message")
len(): Returns the number of elements in an object, such as a string, list, or tuple.
12word = "Codefinity" print("Word length:", len(word))
sum(): Computes the total of a sequence of numbers.
12numbers = [5, 2, 3] print("Sum of numbers:", sum(numbers))
max() and min(): Return the maximum or minimum value from a sequence.
123numbers = [5, 2, 3] print("The largest among the numbers:", max(numbers)) print("The smallest of the numbers:", min(numbers))
You might already be familiar with these functions, or perhaps not. The key in this chapter is to understand the difference between built-in functions and those you create yourself.
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 4.17
Built-In Functions
Swipe to show menu
Built-in functions in Python are predefined and available for use without any additional setup. One example is the print() function, which you have already used. You do not need to define it, write its body, or specify its return value β you simply call it and provide inputs.
Here are some of the most commonly used built-in functions:
print(): Outputs a specified message or variable to the console.
1print("My message")
len(): Returns the number of elements in an object, such as a string, list, or tuple.
12word = "Codefinity" print("Word length:", len(word))
sum(): Computes the total of a sequence of numbers.
12numbers = [5, 2, 3] print("Sum of numbers:", sum(numbers))
max() and min(): Return the maximum or minimum value from a sequence.
123numbers = [5, 2, 3] print("The largest among the numbers:", max(numbers)) print("The smallest of the numbers:", min(numbers))
You might already be familiar with these functions, or perhaps not. The key in this chapter is to understand the difference between built-in functions and those you create yourself.
Thanks for your feedback!