Skip to content

Commit

Permalink
divmod(2,5)=(0,2)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiwsir committed Aug 26, 2014
1 parent b7bc161 commit 2d6bc96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion BasicPython/104.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

看到没有?麻烦出来了,如果从小学数学知识除法,以上四个运算结果都应该是0.4。但我们看到的后三个符合,第一个居然结果是0。why?

因为,在python里面有一个规定,像2/5中的除法这样,是要取整。2除以5,商是0(整数),余数是5(整数)。那么如果用这种形式:2/5,计算结果就是商那个整数。或者可以理解为:**整数除以整数,结果是整数(商)**
因为,在python里面有一个规定,像2/5中的除法这样,是要取整。2除以5,商是0(整数),余数是2(整数)。那么如果用这种形式:2/5,计算结果就是商那个整数。或者可以理解为:**整数除以整数,结果是整数(商)**

继续实验,验证这个结论:

Expand Down

0 comments on commit 2d6bc96

Please sign in to comment.