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
3 Antworten
+ 1
Line 7:
a //= 10 # use floor division for integral result
+ 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.
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/