Vimal Thapliyal’s Post

One difference that trips people up in Python: / always returns a float. // always returns an integer. So 10 / 2 is 5.0, not 5. If you want a whole number, use //. Same with %: it gives the remainder, not the quotient. So 15 % 4 is 3 (the remainder), and 15 // 4 is 3 (how many times 4 fits). Together: quotient × divisor + remainder = dividend. I put together a complete guide to all seven arithmetic operators: +, -, , , /, //, %. With examples, float vs floor division, modulus, power, and common mistakes. Read it here: https://lnkd.in/gdP_qRbX #Python #Coding #Developer

To view or add a comment, sign in

Explore content categories