CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day06/function3.py
Views: 729
1
"""
2
Python的内置函数
3
- 数学相关: abs / divmod / pow / round / min / max / sum
4
- 序列相关: len / range / next / filter / map / sorted / slice / reversed
5
- 类型转换: chr / ord / str / bool / int / float / complex / bin / oct / hex
6
- 数据结构: dict / list / set / tuple
7
- 其他函数: all / any / id / input / open / print / type
8
9
Version: 0.1
10
Author: 骆昊
11
Date: 2018-03-05
12
"""
13
14
15
def myfilter(mystr):
16
return len(mystr) == 6
17
18
19
# help()
20
print(chr(0x9a86))
21
print(hex(ord('骆')))
22
print(abs(-1.2345))
23
print(round(-1.2345))
24
print(pow(1.2345, 5))
25
fruits = ['orange', 'peach', 'durian', 'watermelon']
26
print(fruits[slice(1, 3)])
27
fruits2 = list(filter(myfilter, fruits))
28
print(fruits)
29
print(fruits2)
30
31