-8

I ran this code

x = 2

y = 6

print(x%y)

Output

2

What did '%' exactly do?

  • 1
    Did you know that search engines are now good enough that you can put in something like [`python what is %`](https://duckduckgo.com/?q=python+what+is+%25) and get good answers? – Karl Knechtel Sep 06 '21 at 03:47

1 Answers1

0

It's the modulo operator, it gives the rest from a division that doesn't give an integer( or 0 if the division gives an integer)

So 10 modulo 4 is 2 since 10-4*2=2

user14518362
  • 320
  • 4
  • 11