0

I am experimenting with a simple python code.

import numpy as np

x, y = np.full(5, 5.0), np.full(5, 5.0)
print("{} + {} = {}".format(x, y, x + y))

I get this output, which is expected:

[5. 5. 5. 5. 5.] + [5. 5. 5. 5. 5.] = [10. 10. 10. 10. 10.]

But when I do this:

import numpy as np

x, y = np.full(5, 5.0), np.full(5, 5.0)
print("{} + {} = {}".format(*x, y, x + y))

I get this output:

5.0 + 5.0 = 5.0

What does *x do in this case?

user9524761
  • 731
  • 1
  • 5
  • 4

0 Answers0