>>> fruit = ['apple','banana','clementine']
>>> H = len(fruit)
>>> for x in range(0,H):
... print('the exple %s is %s' %(x,fruit[x]))
#运行结果:
the exple 0 is apple
the exple 1 is banana
the exple 2 is clementine
>>> float(0.23)
0.23
>>> float(3.1415)
3.1415
>>> float(5)
5.0
>>> float(6.0)
6.0
>>> print(abs(5))
5
>>> print(abs(-5))
5
>>> print(abs(a))
Traceback (most recent call last):
File "
", line 1, in
NameError: name 'a' is not defined
>>> print(abs('a'))
Traceback (most recent call last):
File "
", line 1, in
TypeError: bad operand type for abs(): 'str'
姐姐姐姐姐姐姐姐姐姐姐姐姐姐姐姐
>>> bool(0)
False
>>> bool(2)
True
>>> bool(5)
True
>>> bool(a)
Traceback (most recent call last):
File "
", line 1, in
NameError: name 'a' is not defined
>>> bool('a')
True
>>> bool() #不输入任何值
False
>>> bool('') #引号中不含任何字符
False
>>> bool(' ') #引号中一个空格
True
>>> bool('hello')
True
>>> bool(hello)
Traceback (most recent call last):
File "
", line 1, in
NameError: name 'hello' is not defined
>>> bool(None)
False