Python Full Tutorial — Part 2

In Part 1, we understood what Python is and why it exists. In this part, we enter the real foundation of programming: variables, data types, and memory thinking.

What is a Variable?

A variable is a name that points to a value stored in memory. Python does not think in terms of boxes — it thinks in terms of references.

Basic Variable Example

x = 10
name = "Python"
  

Here:

Python is Dynamically Typed

Python does not force you to declare data types. The type is decided automatically at runtime.

Dynamic Typing Example

value = 10
print(type(value))

value = "Ten"
print(type(value))
  

Same variable name, different data types — Python allows this.

Common Python Data Types

Data Type Examples

age = 25          # int
price = 99.99     # float
language = "Python"  # str
is_active = True  # bool
  

Understanding Memory (Important)

Python variables do not store values directly. They store references to objects in memory.

Reference Example

a = 5
b = a
a = 10

print(a)
print(b)
  

Output:

Output

10
5
  

Explanation:

Rules for Variable Names

Valid vs Invalid Names

user_name = "Suraj"   # valid
_age = 25             # valid

2name = "Wrong"       # invalid
user-name = "Wrong"   # invalid
  

Why This Matters

If you do not understand variables and data types, loops, functions, APIs, and AI code will feel like magic. Strong programmers think in memory and flow — not syntax.

In the next part, we will learn operators and expressions — how Python actually performs calculations and decisions.

Disclaimer:
This tutorial is for educational purposes only. Learning programming requires practice and logical thinking.