San python learning science

1, dict.get (key, default) >>> return key corresponding to the value of the corresponding dictionary, and if not, default is returned, this may be set to None

2, calendar.isleap (2019) >>> determines whether a leap year

. 3, the enumerate ( Sequence , [ Start = 0 ]) >>> subscripts and returns the corresponding element, sequence may be an iterative objects, start is the index of the starting position, e.g. enumerate ([1,2]), output: [(0,1), (1,2)]

4, map (function, Iterable, ...) >>> unpacking sequence, function is a function, the Iterable objects is iterative, for example map (int, str (184)), each digit returns; map (lambda x : int (x) ** 3, str (485)), the number of returns you

5, math.ceil (num) >>> rounding up

6, sorted (list) >>> returns a new list, the list in ascending order

7, x = set () >>> create a collection

8, x.add () >>> add elements to the collection

9, dir (itertools) >>> View All methods itertools module

10, itertools.combinations (iterable, i) >>> creates an iterator to return all iterable subsequence of length r of the sub-sequence, the returned items sorted from iterable inputted. For example, itertools.combinations ([1,2,3,4], 3), returns an iterator, it can be converted into a list of output "is selected from three randomly selected from the list all the permutations"

11, math.factorial (n) >>> factorial function, i.e., n!

12, binarySearch (list, num) >>> () value using a binary search function is built-in list in which num binarySearch

13, divmod (div, base) >>> the quotient and the remainder of the division result combined, e.g. divmod (7,2), the output is (3)

14, list.reverse () >>> reverse output in list

Guess you like

Origin www.cnblogs.com/BASE64/p/10961003.html