Day 1 of my coding Journey

agastya shuklaagastya shukla
3 min read

🐍 Python Variables, Data Types, and Operators – The Ultimate Beginner’s Guide

Whether you're starting your Python journey or revising the basics, understanding variables, data types, and operators is essential. These are the foundation blocks of Python programming.

In this blog, we’ll explore all three concepts with simple explanations and examples.


✏️ Variables in Python

📌 What is a Variable?

A variable is a name that stores a value. You can use it to hold data like numbers, text, or even complex data like lists.

🧪 Example:

name = "Agastya"
age = 18
language = "Python"
  • name holds a string

  • age holds an integer

  • language holds another string

📌 Python uses dynamic typing, meaning you don’t need to declare the type. It figures it out automatically.


🧠 Python Data Types

Data types describe the kind of data stored in variables.

🔹 Built-in Data Types

1. Numeric Types

x = 5         # int
y = 3.14      # float
z = 2 + 3j    # complex

2. Text Type

message = "Hello, Python!"  # str

3. Boolean Type

is_coding_fun = True  # bool

4. Sequence Types

list_example = [1, 2, 3]         # list
tuple_example = (1, 2, 3)        # tuple
string_example = "Python"        # str

5. Set Types

set_example = {1, 2, 3}          # set

6. Mapping Type

dict_example = {"name": "Agastya", "age": 18}  # dict

7. None Type

value = None  # Represents no value

🔍 Checking Data Types

print(type(age))  # <class 'int'>

⚙️ Python Operators

Operators are symbols that perform operations on values and variables.

🔢 1. Arithmetic Operators

Used for mathematical calculations:

a = 10
b = 3

print(a + b)  # 13
print(a - b)  # 7
print(a * b)  # 30
print(a / b)  # 3.33
print(a % b)  # 1 (remainder)
print(a ** b) # 1000 (power)
print(a // b) # 3 (floor division)

🧪 2. Comparison Operators

Used to compare values, returns True or False:

print(a == b)  # False
print(a != b)  # True
print(a > b)   # True
print(a <= b)  # False

🔗 3. Logical Operators

Used to combine conditional statements:

x = True
y = False

print(x and y)  # False
print(x or y)   # True
print(not x)    # False

🧾 4. Assignment Operators

Used to assign or update the value of a variable:

x = 5
x += 3  # Same as x = x + 3 → x = 8
x *= 2  # x = 16

🔎 5. Membership Operators

Check if a value is part of a collection:

fruits = ["apple", "banana", "mango"]
print("apple" in fruits)     # True
print("grape" not in fruits) # True

🧱 6. Identity Operators

Used to compare object identity:

a = [1, 2, 3]
b = a
c = [1, 2, 3]

print(a is b)     # True (same object)
print(a is c)     # False (same content, different object)
print(a == c)     # True (values are equal)

🧠 Quick Practice

Try this mini snippet to combine what you’ve learned:

name = "Agastya"
age = 18
skills = ["Python", "HTML", "CSS"]

if age >= 18 and "Python" in skills:
    print(f"{name} is ready to code!")

🚀 Final Thoughts

Understanding variables, data types, and operators will help you build the foundation for writing powerful Python programs. Practice writing small scripts and explore how these basic tools work together.


✍️ Written by Agastya – A passionate first-year polytechnic student learning Python and web development.

Follow me for more beginner-friendly blogs on Python, HTML, CSS, and more! 💻🚀

0
Subscribe to my newsletter

Read articles from agastya shukla directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

agastya shukla
agastya shukla