OpenViSTAI · Agents · Blockchain · Crypto
Menu

OPENVIST LEARN · FREE LESSONS

Names, values and readable programs

Store values, reuse them and explain intent without hiding it in cryptic names.

Lesson 2 of 22 · About 20 minutes · Beginner · English

By the end of this lesson

Trace simple assignments and produce a greeting using a named value.

Before you start

  • Python 3.12 or a compatible newer Python 3 interpreter; no external packages.
  • Complete lesson 1 in this route, or be comfortable with its examples.

Three words to know

Variable
A name referring to a value.
Assignment
Using = to bind a name to a value.
Comment
A note after # that Python does not execute.

1. Read from top to bottom

A small script normally runs one statement after another. An assignment binds a name; it does not print anything. Descriptive names make later changes easier: learner_name tells the reader more than x. Names are case-sensitive, so learner and Learner are different.

A named greetingPYTHON · save as lesson.py, then run with your interpreter
learner_name = "Sam"
lesson_count = 22
print(learner_name)
print(lesson_count)
What you should see · example output
Sam
22

2. Reassignment uses the current value

The right-hand side is evaluated first. Then the name on the left refers to that result. Reassigning one name does not automatically update another name that previously received its old integer value.

Trace two namesPYTHON · save as lesson.py, then run with your interpreter
completed = 2
previous = completed
completed = completed + 1
print(previous)
print(completed)
What you should see · example output
2
3

3. Make intent visible

Use lower_case_with_underscores for ordinary variable names. Do not name a variable print, list or input: doing so hides a useful built-in. Comments should explain a decision rather than repeat every character of a statement.

A useful commentPYTHON · save as lesson.py, then run with your interpreter
# Keep this example independent of the machine clock.
practice_day = "Monday"
print(f"Practice on {practice_day}")
What you should see · example output
Practice on Monday

YOUR TURN

A small check before you continue

Set completed to 4, add 2 to it and print the result. Predict previous if it was assigned completed before the addition.

Show a suggested answer

The result is 6. previous remains 4 when assigned before the addition. Assignment copied the reference to the earlier integer; it did not create a live formula.

Sources and scope

Documentation and examples reviewed 2026-10-18. Provider screens, package versions and output wording can differ. Examples show expected outcomes; they are not a claim that OpenViST connected to your server or verified your setup.