Strictly speaking, a function can only return one value, but if the value is a tuple, the effect is the same as returning multiple values. For example, if you want to divide two integers and compute the quotient and remainder, it is inefficient to compute x/y and then x%y. It is better to compute them both at the same time. The built-in function divmod takes two arguments and returns a tuple of two values, the quotient and remainder. You can store the result as a tuple:

Here is an example of a function that returns a tuple:

max and min are built-in functions that find the largest and smallest elements of a sequence. max_min computes both and return a tuple of two values.

from Thinking in Python

最新文章

  1. PHP 知识结构
  2. 重温Javascript第一章
  3. HDU1004 BALLO0N
  4. 使用 Fiddler2 进行接口测试的方法
  5. php Memcache
  6. mysql open files
  7. libaio under MIPS architecture /在mips架构下使用的libaio
  8. LDA 资料整理
  9. unity与ios交替
  10. 《无所不能的JavaScript编程系列:arguments 参数对象》
  11. OOP in Javascript
  12. iOS Xcode及模拟器SDK下载
  13. 搭建nuxtjs程序 —— 用户信息 or token怎么不丢失
  14. SAM维护的在线LCS
  15. linux tar解压命令
  16. Linux内核基础
  17. FileZilla建立服务器,命令行客户端
  18. python3-知识扩展扫盲易忘-generator的用法
  19. for循环实例2
  20. c++中“箭头(->)”和“点号(.)”操作符的区别

热门文章

  1. Go语言Slice操作.
  2. 1)Win10-UWA开发 UWP应用操作方法、Windows 10应用程序的指南
  3. 基于对话框的应用程序,点击button打开一个网页
  4. 问题集锦 ~ jQuery
  5. (转载)android控件之WebView控件缩小
  6. MySQL学习(五)——使用JDBC完成用户表CRUD的操作
  7. 【原创】VSFTP: Login failure: 530 Login incorrect的解决办法
  8. php面向对象的基础:OOP的常量
  9. hiho151周*
  10. eclipse oxygen离线安装activiti