title: TensorFlow Variables and Constants
body: <p>I am new to tensorflow , I am not able to understand the difference of variable and constant, I get the idea that we use variables for equations and constants for direct values , but why code #1 works only and why not code#2 and #3, and please explain in which cases we have to run our graph first(a) and then our variable(b) i.e </p>
  
  <pre><code> (a) session.run(model)
   (b) print(session.run(y))
  </code></pre>
  
  <p>and in which case I can directly execute this command
  i.e </p>
  
  <pre><code>print(session.run(y))
  </code></pre>
  
  <p>Code #1 :</p>
  
  <pre><code>x = tf.constant(35, name='x')
  y = tf.Variable(x + 5, name='y')
  
  model = tf.global_variables_initializer() 
  
  with tf.Session() as session:
      session.run(model)
      print(session.run(y))
  </code></pre>
  
  <p>Code #2 :</p>
  
  <pre><code>x = tf.Variable(35, name='x')
  y = tf.Variable(x + 5, name='y')
  
  model = tf.global_variables_initializer() 
  
  with tf.Session() as session:
      session.run(model)
      print(session.run(y))
  </code></pre>
  
  <p>Code #3 :</p>
  
  <pre><code>x = tf.constant(35, name='x')
  y = tf.constant(x + 5, name='y')
  
  model = tf.global_variables_initializer() 
  
  with tf.Session() as session:
      session.run(model)
      print(session.run(y))
  </code></pre>