🚀 Python Series – Day 6: Conditional Statements (if-else) Till now, we learned how to take input and use operators 💻 But how does a program make decisions? 🤔 👉 Using Conditional Statements 🔥 🧠 What is a Condition? A condition checks whether something is True or False ✅ Basic if Statement age = 18 if age >= 18: print("You are eligible to vote") 🔁 if-else Statement age = int(input("Enter your age: ")) if age >= 18: print("Eligible") else: print("Not Eligible") 🔄 if-elif-else (Multiple Conditions) marks = int(input("Enter marks: ")) if marks >= 90: print("Grade A") elif marks >= 75: print("Grade B") elif marks >= 50: print("Grade C") else: print("Fail") ⚠️ Important Rule 👉 Indentation matters in Python! Incorrect: if age >= 18: print("Eligible") Correct: if age >= 18: print("Eligible") 🎯 Why is this important? ✔ Used in decision making ✔ Used in real-world logic ✔ Used in every program ❓ Question for you: What will be the output? x = 10 if x > 5: print("A") elif x > 8: print("B") else: print("C") 👉 Comment your answer 👇 📌 Tomorrow: Loops (for & while) 🔥 #Python #Coding #DataScience #Programming #LearnPython #Beginners #Tech #MustaqeemSiddiqui
Python Conditional Statements if-else
More Relevant Posts
-
🚀 Python Series – Day 5: Operators in Python Till now, we learned variables, data types, and user input 💻 Today, let’s understand how Python performs operations — using Operators 🔥 🧠 What are Operators? Operators are symbols used to perform operations on variables and values. 🔢 1️⃣ Arithmetic Operators If a = 10 b = 3 print(a + b) # Addition → 13 print(a - b) # Subtraction → 7 print(a * b) # Multiplication → 30 print(a / b) # Division → 3.33 (float) print(a // b) # Floor Division → 3 print(a % b) # Modulus → 1 print(a ** b) # Power → 1000 ⚖️ 2️⃣ Comparison Operators a = 10 b = 5 print(a == b) # False print(a != b) # True print(a > b) # True print(a < b) # False 🔗 3️⃣ Logical Operators x = True y = False print(x and y) # False print(x or y) # True print(not x) # False 📦 4️⃣ Assignment Operators x = 5 x += 3 # x = x + 3 print(x) # 8 🎯 Why are Operators Important? ✔ Used in calculations ✔ Used in conditions ✔ Used in decision making Without operators, programming is incomplete ❌ --- ⚠️ Important Concept print(10 / 2) # 5.0 print(10 // 2) # 5 👉 `/` gives float 👉 `//` gives integer ❓ Question for you: What will be the output? print(2 ** 3 + 5) 👉 Comment your answer 👇 📌 Tomorrow: Conditional Statements (if-else) 🔥 #Python #Coding #DataScience #Programming #LearnPython #Beginners #Tech #MustaqeemSiddiqui
To view or add a comment, sign in
-
-
🧠 Python Concept: Chaining Comparisons Write conditions like natural language 😎 ❌ Traditional Way x = 10 if x > 5 and x < 20: print("Valid") ❌ Problem 👉 Repeating variable 👉 Less readable ✅ Pythonic Way x = 10 if 5 < x < 20: print("Valid") 🧒 Simple Explanation Think of it like math 🧮 ➡️ 5 < x < 20 ➡️ Reads naturally ➡️ Cleaner logic 💡 Why This Matters ✔ More readable ✔ Less repetition ✔ Cleaner conditions ✔ Very Pythonic ⚡ Bonus Examples x = 15 print(10 < x <= 20) age = 25 if 18 <= age < 60: print("Working age") 🐍 Write code like English 🐍 Keep it clean & simple #Python #PythonTips #CleanCode #LearnPython #Programming #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
🎉 Released my first Python package! 🎉 An open-source Python library for imbalanced classification, now available on PyPI. Existing oversampling methods (SMOTE and its variants) operate in feature space without geometric guarantees: they interpolate between neighbours, but make no commitments about where synthetic points land relative to class boundaries or the minority distribution's internal structure. circover addresses this through four contributions: NHOP (Normalised Histogram Overlap Percentage), a distribution fidelity metric grounded in the identity NHOP = 1 − TV, where TV is total variation distance. Provides per-feature and global scores for evaluating synthetic data quality against the original distribution. ✔️ GeometricSeedSelector: combines NHOP, average geometric topology preservation (AGTP), Jensen–Shannon divergence, and a z-score criterion to select oversampling seeds that maximally preserve minority class geometry. GVM-CO / LRE-CO / LS-CO, three oversampling algorithms that generate synthetic points on geometry-constrained regions (circles, Voronoi-clipped disks, annular layers), with angular bias toward a gravity center derived from local density and inter-cluster distance. All three are fully compatible with imbalanced-learn pipelines and sklearn cross-validation. ✔️ DegradationBench: a controlled benchmark protocol that removes minority samples in equal increments (0% → 100%) and evaluates any estimator or pipeline via cross-validation at each level. Summarised by the Area Recovery Index (ARI = ∫ score(δ) dδ), enabling rigorous comparison across methods. 💻 pip install circover 💻 Feedback and collaboration from the imbalanced learning community are welcome. #MachineLearning #Python #OpenSource #ScientificComputing #ImbalancedLearning #DataScience
To view or add a comment, sign in
-
🚀 Today I explored another important concept in Python — Lists 💻 🔹 What is a List? A list is a collection of items that are ordered and changeable. It allows us to store multiple values in a single variable. 🔹 How Lists Work: 1️⃣ Store multiple values in one place 2️⃣ Access elements using indexing 3️⃣ Modify elements easily 4️⃣ Add or remove items when needed 👉 Flow: Data → Store in List → Access/Modify → Output 🔹 Operations I explored: ✔️ Indexing Accessing elements using position ✔️ Slicing Getting a part of the list ✔️ List Methods Using built-in functions like append(), remove(), sort() 🔹 Example 1: Creating & Accessing List nums = [10, 20, 30, 40] print(nums[0]) # 10 print(nums[-1]) # 40 🔹 Example 2: Modifying List nums = [1, 2, 3] nums.append(4) nums.remove(2) print(nums) 🔹 Key Concepts I Learned: ✔️ Lists are mutable (can be changed) ✔️ Support indexing and slicing ✔️ Can store multiple data types ✔️ Useful for handling collections of data 🔹 Why Lists are Important: 💡 Used to store multiple values 💡 Helps in data processing 💡 Widely used in real-world applications 🔹 Real-life understanding: Lists are like a collection (for example, a list of marks or items), where we can add, remove, and update data easily Learning step by step and building strong fundamentals 🚀 #Python #CodingJourney #Lists #Programming
To view or add a comment, sign in
-
-
🚀 Python Series – Day 9: Lists & Tuples (Store Multiple Values Easily!) Till now, we were working with single values. But what if you want to store multiple values in one variable? 🤔 👉 That’s where Lists & Tuples come in! 📦 What is a List? A list is a collection of items stored in a single variable. ✔️ Ordered ✔️ Changeable (Mutable) ✔️ Allows duplicates 🔧 Example: fruits = ["apple", "banana", "mango"] print(fruits) 🔁 Accessing Elements print(fruits[0]) # apple print(fruits[1]) # banana ✏️ Modify List fruits[1] = "orange" print(fruits) ➕ Add Elements fruits.append("grapes") 📦 What is a Tuple? A tuple is similar to a list, but: ✔️ Ordered ❌ Not changeable (Immutable) ✔️ Faster than list 🔧 Example: numbers = (1, 2, 3, 4) print(numbers) 🎯 Key Difference 👉 List = Mutable (can change) 👉 Tuple = Immutable (cannot change) 🔥 Pro Tip: Use: List → when data changes frequently Tuple → when data should stay fixed ⚡ Quick Challenge: What will be the output? x = [1, 2, 3] x[0] = 10 print(x) 👇 Comment your answer! 📌 Tomorrow: Strings in Python (Text Handling Basics) Follow me to learn Python step-by-step from basics to advanced 🚀 #Python #DataScience #Coding #Programming #LearnPython #Beginners #Tech #MustaqeemSiddiqui
To view or add a comment, sign in
-
-
🚨 Python Gotcha: Copying Lists (It’s Trickier Than You Think!) Many students think they are copying a list… but they’re actually creating a reference 😬 🔍 What’s the issue? Most beginners do this: a = [1, 2, 3] b = a ❌ This does NOT create a new list 👉 It creates a reference to the same list in memory 💡 Example: a = [1, 2, 3] b = a b.append(4) print(a) # [1, 2, 3, 4] 😨 unexpected print(b) # [1, 2, 3, 4] 👉 Why this happens: Both a and b point to the SAME memory location. So any change in b also affects a. ✅ Correct Ways: a = [1, 2, 3] b = a.copy() # Method 1 # or b = a[:] # Method 2 b.append(4) print(a) # [1, 2, 3] ✅ unchanged print(b) # [1, 2, 3, 4] 🧠 Key Takeaway: b = a → reference b = a.copy() or a[:] → actual copy ❓ Did this ever happen to you? #Python #Programming #CodingTips #PythonTips #Developers #LearnPython
To view or add a comment, sign in
-
-
Python has 7 types of operators. Most beginners only know 2. Here is a quick breakdown 🧵 1️ ⃣ Arithmetic → + - * / // % ** (your calculator) 2️ ⃣ Comparison → == != > < >= <= (your judge — gives True or False) 3️ ⃣ Logical → and or not (your referee — combines conditions) 4️ ⃣ Assignment → = += -= *= (shortcut writers — score += 10 is same as score = score + 10) 5️ ⃣ Membership → in not in (the guest list — is 'Ali' in this list?) 6️ ⃣ Identity → is is not (are these literally the same object in memory?) 7️ ⃣ Bitwise → works on binary 0s and 1s (advanced — used in low-level programming) The one that confused me most? = vs == = puts a value into a box. == asks: are these two things the same? Never confuse them or your code will break silently. 😅 Which one confused you? 👇 #Python #Programming #LearnPython #BuildingInPublic #AI #MachineLearning #CodingTips #TechPakistan
To view or add a comment, sign in
-
Python Learning Journey – Dictionaries Deep Dive Dictionaries are one of the most powerful and flexible data structures in Python. Today, I explored some important functions that every developer should know 👇 📌 Core Dictionary Functions: ✔️ len() – Returns number of key-value pairs ✔️ clear() – Removes all elements ✔️ get() – Access values safely without errors ✔️ pop() – Removes specific key and returns its value ✔️ popitem() – Removes last inserted key-value pair ✔️ keys() – Returns all keys ✔️ items() – Returns key-value pairs ✔️ copy() – Creates a shallow copy ✔️ setdefault() – Returns value of key (adds if not present) ✔️ update() – Updates dictionary with new key-value pairs 💡 Advanced Concept: ✨ Dictionary Comprehension – A concise way to create dictionaries in a single line Example: {x: x*x for x in range(5)} 🎯 Mastering dictionaries helps in writing efficient and clean code, especially when working with real-world data. #Globalquesttechnologies #GR Narendra Reddy #Python #CodingJourney #100DaysOfCode #Programming #SoftwareDevelopment #PythonBasics #Learning
To view or add a comment, sign in
-
-
🧠 Python Concept: dict comprehension Create dictionaries in one line 😎 ❌ Traditional Way nums = [1, 2, 3, 4] squares = {} for num in nums: squares[num] = num * num print(squares) ❌ Problem 👉 More lines 👉 Repetitive ✅ Pythonic Way nums = [1, 2, 3, 4] squares = {num: num * num for num in nums} print(squares) 🧒 Simple Explanation Think of it like a shortcut formula 🧮 ➡️ Take each item ➡️ Apply logic ➡️ Store as key:value 💡 Why This Matters ✔ Less code ✔ More readable ✔ Faster to write ✔ Very common in real projects ⚡ Bonus Example even_squares = {num: num * num for num in nums if num % 2 == 0} print(even_squares) 🐍 Build dictionaries smarter 🐍 One line can do it all #Python #PythonTips #CleanCode #LearnPython #Programming #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
DAY 9 – Python Revision | Recursion Masterclass (Core Logic Building) #Python #Recursion #LogicBuilding #FAANGPrep #DSA Recursion means a function calling itself until a base condition stops it. Ye technique har FAANG interview ka core hoti hai, specially: Tree problems Backtracking Divide & Conquer Dynamic Programming Aaj ke 4 powerful recursion problems 👇 (clean code + explanation) 🧩 Problem 1 — Factorial using Recursion (Base Concept) Input: 5 Output: 120 ✔ Recursion Logic Base case → n == 0 → return 1 Recursive case → n * factorial(n-1) def factorial(n): if n == 0: return 1 return n * factorial(n - 1) print(factorial(5)) Output: 120 🧩 Problem 2 — Fibonacci Using Recursion (Interview Favorite) Input: 6 Output: 8 ✔ Recursion Logic Fib(n) = Fib(n-1) + Fib(n-2) def fib(n): if n <= 1: return n return fib(n - 1) + fib(n - 2) print(fib(6)) Output: 8 🧩 Problem 3 — Sum of Digits Using Recursion (Logic Booster) Input: 1234 Output: 10 ✔ Recursion Logic Base → jab number 0 ho Recursive → last digit add + remaining digits ka sum def sum_of_digits(n): if n == 0: return 0 return (n % 10) + sum_of_digits(n // 10) print(sum_of_digits(1234)) Output: 10 🧩 Problem 4 — Reverse a String Using Recursion (Amazon) Input: "hello" Output: "olleh" ✔ Recursion Logic Base → length 0 or 1 Recursive → last char + reverse of remaining string def reverse_string(s): if len(s) <= 1: return s return reverse_string(s[1:]) + s[0] print(reverse_string("hello")) Output: olleh
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
“Very useful resource! This will definitely help many learners. Which part do you think is most important? I also share notes — do check out my profile and follow!”