Python Operators Basics: Arithmetic, Assignment, Relational, Logical & Bitwise

🚀 Day 2/30 📝 Python Operators - Basics As part of my #30DaysOfPython Today I learned about Python Operators. Operators are symbols that perform operations on variables and values. 🔹 1️⃣ Arithmetic Operators Used for mathematical calculations: + Addition - Subtraction * Multiplication / Division % Modulus (remainder) // Floor division ** Exponent (power) Example: a = 10 b = 3 print(a + b) # 13 print(a / b) # 3.333 print(a // b) # 3 print(a % b) # 1 print(a ** b) # 1000 --- 🔹 2️⃣ Assignment Operators Used to assign and update values: = += -= = /= %= //= *= Example: a = 5 a += 2 # a = 7 --- 🔹 3️⃣ Relational (Comparison) Operators Used to compare two values and return True/False: == != > < >= <= --- 🔹 4️⃣ Logical Operators Used with conditions: and or not --- 🔹 5️⃣ Bitwise & Shift Operators Work at binary level: & | ^ ~ << >> Example: 5 << 2 # 20 5 >> 1 # 2 --- 💡 What I Learned Today: Different types of operators perform different tasks. Some operators work on numbers, some on conditions, and some at binary level. Understanding operators helps in writing logical programs. Excited to continue learning rocket🚀 #Day2#Python #PythonBasics #Operators #LearningJourney #Coding #30DaysOfPython

  • text

To view or add a comment, sign in

Explore content categories