Skip to main content

Command Palette

Search for a command to run...

operators & conditional statement

Published
โ€ข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!