How Python calculates % function? can some one please explain 3%5 outcome as 3 in Python? Answer for 5%3 is also showing 3. I use python 2.7
            Asked
            
        
        
            Active
            
        
            Viewed 46 times
        
    -1
            
            
        - 
                    1`5%3` should be equal to 2. `%` is modulo operator as in C, C++ and Java. See http://stackoverflow.com/questions/4432208/how-does-work-in-python – George Sovetov Apr 08 '16 at 13:18
1 Answers
0
            
            
        The Python % operator isn't percentage, it's modulo.  That means the remainder part of a division. Remember when you were a kid and your math problems would be like 11 divided by 3 = 3 R 2 (remainder 2)?  That's what % does.  5 % 3 = 2.
If you want to calculate percentage, do that yourself like A * 100.0 / B.
 
    
    
        Chris Johnson
        
- 20,650
- 6
- 81
- 80
 
    