2

when I calculate the rest of the division in python, I get answers like this:

>>> 12,121123123 % 10
(12, 3)
>>> 12,333434 % 5
(12, 4)
>>> 14,54 % 4
(14, 2)

I would like to understand what means this ordered pair.

altarbza
  • 426
  • 7
  • 13

2 Answers2

8

14,54 is not a decimal number. It is a 2-element tuple containing the integers 14 and 54.

If you want to specify a decimal number, you have to use the decimal point .:

>>> 12.121123123 % 10
2.1211231230000003
>>> 12.333434 % 5
2.3334340000000005
>>> 14.54 % 4
2.539999999999999

Otherwise, your code is equivalent to this:

>>> (12, 121123123 % 10)
(12, 3)
>>> (12, 333434 % 5)
(12, 4)
>>> (14, 54 % 4)
(14, 2)

And there, each tuple element is evaluated separately, so for (14, 54 % 4), you get back the 2-tuple with the elements 14 and the result of 54 % 4.

poke
  • 369,085
  • 72
  • 557
  • 602
2

You have to use dot . instead of comma ,. When you use comma, then you have tuple of objects, not a number.

turkus
  • 4,637
  • 2
  • 24
  • 28