Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part.1.E.4.functions.ipynb 中 divmod函数的返回值说明 #1011

Open
jingmian opened this issue Oct 23, 2020 · 1 comment
Open

Part.1.E.4.functions.ipynb 中 divmod函数的返回值说明 #1011

jingmian opened this issue Oct 23, 2020 · 1 comment

Comments

@jingmian
Copy link

jingmian commented Oct 23, 2020

在作者解释 divmod函数时提到
它的返回值,是一个元组(Tuple,至于这是什么东西,后面讲清楚),其中包括两个值,第一个是商,第二个是余 —— 此为该函数的输出。
而我根据英文文档 ,找不到Tuple返回值这样的关键字,我们新手又如何在这个英文文档中,知道它是返回 元组 呢?

Take two (non complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using integer division. With mixed operand types, the rules for binary arithmetic operators apply. For integers, the result is the same as (a // b, a % b). For floating point numbers the result is (q, a % b), where q is usually math.floor(a / b) but may be 1 less than that. In any case q * b + a % b is very close to a, if a % b is non-zero it has the same sign as b, and 0 <= abs(a % b) < abs(b).
@bing90740
Copy link

bing90740 commented Nov 10, 2020

用python内建函数type,可以看到数据类型。

type(divmod(11,3))

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants