🐍 Day [X] of my Python Learning Journey 📚 Today's lesson: Conditional Operators & IF / ELIF / ELSE statements We all know KPIs... but what if Python could give you the REAL corporate feedback? 😂 ```python KPI = float(input("Enter KPI score (%): ")) print(f"\nKPI Score: {KPI}%") # Corporate reality check 😂 if KPI < 70: print("Status: 🚨 Underperformance") print("Action: Welcome to PIP... we believe in you (kind of) 😬") print("Manager: 'Let's have a quick chat' 👀") elif KPI < 90: print("Status: 😌 Surviving (Meets Expectations)") print("Action: Good job! Here's a 'thank you'... no bonus tho 😅") print("Manager: 'Keep it up!' 👍") else: print("Status: 🚀 Overperforming Rockstar") print("Action: More work coming your way! Also... maybe leadership? 👀") print("Manager: 'We see great potential in you' (translation: more responsibilities) 😂") print("\nEvaluation completed... go grab a coffee ☕") ``` 💡 What I learned today: ✅ IF executes when the first condition is true ✅ ELIF checks additional conditions if the previous ones were false ✅ ELSE catches everything that didn't match above The beauty of conditionals? Python (like your manager) makes decisions based on conditions — except Python is always honest about it 😂 What's your KPI score today? Drop it below 👇 (Python won't judge... much) #Python #100DaysOfCode #DataScience #LearningInPublic #PythonForBeginners #CodingJourney #Tech
Python Conditional Operators & IF/ELIF/ELSE Statements
More Relevant Posts
-
🐍 Day 17–20 of My 30-Day Python Learning Challenge 🚀 Over the last few days, I focused on improving my Mini Project: Log File Analyzer by making it more practical and closer to real-world usage. 📌 What I Improved: ✅ Removed Stopwords Ignored common words like "the", "is", "and" to focus on meaningful data. stopwords = {"the", "is", "and", "in", "to", "of"} filtered_words = [w for w in words if w not in stopwords] --- ✅ Data Cleaning (Punctuation Removal) Handled messy real-world text by removing special characters. import string for p in string.punctuation: content = content.replace(p, "") --- ✅ Better Word Frequency Analysis Used efficient logic to count words. word_count[word] = word_count.get(word, 0) + 1 --- ✅ Top Frequent Words Extraction top_words = sorted(word_count.items(), key=lambda x: x[1], reverse=True)[:3] --- 📊 Key Learning: Small improvements like cleaning and filtering data significantly improve accuracy. 📈 Next Steps: • Visualize results using graphs • Add user input support • Build a simple UI using Streamlit 💡 This project helped me understand how Python is used in: • Data analysis • Text processing • Real-world problem solving #Python #MiniProject #DataCleaning #LearningInPublic #SoftwareDeveloper #ProjectBuilding
To view or add a comment, sign in
-
🚀 Day 14/60 – Dictionary Comprehension (Level Up Your Python 🚀) Yesterday you learned list comprehension. Today, let’s level up 👇 🧠 What is Dictionary Comprehension? A quick way to create dictionaries in one clean line. ❌ Traditional Way numbers = [1, 2, 3, 4] squares = {} for num in numbers: squares[num] = num * num print(squares) ✅ Dictionary Comprehension Way numbers = [1, 2, 3, 4] squares = {num: num * num for num in numbers} print(squares) 👉 Cleaner. Faster. More Pythonic. 🔍 With Condition numbers = [1, 2, 3, 4, 5, 6] even_squares = {num: num * num for num in numbers if num % 2 == 0} print(even_squares) ⚡ Real Example names = ["adeel", "ali", "ahmed"] name_length = {name: len(name) for name in names} print(name_length) ❌ Common Mistake {num * num for num in numbers} # ❌ This creates a set Correct: {num: num * num for num in numbers} # ✅ Dictionary 🔥 Pro Tip Use dictionary comprehension when: ✅ You want clean transformation of data ❌ Avoid if logic becomes too complex 🔥 Challenge for today 👉 Create numbers from 1 to 5 👉 Create dictionary where: Key = number Value = cube of number Comment “DONE” when finished ✅ Follow Adeel Sajjad to stay consistent for 60 days 🚀 #Python #PythonProgramming #LearnPython #Coding #Programming #Developer #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 DAY 3 – #LearningInPublic (Python Session – Functions & Higher Order Thinking) 🧠 Today’s Focus: Writing Cleaner Python Using Functions & Built-in Tools Today’s notebook session helped me understand how to write smarter and cleaner Python code using functions and powerful built-in utilities. 📌 What I Practiced Today ✅ Creating Functions I learned how to define reusable blocks of code using def and return results using return. This makes code: • Cleaner • Reusable • Easier to debug • More modular ✅ Higher-Order Functions I explored functions that work with other functions: • map() • filter() • lambda functions These allow transforming data in a single line instead of writing long loops. Example idea: Transforming dataset values using map() and lambda without writing explicit loops. ✅ enumerate() Function I learned how enumerate() helps when I need: • Index • Value at the same time while looping. This makes iteration much more readable. ✅ args and kwargs I practiced writing flexible functions using: • *args → multiple positional arguments • **kwargs → multiple keyword arguments This allows functions to accept dynamic inputs — very useful for datasets. ✅ Working With Dataset-like Rows I also explored calculating values using loops and generator expressions, like summing selected columns from rows. This helped me understand how data processing works internally in data science workflows. 💡 Key Takeaway Today I moved from: Writing simple code → Writing reusable logic Basic loops → Functional programming style Rigid functions → Flexible functions Slowly building the mindset required for Data Science and Python mastery. Consistency over perfection. 🚀 #LearningInPublic #Python #DataScience #Functions #PythonLearning #AI #MachineLearning #DeveloperJourney #100DaysOfCode
To view or add a comment, sign in
-
I started learning Python. Here's everything I've built into my brain so far day by day, concept by concept. → if / else statements Teaching the computer to make decisions. The moment this clicked, I felt like I was actually writing logic not just typing commands. → for loops & while loops Automation starts here. Instead of repeating myself, I let the code do the work. → logical operators Combining conditions with and, or, not. Simple but incredibly powerful once you see it in action. → arithmetic & comparison operators The foundation of every calculation and every decision in code. → operator precedence Python follows rules just like math. Understanding this saved me from confusing bugs. → formatted strings (f-strings) My favourite discovery so far. Clean, readable, dynamic text output in one line. → string methods .upper() .strip() .replace() .split() tools that make working with text feel effortless. → math functions Built-in tools like round(), abs(), pow() — Python does the heavy lifting. The biggest lesson so far? Confusion is not a sign you're failing. It's a sign you're learning. Every single concept above confused me at first. I stayed with it. I kept going. I'm sharing this publicly to hold myself accountable and because I know many people are quietly upskilling on the side without telling anyone. If that's you you're not alone. Keep going. 💪 What skill are you currently learning? Drop it in the comments. Let's inspire each other. 👇 #Python #LearningInPublic #CareerGrowth #SelfDevelopment #CodingJourney #GrowthMindset #ProfessionalDevelopment #TechSkills #100DaysOfCode #CodeNewbie
To view or add a comment, sign in
-
-
Assalam o Alaikum 👋 💡 Python Tip: Stop Writing Extra Code — Use "enumerate()"! If you’re learning Python, this small function can make your code cleaner and smarter 🚀 What is "enumerate()"? "enumerate()" is a built-in Python function that helps you loop through a list while keeping track of the index (position) of each item. 👉 Normally, you do this: You create a counter variable, update it manually, and then access elements. But with "enumerate()"… Python does it for you automatically Example: my_list = ['apple', 'banana', 'cherry'] for index, fruit in enumerate(my_list): print(index, fruit) Output: 0 apple 1 banana 2 cherry Why use "enumerate()"? No need to create a separate counter Cleaner & more readable code Less chance of mistakes Perfect for loops where position matters Pro Tip: You can even change the starting index! for index, fruit in enumerate(my_list, start=1): print(index, fruit) 👉 Now counting starts from 1 instead of 0 🚀 Real Use Cases: • Numbering items in a list • Working with indexed data • Tracking positions in loops • Displaying ordered results If you're learning Python, mastering small functions like this will level up your coding fast! 👉 Follow for more simple Python & AI tips #Python #PythonTips #CodingForBeginners #LearnPython #AIAutomation #TechLearning
To view or add a comment, sign in
-
-
Tell your AI that you are beginner when learning Python! I recently asked AI to generate some simple code to reverse two virtual spreadsheet columns called ‘Name’ and ‘Type’. Instead of simply suggesting code in which the column list [‘Name’, ‘Type] is replaced by [‘Type’, ‘Name’], AI suggested a complex indexing trick that looks like [::-1]. Succinct coding, to be sure, but I could not decipher it without additional prompts! In another case, my AI provided some sample code in which a variable was defined after that variable was used! The Horror! When I asked why it made such a fundamental mistake, the AI complimented me on my “good eye” for catching the error and that it did not necessarily provide code in execution order. So, if you are just learning Python, always start your session with a good prompt to set the stage such as the following: "I am a total beginner learning Python. Please follow these rules for ALL Python code you write for me: 1. Write code in execution order. 2. Break every task into small, discrete steps. 3. Use simple, obvious variable names that describe what they contain 4. Add plenty of comments explaining what it happening in plain English 5. Avoid shortcuts, clever one-liners, or condensed syntax that experienced coders use 6. If there are multiple ways to do something, choose the most readable one, not the most efficient one 7. Before showing me code, double-check it runs in the correct order from top to bottom" For more tips, consider my new book "Automate Excel with Python". My publisher @No Starch Press is offering a free review chapter in case you were interested: https://lnkd.in/eS-WAVyV Good luck and good coding! #Excel, #Python, #pandas, #dataframes,#Productivity, #DataAnalysis, #Automation
To view or add a comment, sign in
-
-
⚡ Writing Python loops the hard way? Let's fix that. ━━━━━━━━━━━━━━━━━━━━━━ Most Python beginners write this: result = [] for n in [1, 2, 3, 4, 5, 6]: if n % 2 == 0: result.append(n * 2) ▸ 4 lines. Repetitive. Easy to get wrong. ━━━━━━━━━━━━━━━━━━━━━━ Python gives you a cleaner tool — the List Comprehension: result = [n * 2 for n in numbers if n % 2 == 0] ────── ─────────────── ───────────── express iterate filter Both produce the same result: [4, 8, 12] ▸ 1 line. Readable. Faster to execute. ━━━━━━━━━━━━━━━━━━━━━━ How to read any list comprehension: [ WHAT YOU WANT → FROM WHERE → ONLY IF ] Once you see that pattern, every comprehension becomes obvious. This is the kind of insight Vaathiyaar teaches at PyMasters — building intuition, not just syntax. → Learn Python the right way at pymasters.net #Python #PythonTips #ListComprehensions #LearnPython #PyMasters
To view or add a comment, sign in
-
-
I wrote just one line of Python code, and it worked. That’s when I realized something. Python is not just code, it’s instructions that bring ideas to life. Let me explain it like I’m explaining to a baby. Imagine you have a robot 🤖 You tell the robot: “Bring water” The robot follows your instruction step by step and that’s exactly what Python implementation is. What is Python Implementation? It simply means, writing instructions (code) And Python understands it Then executes it step by step For example, If I write, print("Hello, Precious") Python doesn’t argue. It doesn’t guess. It simply says, “Okay, let me display this.” And it shows, "Hello, Precious" But here’s what really blew my mind, Python doesn’t just run code. It reads it Interprets it Executes it immediately That’s why Python is called an interpreted language. Why this matters for Data Analysis As someone who have learn, Excel, SQL, Tableau and now Python I’m realizing that python is where everything comes together. Data cleaning, Data analysis, Automation, Visualization. All in one place. I used to think, “Learning tools is enough” Now I know that understanding how they work is the real power. If you’re learning Python or planning to, what was your first “aha” moment? Let’s talk 👇 #Python #DataAnalytics #LearningInPublic #SQL #Excel #Tableau #Programming #TechJourney #BeginnerInTech #DataScience #CareerGrowth
To view or add a comment, sign in
-
-
📘 Python for PySpark Series – Day 15 🎭 Polymorphism in Python ✨ What is Polymorphism? Polymorphism means “many forms”. It allows the same method or function to behave differently based on the object. ➡️ Promotes flexibility and dynamic behavior in code 🔹 Why Polymorphism? ✔ Improves code flexibility ✔ Reduces complexity ✔ Enhances readability ✔ Supports method reusability 🔹 Types of Polymorphism ✔ Method Overriding (Runtime) ✔ Method Overloading (Compile-time – limited in Python) ✔ Operator Overloading 🔹 Syntax (Method Overriding) class Parent: def show(self): print("Parent method") class Child(Parent): def show(self): print("Child method") 🔹 Example class Animal: def sound(self): print("Some sound") class Dog(Animal): def sound(self): print("Bark") class Cat(Animal): def sound(self): print("Meow") animals = [Dog(), Cat()] for a in animals: a.sound() ➡️ Same method sound() → different outputs 🔗 Why Polymorphism in PySpark? ✔ Same operations work on different data types (RDD, DataFrame) ✔ Functions behave differently based on input ✔ Helps in writing generic and reusable code 🏫 Real-Life Analogy (Remote Control 📺) One remote → multiple devices ➡️ Same button (action) → different behavior (TV, AC, etc.) 🧠 Interview Key Points ✔ Polymorphism = one interface, multiple implementations ✔ Achieved using method overriding ✔ Supports dynamic method dispatch ✔ Increases flexibility and scalability 🧠 Key Takeaway Polymorphism allows writing flexible and reusable code where the same operation behaves differently for different objects. 🔖 Hashtags #python #pyspark #dataengineering #oop #polymorphism #pythonbasics #learningjourney #coding
To view or add a comment, sign in
-
Explore related topics
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