Python3 common built-in functions, python3 built-in
Mathematical Problems
- Abs (a): Obtain the absolute value. Abs (-1)
- Max (list): calculate the maximum value of list. Max ([1, 2, 3])
- Min (list): calculates the minimum value of list. Min ([1, 2, 3])
- Sum (list): Calculate the sum of list elements. Sum ([1, 2, 3]) >>> 6
- Sorted (list): sort, returns the sorted list.
- Len (list): list length, len ([1, 2, 3])
- Divmod (a, B): obtains the quotient and remainder. Divmod (5, 2) >>> (2, 1)
- Pow (a, B): obtains the number of squares. Pow (2, 3) >>> 8
- Round (a, B): returns the decimal number of a specified number of digits. A Indicates a floating point number, and B indicates the number of digits to be retained. Round (3.1415926, 2) >>> 3.14
- Range (a [, B]): generates an array from a to B, which is left closed and right open. Range () >>> [, 9]
Type conversion
- Int (str): Convert to int type. Int ('1')> 1
- Float (int/str): converts int or floating type to floating type. Float ('1') >>> 1.0
- Str (int): Convert to struct type. Str (1) >>> '1'
- Bool (int): Convert to boolean type. Str (0) >>> False str (None) >>> False
- Bytes (str, code): receives a string and returns a byte stream type in the encoding format. Bytes ('abc', 'utf-8') >>> B 'abc' bytes (u'crawler ', 'utf-8') >>> B '\ xe7 \ x88 \ xac \ xe8 \ x99 \ xab'
- List (iterable): converts to list. List (1, 2, 3) >>> [1, 2, 3]
- Iter (iterable): returns an iteratable object. Iter ([1, 2, 3]) >>< list_iterator object at 0x0000000003813B00>
- Dict (iterable): converts to dict. Dict ([('A', 1), ('B', 2), ('C', 3)]) >>>{ 'A': 1, 'B': 2, 'C': 3}
- Enumerate (iterable): returns an enumeration object.
- Tuple (iterable): Convert to tuple. Tuple ([1, 2, 3]) >>> (1, 2, 3)
- Set (iterable): converts to set. Set ([,]) >>>{, 5} set ({1: 'A', 2: 'B', 3: 'C'}) >>>{ 1, 2, 3}
- Hex (int): Convert to hexadecimal. Hex (1024) >>> '0x400'
- Oct (int): Convert to octal. Oct (1024) >>> '0o2000'
- Bin (int): converts to binary. Bin (1024) >>> '0b0000000000'
- Chr (int): converts a number to an ASCI character. Chr (65) >>> 'A'
- Ord (str): converts ASCI characters to numbers. Ord ('A')> 65
Related Operations
- Eval (): executes an expression or string as an operation. Eval ('1 + 1') >>> 2
- Exec (): Execute the python statement. Exec ('print ("Python") ')> Python
- Filter (func, iterable): filter matching elements by determining the function fun. Filter (lambda x: x> 3, [0000000003813828,]) >>> <filter object at 0 x>
- Map (func, * iterable): Use func for each iterable object. Map (lambda a, B: a + B, [1, 2, 3, 4], [5, 6, 7]) >>> [6, 8, 10]
- Zip (* iterable): combines the iterable group. Returns a zip object. List (zip ([, 3], [, 6]) >>> [(1, 4), (2, 5), (3, 6)]
- Type (): return the type of an object.
- Id (): return the Unique Identifier value of an object.
- Hash (object): returns the hash value of an object. An object with the same value has the same hash value. Hash ('python') >>> 7070808359261009780
- Help (): Call the built-in help system.
- Isinstance (): determines whether an object is an instance of this class.
- Issubclass (): determines whether a class is a subclass of another class.
- Globals (): returns the dictionary of the current global variable.
- Next (iterator [, default]): receives an iterator and returns the value in the iterator. If default is set, the default content is output after element traversal in the iterator.
- Reversed (sequence): generates an iterator that reverses the sequence. Reversed ('abc') >>> ['C', 'B', 'a']