The path of small white growth: first knowledge python (iii)-----------Python built-in functions

Source: Internet
Author: User
Tags chr iterable pow

I just looked at it and someone else read my blog ^-^

Needless to say, on the code, there is no right to spray, after all, I really was small white

# Python built-in function collation

# returns the absolute value of a number
# a = ABS (-10)
# Print (a)

# passes in an iterative object that returns True if every element of the object is True
# ret = ALL ([1, 2, 3, 4])
# Print (ret)

# to pass in an iterator object that returns true if there is a true element in the object
# ret = any ([None, ', [], {},1])
# Print (ret)

# # #不同进制之间的转换
# Print (Bin (10)) conversion to binary
# 0b1010
# Print (Oct (10)) Convert decimal to octal
# 0o12
# Print (Hex (10)) converts decimal to hexadecimal
# 0xa

# ret = bytes (' Day ', encoding= ' utf-8 ') convert characters to byte form
# Print (ret)
# b ' \xe5\xa4\xa9 '

#############################################
#chr () converts 0~255 to characters that are encoded in ASCII code
# Print (Chr (66))
# B

# ret = Ord (' A ') converts the character to its ASCII code value
# Print (ret)
# 97
##############################################

#帮助 command
# print (list) simple way to view objects
# print (Help list) How to view objects in detail

###############################################

# globals () view global variables in the current code
# locals () nearly local variables in the current code

###############################################

# enumerate (iterable,start = 0) generates an index default of 0 for an object that can be iterated
# li = [11,22,33,44]
# for _,i in Enumerate (LI):
# Print (_,i)
# 0 11
# 1 22
# 2 33
# 3 44

################################################
# Divmod (A, B)
# A, B = Divmod (10,3)
# print (A, B)
# 3 1
# A is 10/3 quotient, B is the remainder

####################################################

# ret = eval (' 3 + 1 ') can execute string-form expressions with return values
# Print (ret)
# 4

###################################################
# ret = filter (function=,iterable=)
#遍历可迭代对象中的某一个元素, as a function parameter, if the function is executed and returned as true
# returns the element, the RET object cannot be read directly
# A simple function body can be used with lambda expressions
# def func (x):
# return x > 22
# ret = filter (func,[22,33,66])
# for I in RET:
# Print (i)
# 33
# 66
# ###########
# ret = filter (lambda x:x > 22, [22,33,66])
# for I in RET:
# Print (i)
# 33
# 66

#####################################################
# map (func=,iter1=,iter2=) iterates through each element of the Iterable object, executes the function
# Returns a new value
# def func (x):
# return x + 10
# Ret1 = Map (func,[1,2,3,])
# for I in Ret1:
# Print (i)
# 11
# 12
# 13
# Simple functions can also be used with lambda expressions
#######################################################
# max () to find the maximum value of the Iterable object
# min () ...... ..... Minimum value

# POW () exponentiation
# ret = POW (2,10)
# Print (ret)
# 1024

# round () rounding
# sum () sum
# len ()

#######################################################
# ID () take address
# isinstance () to determine whether an object belongs to a class, returns a Boolean value
# L1 = []
# ret = isinstance (l1,list)
# Print (ret)
# True

#######################################################

The path of small white growth: first knowledge python (iii)-----------Python built-in functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.