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


全部评论

相关推荐

这算盘打的
程序员小白条:都这样的,都是潜规则,你自己说可以实习一年就行了,实习可以随便跑路的
点赞 评论 收藏
分享
06-20 17:42
东华大学 Java
凉风落木楚山秋:要是在2015,你这简历还可以月入十万,可惜现在是2025,已经跟不上版本了
我的简历长这样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务