title: Python - unsupported operand type(s) for +: 'numpy.ndarray' and 'str'
body: <p>long time reader yet first time poster. I'm trying to write a simple user inputed sine graph drawer which affects the frequency, amplitude and phase shift of the graph. The aim is for everything to be in terms of pi to introduce Maths and Physics students to radians.</p>
  
  <p>My problem is, I am getting the error in the title whilst trying to detect if the word 'pi' is in a user input and convert it to np.pi to use as a float. The code for the program (working other than this pi section) is posted below:</p>
  
  <pre><code>import sys
  import matplotlib.pyplot as plt
  import numpy as np
  
  a = float(input("Amplitude of the curve: "))
  f = float(input("Frequency of the curve: "))
  p = input("Phase shift of the curve: ")
  
  if "pi" in p:
  str.translate(np.pi, "pi")
  float(p)
  
  else: float(p)
  
  x = np.linspace(0, 2*np.pi, 1000)
  y = a*np.sin((f*x)+p)
  
  plt.grid()
  
  plt.xlabel('x = angle(rads)', fontsize=18)
  plt.ylabel('y = amplitude', fontsize=18)
  plt.title('The Sine Function', fontsize=26)
  
  plt.xticks(np.linspace(0,2*np.pi,5), ['0', '$\pi$/2', '$\pi$', '3$\pi$/2', '2$\pi$'])
  plt.yticks(np.arange(min(y), max(y)+1, max(y)), [round(min(y)), '0', round(max(y))])
  
  plt.plot(x, y)
  plt.show()
  
  savefile = input("Do you wish to save the file? ")
  
  if "no" in savefile:
  sys.exit()
  
  elif "yes" in savefile:
  plt.grid()
  plt.xticks(np.linspace(0,2*np.pi,5), ['0', '$\pi$/2', '$\pi$', '3$\pi$/2', '2$\pi$'])
  plt.yticks(np.arange(min(y), max(y)+1, max(y)), [round(min(y)), '0', round(max(y))])
  plt.plot(x, y)
  filename = input("Name the file: ")
  plt.savefig(filename, format='pdf', bbox_inches='tight',     pad_inches=0.3)
  
  else: print("\n","Invalid input. Ending Script" ,sep="", end="\n \n")
  sys.exit()
  </code></pre>
  
  <p>Thanks in advance</p>