Built-in Functions

As mentioned above the Python programming language like many others has a number of important built-in functions that we can use without needing to provide the function definition. The programmers who created Python included a set of functions to solve common problems and included them in Python so we can use them. The functions such as: print, type, int, str, raw_input we already met. Now we’ll introduce a couple more.
The max and min functions give us the largest and smallest values in a list, respectively:
>>>max(“Hello world!”)
‘w’
>>>min(“Hello world!”)
‘ ‘
The max functions tells us the “largest character” in the string and the min functions shows us the smallest character which turns out to be a space.
Another common built-in function is len functions which gives us information of how many items are in its argument. If the argument to len is a string, it returns the number of characters in the string.
>>>len(“Hello world!”)
12
You should avoid the names of built-in functions as reserved words (AVOID USING BUILT-IN FUNCTION NAMES FOR YOUR FUNCTIONS OR NAME OF VARIABLES). The list of built-in function in standard Python 2.7.11 are:




Nema komentara:

Objavi komentar