operators & conditional statement

agastya shuklaagastya shukla
2 min read

🚀 What I Learned Today: Operators & Conditional Statements in Programming

Hey there, fellow coders! 👋
Today was all about operators and conditional statements, two super important building blocks in any programming language. Whether you're working with Python, JavaScript, C++, or any other language, these concepts show up everywhere. Here's what I learned:


🔧 Operators: The Tools to Work With Data

Operators are symbols or words that let you perform operations on variables and values. Think of them like the math signs you already know, but for more than just numbers.

✨ Types of Operators:

  1. Arithmetic Operators

    • + (Addition)

    • - (Subtraction)

    • * (Multiplication)

    • / (Division)

    • % (Modulus – returns the remainder)

  2. Comparison Operators
    These compare two values and return true or false.

    • == (Equal to)

    • != (Not equal to)

    • > (Greater than)

    • < (Less than)

    • >= (Greater than or equal to)

    • <= (Less than or equal to)

  3. Logical Operators
    Perfect for combining conditions.

    • && or and (Both conditions must be true)

    • || or or (At least one condition must be true)

    • ! or not (Reverses the condition)


🧠 Conditional Statements: Making Decisions in Code

Conditional statements allow our code to make decisions. It’s like giving your program the ability to think: “If this is true, do that. Otherwise, do something else.”

✅ The Basics:

if condition:
    # do something
elif another_condition:
    # do something else
else:
    # do this if none of the above are true

💡 Example:

age = 18

if age >= 18:
    print("You're an adult!")
else:
    print("You're still a minor.")

Super simple, right? And yet so powerful!


📝 Final Thoughts

Learning operators and conditional statements felt like unlocking a new level in my coding journey 🎮. They form the logic that powers every program, from simple calculators to complex games.

Tomorrow, I’ll dive deeper—maybe loops or functions next? 😄
Stay tuned and keep coding!

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