Simple Python Built-in Functions

 

>>>ord('a') - ord('A')
32
>>>chr(98)  
'b'  
#chr(code ) function return the character represent by the code  
>>> str(98)  
'98'  
#notice the difference between str() and chr()  

chr()
ord()
str()
abs(x)    #return the absolute value for x
max(x1,x2,...) #return the largest among x1,x2,. . .  
min(x1,x2,...) #return thesmallest among x1,x2,. . .  
pow(a,b) #return a**b</p>  
round(x,n) #return the float value rounded to n digits after the decimal point  
round(x) #Return an integer nearest to x. If x is equally close to two integers,the even one is returned  

>>>abs(-2)   # is 2
>>>max(1,5,2)# is 5  
>>>min(1, 5, 2) # is 1  
>>>pow(2, 3) #is 8  
>>>round(5.5) #is 6  
>>>round(5.4) # is 5  
>>>round(4.5) #is 4  
>>>round(5.446,2) #is 5.45  
>>>round(5.443,2) # is 5.44


你可能感兴趣的:(Simple Python Built-in Functions)