贊助

Donate

搜尋此網誌

贊助本站

Donate

2018年4月3日 星期二

Python: None

min

The usage of None

In [2]:
def min(values):
    s=None
    for i in values:
        if s is None or i <s:
            s=i
    return s
In [6]:
min([1,2,3])
Out[6]:
1
In [25]:
min([5,3,7,2,12,7,8,9,11])
Out[25]:
2
In [18]:
x=(None,1,2,3)
In [19]:
x
Out[19]:
(None, 1, 2, 3)
In [20]:
for i in x:
    print(i)
None
1
2
3
In [21]:
x
Out[21]:
(None, 1, 2, 3)
In [22]:
x[2]
Out[22]:
2
In [23]:
x[3]
Out[23]:
3
In [24]:
len(x)
Out[24]:
4

沒有留言:

張貼留言

C3 plot package

R:C3 plot Peter Lin 2018-06-02 library (ggplot2) x=c( "vs" , "cyl" , "carb" , "gear" ) for...

Donate-2

Donate-2