title: How to Initialize different variables (at the same time) with zeros before a for loop?
body: <p>I'm writing a code in which I have to call the same function several times with different parameters inside a for loop. This function returns four variables and I would like to save them in a <code>numpy array</code> (matrix) for easy plotting later. </p>
  
  <p>For example, let's say that I want to evaluate the functions <code>y = ax</code>, <code>y = x/a</code>, <code>y = ax^2</code> and <code>y = x^2/a</code> for different values of <code>a</code> at <code>x = [0, 10]</code>. I create a Python function to evaluate the four different functions, let's call them, <code>y1</code>, <code>y2</code>, <code>y3</code> and <code>y4</code>. I make a for loop for this and each variable would be a <code>numpy array</code>, with each column being a particular value of <code>a</code>, and each row being a particular value of <code>x</code>. The thing is that I'm required to initialize the variables before the loop and I can't find a way to do it in a simple, pretty and pythonic way.</p>
  
  <pre><code>import numpy as np
  
  def func(x, a):
      y1 = a*x
      y2 = x/a
      y3 = a*x**2
      y4 = x**2/a
      return y1, y2, y3, y4
  
  x = np.arange(0, 11)
  a = np.array([1, 2, 3, 4])
  
  y1 = np.zeros((len(x), len(a)))
  y2 = np.zeros((len(x), len(a)))
  y3 = np.zeros((len(x), len(a)))
  y4 = np.zeros((len(x), len(a)))
  for i in range(len(a)):
      y1[:, i], y2[:, i], y3[:, i], y4[:, i] = func(x, a[i])
  </code></pre>
  
  <p>I just would like to find a better way to initialize <code>y1</code>, <code>y2</code>, <code>y3</code>, and <code>y4</code>. Of course, I welcome any other advice, since I come from Matlab, this might not be the best way to do it in Python.</p>