ChristCoded

the course / the basics

Variables: the name that changed

God renamed Abram to Abraham, and that is exactly how a variable works. Learn what a variable is, what "=" really means, and what happens to the old value when you reassign it.

Neither shall thy name any more be called Abram, but thy name shall be Abraham; for a father of many nations have I made thee. — Genesis 17:5 (KJV)

In Genesis 17, God makes a covenant with a 99-year-old man named Abram and gives him a new name: Abraham, “father of many nations.” Same man, new name — and from that moment on, when people called for Abraham, the old name was gone.

That small moment is the first idea every programmer learns: the variable.

What is a variable?

A variable is a name tied to a value. Think of a luggage tag on a string: the tag says name, and the string is tied to a value — here, the text "Abram".

name = "Abram"

Read this line right to left:

  1. Python creates the value "Abram" (a piece of text, called a string).
  2. It ties the tag name to that value.

Later, whenever your code says name, Python follows the string on the tag and hands you whatever it’s tied to.

print(name)    # Abram

= does not mean “equal”

This is the single most common beginner confusion. In math, x = 5 is a statement of fact. In Python, = is an action: “point this name at this value.” It’s called assignment.

That’s why this line, which is nonsense in math, is perfectly normal code:

score = score + 10    # take the current score, add 10, point "score" at the result

(When you actually want to ask whether two things are equal, Python uses a double equals: name == "Abram".)

Reassignment: a new name

Now God speaks a second line:

name = "Abram"
print(name)      # Abram

name = "Abraham"
print(name)      # Abraham

The tag name is untied from "Abram" and tied to a new value, "Abraham". Same tag, new value. Everything in your program that asks for name from now on gets Abraham.

What happens to “Abram”?

Nothing points to it anymore. A value with no tag tied to it can’t be reached by your code, so Python is free to reclaim the memory it used. This is called garbage collection, and it happens automatically — you never have to throw old values away yourself.

Small print for the curious: text written directly in your code (a “literal”) may stay in memory as part of the program itself. What matters is that you can no longer reach it through name.

The same idea in JavaScript

let name = "Abram";
console.log(name);   // Abram

name = "Abraham";
console.log(name);   // Abraham

JavaScript asks you to declare a variable the first time with let. If you use const instead, the name can never be reassigned — try const name = "Abram"; name = "Abraham"; and you’ll get an error.

It’s everywhere

Every app you use is full of names whose values change:

Variable Changes when… Code
score you collect a coin score = score + 10
username you edit your profile username = "abraham"
battery a minute passes battery = battery - 1

Common mistakes

  • Writing it backwards. "Abram" = name is an error: the name always goes on the left.
  • Using a name before tying it. print(nmae) → NameError: name 'nmae' is not defined. Python only knows tags you’ve created (and spelled the same way — Name and name are different tags).
  • Quotes. name = Abram (no quotes) makes Python look for another variable called Abram. Text needs quotes.

Try it

  1. Create a variable city = "Haran" and print it. Then reassign it to "Canaan" (Abram’s journey, Genesis 12:5) and print it again.

  2. Make age = 99, then write the line that makes him one year older without typing 100.

  3. Predict the output, then run it:

    a = "Sarai"
    b = a
    a = "Sarah"      # Genesis 17:15
    print(a, b)
    Answer

    Sarah Sarai — b was tied to the value "Sarai", not to the tag a. Moving a later doesn’t move b.

Reflect

Abraham’s new name wasn’t a label he earned — it was a promise God spoke over him before it was visible. When God renames someone in Scripture (Abram, Sarai, Jacob, Simon), the new name describes who they are becoming.