title: Saving the output of a cell as a txt file in jupyter notebook
body: <p>I would very much like to save the output of the last cell in a txt file. </p>
  
  <pre><code> q = [rng.next () for _ in range (0, 25000000)]
  </code></pre>
  
  <p>I know I can use pandas dataframe but I need the txt file to carry out Diehard tests. Is it feasible in a jupyter notebook? Possibly what type of data do I need to carry out the <a href="http://webhome.phy.duke.edu/~rgb/General/dieharder.php" rel="noreferrer">Dieharder Suite</a> ?</p>
  
  <p>I am almost sure that once I did something like that unfortunately I do not remember how, and I can not find a clear answer</p>
  
  <p>Below is the code of my LCG random number generator:</p>
  
  <pre><code>import numpy as np
  
  class LCG(object):
  
      UZERO: np.uint32 = np.uint32(0)
      UONE : np.uint32 = np.uint32(1)
  
      def __init__(self, seed: np.uint32, a: np.uint32, c: np.uint32) -&gt; None:
          self._seed: np.uint32 = np.uint32(seed)
          self._a   : np.uint32 = np.uint32(a)
          self._c   : np.uint32 = np.uint32(c)
  
      def next(self) -&gt; np.uint32:
          self._seed = self._a * self._seed + self._c
          return self._seed
  
      def seed(self) -&gt; np.uint32:
          return self._seed
  
      def set_seed(self, seed: np.uint32) -&gt; np.uint32:
          self._seed = seed
  
      def skip(self, ns: np.int32) -&gt; None:
          """
          Signed argument - skip forward as well as backward
  
          The algorithm here to determine the parameters used to skip ahead is
          described in the paper F. Brown, "Random Number Generation with Arbitrary Stride,"
          Trans. Am. Nucl. Soc. (Nov. 1994). This algorithm is able to skip ahead in
          O(log2(N)) operations instead of O(N). It computes parameters
          A and C which can then be used to find x_N = A*x_0 + C mod 2^M.
          """
  
          nskip: np.uint32 = np.uint32(ns)
  
          a: np.uint32 = self._a
          c: np.uint32 = self._c
  
          a_next: np.uint32 = LCG.UONE
          c_next: np.uint32 = LCG.UZERO
  
          while nskip &gt; LCG.UZERO:
              if (nskip &amp; LCG.UONE) != LCG.UZERO:
                  a_next = a_next * a
                  c_next = c_next * a + c
  
              c = (a + LCG.UONE) * c
              a = a * a
  
              nskip = nskip &gt;&gt; LCG.UONE
  
          self._seed = a_next * self._seed + c_next
  
  
  #%%
  np.seterr(over='ignore')
  
  a = np.uint32(1664525)
  c = np.uint32(1013904223)
  seed = np.uint32(1)
  
  rng = LCG(seed, a, c)
  q = [rng.next() for _ in range(0, 25000000)]
  </code></pre>