🚀 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
Python Operators Basics: Arithmetic, Assignment, Relational, Logical & Bitwise
More Relevant Posts
-
🧠 Python Concept That Makes Loops More Pythonic: enumerate() Stop manually counting indexes 👀 ❌ Old Way names = ["Asha", "Rahul", "Zoya"] for i in range(len(names)): print(i, names[i]) Works… but not very Pythonic. ✅ Pythonic Way names = ["Asha", "Rahul", "Zoya"] for index, name in enumerate(names): print(index, name) Cleaner. More readable 🎯 ⚡ Start From Any Number for i, name in enumerate(names, start=1): print(i, name) Output: 1 Asha 2 Rahul 3 Zoya 🧒 Simple Explanation 👩🏫 Imagine a teacher calling students 1️⃣ Asha 2️⃣ Rahul 3️⃣ Zoya 👩🏫 Teacher automatically adds numbers. 👩🏫 That teacher = enumerate(). 💡 Why This Matters ✔ Cleaner loops ✔ Avoid index bugs ✔ More readable code ✔ Widely used in production 🐍 Python often gives you tools that remove unnecessary work 🐍 enumerate() lets you loop with both index and value cleanly. #Python #PythonTips #PythonTricks #AdvancedPython #CleanCode #LearnPython #Programming #DeveloperLife #DailyCoding #100DaysOfCode
To view or add a comment, sign in
-
-
💡 Understanding Default Parameters in Python While working with functions in Python, default parameters can make our code more flexible and easier to use. Let’s look at this simple example: def func(a, b=2, c=3): return a + b * c print(func(2, c=4)) 1️⃣ Step 1: Function Definition The function func has three parameters: • a • b with a default value of 2 • c with a default value of 3 ➡️ This means that if we call the function without providing values for b or c, Python will automatically use their default values. 2️⃣ Step 2: Calling the Function func(2, c=4) Here is what happens: • The value 2 is assigned to a. • We did not pass a value for b, so Python uses the default value 2. • We explicitly passed c = 4, which overrides the default value 3. So the values inside the function become: a = 2 b = 2 c = 4 3️⃣ Step 3: Evaluating the Expression The function returns: a + b * c Substituting the values: 2 + 2 * 4 According to Python’s order of operations, multiplication happens before addition: 2 + 8 = 10 ➡️ Final Output: 10 🔹 Important Concept Default parameters allow functions to work with optional arguments. They make functions more flexible, cleaner, and easier to reuse. #Python #Programming #AI #DataAnalytics #Coding #LearnPython
To view or add a comment, sign in
-
🐍 Day 2 of Learning Python Continuing my Python learning journey and today’s focus was on understanding how Python actually executes code behind the scenes, along with practicing some fundamental concepts. 🔎 What I explored today: ⚙️ How Python Executes Code I learned that Python does not directly run the code we write. Instead, the Python interpreter first converts the source code into Bytecode, which is then executed by the Python Virtual Machine (PVM). Understanding this process helped me see how Python translates human-readable instructions into something a computer can execute. 🧠 Variables in Python After that, I practiced working with variables, which are used to store data in memory. Python makes this simple since we don’t need to explicitly declare the data type — the interpreter handles it dynamically. 💻 Taking User Input To practice further, I wrote a small program where the user enters their name and age, and the program prints a formatted message. Example concept used: input() for user input. int() to convert age into an integer. f-strings for clean and readable output formatting. This small exercise helped me understand data types, variable assignment, and interaction with users through the terminal. Every day I’m trying to strengthen the fundamentals because strong basics make advanced topics like automation, AI, and machine learning easier to approach later. Looking forward to exploring more Python concepts tomorrow. 🚀 #Python #PythonProgramming #LearningPython #CodingJourney #100DaysOfCode #SoftwareDevelopment #ProgrammingBasics #TechLearning #Developers #FutureEngineer #LearnInPublic #PythonBeginner #SDE
To view or add a comment, sign in
-
-
🚀My Python Learning Journey – For Loop & range() Function 🐍 Today I learned about the for loop in Python and how the range() function works with it. The for loop is used to iterate over a sequence like a list, tuple, string, or range. It helps execute a block of code multiple times efficiently. 🔹 Syntax of for loop: for variable in sequence: # block of code 🔹 Understanding range() The range() function is commonly used with a for loop to generate a sequence of numbers. ✅ Syntax: range(start, stop, step) start → The starting value (default is 0) stop → The ending value (not included) step → The increment/decrement value (default is 1) 🔹 Different Forms of range() ✔️ range(stop) for i in range(5): print(i) Output: 0 1 2 3 4 ✔️ range(start, stop) for i in range(2, 6): print(i) Output: 2 3 4 5 ✔️ range(start, stop, step) for i in range(1, 10, 2): print(i) Output: 1 3 5 7 9 ✔️ Using negative step (reverse order) for i in range(10, 0, -2): print(i) Output: 10 8 6 4 2 📌 Key Points I Learned: ✔️ range() does not include the stop value ✔️ Default start = 0 ✔️ Default step = 1 ✔️ Step can be negative for reverse looping Improving my logical thinking step by step with Python 💻✨ #Python #LearningJourney #ForLoop #RangeFunction #Programming
To view or add a comment, sign in
-
-
🚀 Day 16 of My Python Learning Journey ⚙️ Topic: Operators in Python Today, I learned about Operators in Python. Operators are special symbols used to perform operations on variables and values. 📌 What are Operators? Operators help us perform calculations, comparisons, and logical decisions in a program. 🔢 Types of Operators in Python: 1️⃣ Arithmetic Operators Used to perform mathematical operations. Examples: +, -, *, /, %, //, ** a = 10 b = 3 print(a + b) # Addition print(a % b) # Modulus 2️⃣ Comparison (Relational) Operators Used to compare two values. Examples: ==, !=, >, <, >=, <= print(a > b) # True print(a == b) # False 3️⃣ Logical Operators Used to combine conditional statements. Examples: and, or, not print(a > 5 and b < 5) 4️⃣ Assignment Operators Used to assign values to variables. Examples: =, +=, -=, *=, /= a += 5 5️⃣ Bitwise Operators Work on binary numbers. Examples: &, |, ^, ~, <<, >> 6️⃣ Membership Operators Used to test membership in a sequence. Examples: in, not in 7️⃣ Identity Operators Used to compare memory locations. Examples: is, is not 💡 Key Takeaway: Operators are the building blocks of programming. They help us perform calculations, make decisions, and control program flow. Step by step, learning and growing every day 💻✨ #Day16 #PythonLearning #Operators #CodingJourney #ProgrammingBasics #LearnPython
To view or add a comment, sign in
-
-
You can tell a lot about a Python developer by how they use lists. Beginners see lists as a place to store values. Experienced developers see them as a tool to control flow, shape data, and simplify logic. append() is not just adding data. It’s building sequences step by step. pop() is not just removing elements. It’s controlling state. insert(), extend(), remove() small methods, but they quietly influence how clean or messy your code becomes. The interesting thing about Python is this: Many powerful programming habits start with very simple tools. Lists are usually the first data structure we learn. But they’re also one of the ones we keep using for years. Simple syntax. Serious power. Sometimes the most “basic” features in Python are the ones you never outgrow. #Python #DataScience #Ai #Lists
To view or add a comment, sign in
-
-
📌 Topic: Set Methods in Python Today I explored Set Methods in Python. A set is an unordered collection of unique elements. It does not allow duplicates and is very useful for mathematical operations like union and intersection. 🔹 Important Set Methods I Learned: add() – Adds a single element to the set s = {1, 2, 3} s.add(4) print(s) ✅ update() – Adds multiple elements s.update([5, 6]) ✅ remove() – Removes an element (gives error if not found) ✅ discard() – Removes an element (no error if not found) ✅ pop() – Removes a random element ✅ clear() – Removes all elements 🔹 Set Operations: 🔸 Union (| or union()) 🔸 Intersection (& or intersection()) 🔸 Difference (- or difference()) 🔸 Symmetric Difference (^) Example: a = {1, 2, 3} b = {3, 4, 5} print(a.union(b)) print(a.intersection(b)) 📚 Every day I am improving step by step in Python. Consistency is the key to success! 💪 #Day16 #PythonLearning #SetMethods #CodingJourney #LearningEveryday
To view or add a comment, sign in
-
📅 Day 15 of Learning Python .🐍 — Topics Covered.... ✅ 🔹 Split() Method ✂️ → breaking text into parts ✅ 🔹 Join() Method 🔗 → combining text together ✅ 🔹 Working with Dates & Times 📅⏰ → handling real-world time data ✅ 🔹 today() Method 🌞 → getting current date ✅ 🔹 date Constructor 🗓️ → creating date objects ✅ 🔹 time Constructor ⏱️ → creating time objects ✅ 🔹 datetime Constructor 📆 → working with date + time together ✅ 🔹 Parsing Dates & Times 🔍 → converting text into date/time ✅ 🔹 Format Codes 🧩 → customizing display format ✅ 🔹 Formatting Date/Time/Datetime Objects 🎨 → making output readable ✅ 🔹 Common Format Codes 📌 → standard formatting styles 💡 Doing → Learning → Improving → Growing 🚀 Small daily progress builds real skills for the future. 🔥 Hashtags for your post #Day15 #PythonLearning #CodingJourney #LearnPython #ProgrammingLife #FutureDeveloper #DataScienceJourney #AIJourney #TechSkills #Consistency #100DaysOfCode #KeepLearning
To view or add a comment, sign in
-
-
🚀 My Python Learning Journey – Nested If Statement 🐍 Today I learned about the Nested If statement in Python. A nested if means placing one if statement inside another if statement. It is useful when we need to check a condition inside another condition. This helps in handling more complex decision-making scenarios in programs. 🔹 Syntax of Nested If: if condition1: # block of code if condition2: # block of code We can also combine it with else if needed: if condition1: # block of code if condition2: # block of code else: # block of code else: # block of code 🔹 Example: num = 10 if num > 0: if num % 2 == 0: print("Positive Even Number") else: print("Positive Odd Number") else: print("Negative Number") 📌 Key Points I Learned: ✔️ Used for checking conditions inside another condition ✔️ Proper indentation is very important ✔️ Helps build logical and structured programs Improving my logical thinking step by step with Python 💻✨ #Python #LearningJourney #NestedIf #ConditionalStatements #Programming
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development