title: Python: "Name is not defined" error
body: <p>So I was doing a tuition program assignment for homework the other day. This is my program. I hope it's self explanatory. (This is Python, by the way.)</p>
  
  <pre><code>def print_intro():
  print ("Welcome to the tuition program. This program will calculate your tuition cost.")
  
  def get_id_num():
      grad_status = input("Is the student an undergrad or grad (U/G)? ")
      id_num = int(input("Enter the student's ID Number: "))
      while (grad_status == "U") and (id_num &lt; 0):
          print("Sorry, that is invalid. Please try again.")
          id_num = int(input("Enter the student's ID Number: "))  
      while (grad_status == "G") and (id_num &gt;= 0):
          print("Sorry, that is invalid. Please try again.")
          id_num = int(input("Enter the student's ID Number: "))
  
  def get_info():
      get_id_num()
      age = int(input("Enter the student's age (numbers only): "))
      residency = input("Is the student in-state or out-of-state (I/O)? ")
      num_credits = int(input("How many hours of credit will the student take? "))
      correct = input("Is all the above information correct (Y/N)? ")
      while correct == "N":
          print("Please enter the information correctly!")
          get_info()
      else:
          get_base_tuition()
  
  def get_base_tuition():
      if (grad_status == "U") and (num_credits &lt;= 6) and (residency == "I"):
          initial_tuition = 2000
      if (grad_status == "U") and (7 &lt;= num_credits &lt;= 11) and (residency == "I"):
          initial_tuition = 3000
      if (grad_status == "U") and (num_credits &gt;= 12) and (residency == "I"):
          initial_tuition = 3800
      if (grad_status == "U") and (num_credits &lt;= 6) and (residency == "O"):
          initial_tuition = 2000
      if (grad_status == "U") and (7 &lt;= num_credits &lt;= 11) and (residency == "O"):
          initial_tuition = 3000
      if (grad_status == "U") and (num_credits &gt;= 12) and (residency == "O"):
          initial_tuition = 9000
      if (grad_status == "G") and (num_credits &lt;= 6) and (residency == "I"):
          initial_tuition = 2000
      if (grad_status == "G") and (7 &lt;= num_credits &lt;= 11) and (residency == "I"):
          initial_tuition = 2500
      if (grad_status == "G") and (num_credits &gt;= 12) and (residency == "I"):
          initial_tuition = 4400
      if (grad_status == "G") and (num_credits &lt;= 6) and (residency == "O"):
          initial_tuition = 2000
      if (grad_status == "G") and (7 &lt;= num_credits &lt;= 11) and (residency == "O"):
          initial_tuition = 3700
      if (grad_status == "G") and (num_credits &gt;= 12) and (residency == "O"):
          initial_tuition = 4400
      print(initial_tuition)
  </code></pre>
  
  <p>So after I run this, the get_info() function runs fine, up until it goes to the get_base_tuition() function. I get this error:</p>
  
  <pre><code>line 28, in get_base_tuition
      if (grad_status == "U") and (num_credits &lt;= 6) and (residency == "I"):
  NameError: name 'grad_status' is not defined
  </code></pre>
  
  <p>Should I have been adding parameters in my functions or something? I'm stuck and really don't know what to do. I know that if I include the variables "grad_status", "num_credits", and "residency" inside of get_base_tuition() OR define the variables inside the Python Shell before running get_base_tuition(), then of course it will work. But if I put it inside another get_base_tuition() like I did now, it won't work. Is there any way to make the get_base_tuition() function run without having to put the variables inside of get_base_tuition()? Because I already put those variables inside the functions get_id_num() and get_info(). 
  Help is appreciated, thanks.</p>
  
  <p>In case you want to know about the way the base tuition is supposed to be calculated, I attached that assignment here:
  <a href="https://i.stack.imgur.com/37B2o.png" rel="nofollow noreferrer">Assignment Page 2</a></p>