# This is a learning note for the Liaoche teacher Python tutorial
Functions are the most basic form of code abstraction. Python is not only very flexible in defining functions, but it has built in many useful functions that can be called directly.
1. Calling Python intrinsics
Python has built in a lot of useful functions that we can call directly.
To invoke a function, you need to know the name and parameters of the function, such as the function abs with absolute value, only one parameter
Call the ABS function:
>>>abs (100)
100
>>>abs (-20)
20
>>>abs (12.34)
12.34
Note: When calling a function, if the incoming parameter number and parameter type are incorrect, an error will be
Call the Max function:
>>>max (1, 2)
2
>>>max (2, 3, 1,-5)
3
Data type conversion functions (int, float, str, BOOL)
>>>int (' 123 ')
123
>>>int (12.34)
12
>>>float (' 12.34 ')
12.34
>>>STR (1.23)
' 1.23 '
>>>STR (100)
' 100 '
>>>bool (1)
True
>>>bool (")
False
The nature of the function name:
The function name is actually a reference to a function object, assigning the function name to a variable, which is equivalent to giving the function an "alias".
>>>A = ABS # variable a points to ABS function
>>>a (-1) # So you can also call the ABS function by a
1
2. Examples
Use the Python built-in hex () function to convert an integer to a hexadecimal-represented string
#-*-Coding:utf-8-*-
N1 = 255
N2 = 1000
Print (Hex (N1))
Print (Hex (n2))
3. Reference documents
Built-in functions in Python (https://docs.python.org/3/library/functions.html)
Python Learning note __2.1 Call function