0

I was asked to Perform the subtraction one coordinate at a time by subscripting in the original tuples.

I'm trying to subtract two tuples and print out the final answer using the string format (%s). I tried using numpy, but it was giving me an error while trying to print. This is what I tried.

`import numpy'

AA = (2.3, 4.5)
BB = (-2.0, -5.0)
ptbminusa = tuple(numpy.subtract((3.5, 1.2),(-2.7, -3.2)))
print("ptB - ptA = %s" %ptbminusa )

But, every time I run the file I get.

print("ptB - ptA = %s" %ptbminusa )`TypeError: not all arguments converted during string formatting`
Brian Rogers
  • 118,414
  • 30
  • 277
  • 278
kay oll
  • 29
  • 1
  • 3

1 Answers1

0

You are trying to print a tuple so you must use the following line:

print("ptB - ptA = %s" % (ptbminusa,) )

See Alex Martelli's answer for more information.

Community
  • 1
  • 1
Hayley Guillou
  • 3,827
  • 4
  • 24
  • 32