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


全部评论

相关推荐

迷茫的大四🐶:好一个误闯天家,我也想闯一闯
点赞 评论 收藏
分享
10-22 12:03
山东大学 Java
程序员小白条:26届一般都得有实习,项目可以随便写的,如果不是开源社区的项目,随便包装,技术栈也是一样,所以本质应该找学历厂,多投投央国企和银行,技术要求稍微低一点的,或者国企控股那种,纯互联网一般都得要干活
应届生简历当中,HR最关...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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