0

Python code showing wrong output.

Why does this code show wrong output for large values of a? https://code.sololearn.com/c49KT4i04QC9/?ref=app

15th Jun 2021, 10:25 AM
SHIVANSH
SHIVANSH - avatar
3 Réponses
+ 1
Line 7: a //= 10 # use floor division for integral result
15th Jun 2021, 10:48 AM
Ipang
+ 1
Ipang Yes, It is working fine now. Thank you. But i am not able to understand why is int(a/b) different from a//b.
16th Jun 2021, 2:57 PM
SHIVANSH
SHIVANSH - avatar
0
Shivansh, Simply because / results in float value, whereas // results in int value. When extracting digits that way, we don't want float value from division, just int value. Although // can also result in float when one or more of the operands were float. https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/4430/
16th Jun 2021, 4:51 PM
Ipang