0

what does % sign mean in python? I looked it up and it said that it's a format for the print part, but it's not on the part of the printing so it didn't really help.. here's the code anyway:

a = 5
b = 6
c = 7
for i in range((a+b)*4):
  if i%c == 0:
    print(i)
someone
  • 1
  • 1
  • 1
  • 1

2 Answers2

2

The % is the modulo it will return the rest of an euclidian division

Ex :

10 % 3 == 1 #True because 10//3 = 9 and the rest is 1
10 % 10 == 0 #True because 10//10 = 1 and the rest is 0
Xiidref
  • 1,456
  • 8
  • 20
2

It denotes a Modulus operator; gives the remainder of the left value divided by the right value. like:

5%3=2

15%30=15
Harsh
  • 149
  • 2
  • 11