第419页 | Learning Python | 阅读 ‧ 电子书库

同步阅读进度,多语言翻译,过滤屏幕蓝光,评论分享,更多完整功能,更好读书体验,试试 阅读 ‧ 电子书库

Test Your Knowledge: Quiz

 

 
What is the output of the following code, and why?

>>> def func(a, b=4, c=5):
...     print(a, b, c)
...
>>> func(1, 2)

What is the output of this code, and why?

>>> def func(a, b, c=5):
...     print(a, b, c)
...
>>> func(1, c=3, b=2)

How about this code: what is its output, and why?

>>> def func(a, *pargs):
...     print(a, pargs)
...
>>> func(1, 2, 3)

What does this code print, and why?

>>> def func(a, **kargs):
...     print(a, kargs)
...
>>> func(a=1, c=3, b=2)

One last time: what is the output of this code, and why?

>>> def func(a, b, c=3, d=4): print(a, b, c, d)
...
>>> func(1, *(5,6))

Name three or more ways that functions can communicate results to a caller.

请支持我们,让我们可以支付服务器费用。
使用微信支付打赏


上一页 · 目录下一页


下载 · 书页 · 阅读 ‧ 电子书库