🎓 EASYTUTORGUIDE · Complete Python Course

Very beginner → professional Python · 60 chapters · 900 topics

EasyTutorGuide

Chapter 4: Variables and Constants

Complete Python lesson for very beginners. Technical words are explained in simple language, and every outline topic includes a practical example, expected output, steps, and practice.

Python CourseVery Beginner Friendly15 TopicsExamples + Output20 Q&A
Chapter 4 · 15 topics
100%

Chapter Overview

This Python tutorial chapter covers Variables and Constants through 15 connected topics. Work through the examples in order, check the expected output, and complete the practice after each topic.

  • 4.1 Creating Variables
  • 4.2 Assignment
  • 4.3 Variable Names
  • 4.4 Naming Rules
  • 4.5 Multiple Assignment
  • Plus 10 additional Python topics in this chapter.

4.1 Creating Variables

Creating Variables is part of Variables and Constants. In simple language, it means a name that refers to a value.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Creating Variables (a name that refers to a value).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Creating Variables”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.2 Assignment

Assignment is part of Variables and Constants. In simple language, it means a Python idea used while learning variables and constants.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Assignment (a Python idea used while learning variables and constants).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Assignment”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.3 Variable Names

Variable Names is part of Variables and Constants. In simple language, it means a name that refers to a value.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Variable Names (a name that refers to a value).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Variable Names”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.4 Naming Rules

Naming Rules is part of Variables and Constants. In simple language, it means a Python idea used while learning variables and constants.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Naming Rules (a Python idea used while learning variables and constants).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Naming Rules”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.5 Multiple Assignment

Multiple Assignment is part of Variables and Constants. In simple language, it means a Python idea used while learning variables and constants.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Multiple Assignment (a Python idea used while learning variables and constants).

Python / Practical Example

x, y = 10, 20
print(x)
print(y)

Expected Output

10
20

Step-by-Step Explanation

  1. Two values appear on the right.
  2. Python assigns them by position.
  3. Each name receives one value.
Practice: Re-type the example for “Multiple Assignment”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.6 Unpacking Values

Unpacking Values is part of Variables and Constants. In simple language, it means a Python idea used while learning variables and constants.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Unpacking Values (a Python idea used while learning variables and constants).

Python / Practical Example

x, y = 10, 20
print(x)
print(y)

Expected Output

10
20

Step-by-Step Explanation

  1. Two values appear on the right.
  2. Python assigns them by position.
  3. Each name receives one value.
Practice: Re-type the example for “Unpacking Values”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.7 Reassignment

Reassignment is part of Variables and Constants. In simple language, it means a Python idea used while learning variables and constants.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Reassignment (a Python idea used while learning variables and constants).

Python / Practical Example

value = 10
print(type(value).__name__)
value = "ten"
print(type(value).__name__)

Expected Output

int
str

Step-by-Step Explanation

  1. Bind a name to an integer.
  2. Reassign the same name to text.
  3. The name can refer to objects of different types over time.
Practice: Re-type the example for “Reassignment”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.8 Dynamic Typing

Dynamic Typing is part of Variables and Constants. In simple language, it means a Python idea used while learning variables and constants.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Dynamic Typing (a Python idea used while learning variables and constants).

Python / Practical Example

value = 10
print(type(value).__name__)
value = "ten"
print(type(value).__name__)

Expected Output

int
str

Step-by-Step Explanation

  1. Bind a name to an integer.
  2. Reassign the same name to text.
  3. The name can refer to objects of different types over time.
Practice: Re-type the example for “Dynamic Typing”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.9 Object References

Object References is part of Variables and Constants. In simple language, it means a value with data and behavior.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Object References (a value with data and behavior).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Object References”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.10 Variable Identity

Variable Identity is part of Variables and Constants. In simple language, it means a name that refers to a value.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Variable Identity (a name that refers to a value).

Python / Practical Example

a = []
b = a
c = []
print(a is b)
print(a is c)

Expected Output

True
False

Step-by-Step Explanation

  1. b refers to the same list as a.
  2. c is a different empty list.
  3. is checks object identity, not equal contents.
Practice: Re-type the example for “Variable Identity”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.11 id()

id() is part of Variables and Constants. In simple language, it means a Python idea used while learning variables and constants.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: id() (a Python idea used while learning variables and constants).

Python / Practical Example

value = [1, 2]
print(type(id(value)).__name__)

Expected Output

int

Step-by-Step Explanation

  1. Create an object.
  2. id() returns an identity number for that object during its lifetime.
  3. The example prints the type of that identity value instead of depending on a machine-specific number.
Practice: Re-type the example for “id()”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.12 Constants by Convention

Constants by Convention is part of Variables and Constants. In simple language, it means a value you intend not to change.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Constants by Convention (a value you intend not to change).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Constants by Convention”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.13 Deleting Variables

Deleting Variables is part of Variables and Constants. In simple language, it means a name that refers to a value.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Deleting Variables (a name that refers to a value).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Deleting Variables”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.14 Scope Introduction

Scope Introduction is part of Variables and Constants. In simple language, it means the part of a program where a name is available.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Scope Introduction (the part of a program where a name is available).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Scope Introduction”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

4.15 Variable Best Practices

Variable Best Practices is part of Variables and Constants. In simple language, it means a name that refers to a value.

It is one building block of variables and constants and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Variable Best Practices (a name that refers to a value).

Python / Practical Example

name = "Ava"
age = 20
print(name, age)

Expected Output

Ava 20

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Variable Best Practices”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

Common Beginner Mistakes

  • Copying code without predicting what each line does.
  • Ignoring the first useful error message or traceback location.
  • Mixing tabs/spaces or changing indentation accidentally.
  • Using data of the wrong type for an operation.
  • Trying to learn many advanced variations before mastering one small working example.

Chapter Practice

  1. Choose three topics from this chapter and re-type their examples without copying and pasting.
  2. For each example, change one input and predict the output first.
  3. Explain five technical terms from this chapter in your own beginner-friendly words.
  4. Create one small program that combines at least two chapter topics.
  5. Keep notes about errors you made and what fixed them.

Mini Project / Challenge

Create a small Python exercise that combines at least three ideas from Variables and Constants. Start with a tiny working version, test it, then improve it one step at a time.

  1. Choose three topics from this chapter.
  2. Write or adapt a small Python example using those topics.
  3. Predict the output before running the code.
  4. Test at least one different input.
  5. Write two sentences explaining what the program does and what you learned.

20 Questions & Answers

1. What is the main goal of Chapter 4?

The goal is to understand variables and constants through small explanations, examples, and practice.

2. Should I memorize every command or method?

No. Understand the pattern, practice the common form, and learn how to read documentation when you need exact details.

3. Why are the examples small?

Small examples isolate one idea at a time, which makes errors easier to understand and fix.

4. What should I do when an example gives an error?

Read the last part of the traceback, check spelling and indentation, confirm the required package or file exists, and compare the input types with what the operation expects.

5. Why should I predict output before running code?

Prediction forces you to reason about the program instead of only copying it.

6. What should I remember about Creating Variables?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

7. What should I remember about Assignment?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

8. What should I remember about Variable Names?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

9. What should I remember about Naming Rules?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

10. What should I remember about Multiple Assignment?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

11. What should I remember about Unpacking Values?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

12. What should I remember about Reassignment?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

13. What should I remember about Dynamic Typing?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

14. What should I remember about Object References?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

15. What should I remember about Variable Identity?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

16. What should I remember about id()?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

17. What should I remember about Constants by Convention?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

18. What should I remember about Deleting Variables?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

19. What should I remember about Scope Introduction?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

20. What should I remember about Variable Best Practices?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.