Programming Basics

Understanding Variables and Data Types for Beginners

📅 December 05, 2025 ⏱️ 1 min read 👁️ 4 views 🏷️ Programming Basics

Variables are containers that store information in your programs. Understanding them is fundamental to programming.

What are Variables?


# Python variables
name = "Alice"  # String
age = 25  # Integer
height = 5.6  # Float
is_student = True  # Boolean

print(f"{name} is {age} years old")

Common Data Types


# Numbers
integer_num = 42
float_num = 3.14
complex_num = 2 + 3j

# Strings
text = "Hello, World!"
multiline = """This is
a multiline string"""

# Boolean
is_active = True
is_admin = False

# Lists
numbers = [1, 2, 3, 4, 5]
mixed = [1, "two", 3.0, True]

Type Conversion


# Convert between types
age_str = "25"
age_int = int(age_str)

price = 19.99
price_str = str(price)

# Check type
print(type(age_int))  # 

Variable Naming Rules


# Good variable names
user_name = "Alice"
total_price = 100.50
is_logged_in = True

# Avoid
x = "Alice"  # Too vague
UserName = "Bob"  # Use snake_case in Python
1st_name = "Error"  # Can't start with number

Good variable naming makes code readable and maintainable!

🏷️ Tags:
programming basics variables data types beginner tutorial

📚 Related Articles