Sunday, November 1, 2015

exercises in python

---join
In [4]: a
Out[4]: ['1', '2', '3', '4']

In [6]: ',tail'.join(a)
Out[6]: '1,tail2,tail3,tail4'

--dictionary
In [20]: dict
Out[20]: {'H1': 'H1 UL1 [%]', 'H2': 'H2 UL1 [%]'}

In [21]: for i in dict: print dict[i]
H2 UL1 [%]
H1 UL1 [%]


 ---type
>> type([]) is list
True
>>> type({}) is dict
True
>>> type('') is str
True
>>> type(0) is int
True
>>> type({})

>>> type([])

>> type([]) is list
True
>>> type({}) is dict
True
>>> type('') is str
True
>>> type(0) is int
True
>>> type({})

>>> type([])


---utilities
In [3]: print int("0x3cf",0)  python hex to int

No comments: