1.形参和实参的一些问题
2.另外,了解到list默认为可变类型的,append函数是原地修改对象的。故可在方法内修改外传进来的list
Last login: Fri Aug 11 08:51:47 on console
bingjun1:~ bingjun$ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> y = math.sqrt
>>> print y(4)
2.0
>>> callable(y)
True
>>> callable(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name ‘x‘ is not defined
>>> x = 1
>>> callable(x)
False
>>> def hello(name):
... return (‘str1‘,‘str2‘)
... hello(‘ad‘)
File "<stdin>", line 3
hello(‘ad‘)
^
SyntaxError: invalid syntax
>>> def hello(name):
... return (‘str1‘,‘str2‘)
...
>>> hello(‘ad‘)
(‘str1‘, ‘str2‘)
>>> def hello(name):
... return [‘str1‘,‘str2‘]
...
>>> hello(‘asdf‘)
[‘str1‘, ‘str2‘]
>>> help(hello)
>>> hellp(hello)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name ‘hellp‘ is not defined
>>> help(hello)
>>> help(hello)
>>> def hello(name):
... ‘test 文档字符串‘
... return ‘name‘
...
>>> hello.__doc__
‘test \xe6\x96\x87\xe6\xa1\xa3\xe5\xad\x97\xe7\xac\xa6\xe4\xb8\xb2‘
>>> help(hello)
>>> help(hello)
>>> help(sqrt)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name ‘sqrt‘ is not defined
>>>
>>> def appendList(list)
File "<stdin>", line 1
def appendList(list)
^
SyntaxError: invalid syntax
>>> def appendList(list):
... list.append(4)
...
>>> list = [1, 2, 3]
>>> appendList(list)
>>> list
[1, 2, 3, 4]
>>> def appendList(list):
... list = ‘shuai‘
...
>>> list = he
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name ‘he‘ is not defined
>>> list = ‘he‘
>>> appendList(list)
>>> list
‘he‘
>>> liston;