🚀 Day 4/60 – Operators in Python (Make Your Code Powerful) Variables store data. Operators make data useful. Let’s learn the basics 👇 ➕ 1️⃣ Arithmetic Operators (Math) a = 10 b = 3 print(a + b) # 13 print(a - b) # 7 print(a * b) # 30 print(a / b) # 3.33 print(a % b) # 1 (remainder) 🔍 2️⃣ Comparison Operators (True/False) print(10 > 5) # True print(10 < 5) # False print(10 == 10) # True print(10 != 5) # True Used in decision making. 🔗 3️⃣ Logical Operators (Combine Conditions) print(True and False) # False print(True or False) # True print(not True) # False ⚡ Real Example age = 20 if age >= 18: print("You can vote") Operators help you build logic like this. ❌ Common Mistake if age = 18: # ❌ Wrong Correct: if age == 18: # ✅ Comparison 🔥 Pro Tip = → assignment == → comparison Never mix them. 🔥 Challenge for today Write a program: 👉 Take a number 👉 Check if it is even or odd Hint 👇 num % 2 Comment “DONE” when you solve it ✅ Follow Adeel Sajjad if you’re serious about learning Python in 60 days 🚀 #Python #LearnPython #PythonProgramming #Coding #Programming
Python Operators: Arithmetic, Comparison, and Logical Basics
More Relevant Posts
-
🚀 Day 10/60 – Dictionaries in Python (Key-Value Magic 🔑) Lists store values… But what if you need labels with values? That’s where dictionaries shine 👇 🧠 What is a Dictionary? A dictionary stores data in key-value pairs. person = { "name": "Adeel", "age": 25, "city": "Lahore" } 🔍 Access Values print(person["name"]) # Adeel print(person["age"]) # 25 ➕ Add / Update Values person["job"] = "Data Engineer" # Add person["age"] = 26 # Update ❌ Remove Item person.pop("city") 🔁 Loop Through Dictionary for key, value in person.items(): print(key, value) ⚡ Real Example student = { "name": "Ali", "marks": 90 } if student["marks"] > 80: print("Top Student") ❌ Common Mistake print(person.name) # ❌ Error Correct: print(person["name"]) # ✅ 🔥 Pro Tip Keys must be unique & immutable (like strings, numbers, tuples) 🔥 Challenge for today Create a dictionary: 👉 Store your name, age, and favorite language 👉 Print each key and value Comment “DONE” when finished ✅ Follow Adeel Sajjad to stay consistent for 60 days 🚀 #Python #LearnPython #PythonProgramming #Coding #Programming
To view or add a comment, sign in
-
-
🚀 Python Series – Day 14: File Handling (Read & Write Files) Yesterday, we explored advanced concepts in functions. Today, let’s learn something super practical — how Python works with files 📂 🧠 What is File Handling? File handling allows you to: ✔️ Read data from files ✔️ Write data to files ✔️ Store information permanently 👉 Used in real-world projects like logs, data storage, reports, etc. 📂 Step 1: Open a File file = open("demo.txt", "r") 👉 Modes: "r" → Read "w" → Write (overwrites file) "a" → Append "x" → Create new file 📖 Step 2: Read a File file = open("demo.txt", "r") print(file.read()) file.close() ✍️ Step 3: Write to a File file = open("demo.txt", "w") file.write("Hello, Python!") file.close() ➕ Step 4: Append Data file = open("demo.txt", "a") file.write("\nLearning File Handling 🚀") file.close() 🔥 Best Practice (Important!) Use with statement (auto closes file): with open("demo.txt", "r") as file: data = file.read() print(data) 🎯 Why This is Important? ✔️ Used in data science (CSV, logs) ✔️ Used in real-world applications ✔️ Helps manage large data ⚠️ Pro Tip: Always close files OR use with 👉 Otherwise it may cause memory issues 📌 Tomorrow: Exception Handling (Handle Errors Like a Pro!) Follow me to master Python step-by-step 🚀 #Python #Coding #Programming #DataScience #LearnPython #100DaysOfCode #Tech #MustaqeemSiddiqui
To view or add a comment, sign in
-
-
Most beginners struggle with loops… until they understand THIS one idea. When I started learning Python, I thought loops were confusing. But then I realized: 👉 You don’t repeat code randomly. 👉 You repeat it for each item in a sequence. That’s where for loops change everything. 🔹 What is a for loop? A for loop runs code for every item inside a collection. Example: for num in [1, 2, 3]: print(num) Output: 1 2 3 💡 Simple: It goes item by item. Where does it work? (Iterable) You can loop over: Lists → [1, 2, 3] Strings → "Python" Tuples → (1, 2, 3) Dictionaries → {name: "Adeel"} Sets → {1, 2, 3} If it has multiple items → you can loop it. 🔹 The game changer → range() What if you don’t have a list? for i in range(5): print(i) Output: 0 1 2 3 4 range() = “Run this code X times” Next level → Nested loops Loop inside a loop: for i in [1, 2]: for j in [3, 4]: print(i, j) Used when working with complex data (like tables, datasets). 💡 Big realization: while → runs based on condition for → runs based on data This is why data analysts love for loops Real-world use: Processing datasets Automating reports Cleaning data Iterating through user records 🧠 Remember this forever: For loop = Go through each item one by one #Python #DataAnalytics #Coding #LearnToCode #Programming #Automation
To view or add a comment, sign in
-
-
You’re not struggling with Python… you’re just not understanding DATA TYPES deeply enough. Let me simplify this in 60 seconds Everything in Python = Data Type If you understand this… your coding level instantly upgrades. 🔢 1. Numeric (Numbers) int → 10, -5 float → 3.14 complex → 3 + 5i 🧵 2. Sequence (Ordered data) string → "Hello" list → [1, "Ahmed", True] ✅ (changeable) tuple → (1, 2, 3) ❌ (not changeable) 📦 3. Dictionary (Key → Value) {"name": "Adeel", "age": 18} Perfect for structured data 🧩 4. Set (Unique values only) No duplicates Unordered {1, 2, 3} ⚖️ 5. Boolean (Decision maker) True / False Used in conditions, logic, loops 💾 6. Binary (Advanced level) bytes, bytearray, memoryview Used in images, audio, files 💡 Real Talk: Most beginners jump into projects… without mastering these basics. That’s why they get stuck. If you master data types → you master Python foundations. #Python #DataTypes #LearnPython #Coding #Programming #DataAnalytics #DataScience #TechSkills #AI #MachineLearning #CodingJourney #SoftwareEngineering #Developers #CareerGrowth
To view or add a comment, sign in
-
-
Python Basics Every Al Engineer Must Know If you're starting your Al journey, Python is your best friend Here's what I learned that actually matters 1. Variables & Data Types →int, float, string, boolean → These are the building blocks of every ML model 2. Lists & Dictionaries → Store datasets, features, and labels → df['column'] is just a dictionary in disguise! 3. Loops & Conditions → for loops to iterate over data →if/else to filter and clean data 4. Functions →Write reusable code for preprocessing. →def preprocess(df): your best habit 5. Libraries You Must Know →NumPy - numbers & arrays →Pandas - data manipulation →Matplotlib/Seaborn - visualization →Scikit-learn - ML models 6. OOP (Object Oriented Programming) →Classes & objects power every Al framework → TensorFlow, PyTorch are all built on OOP 7. File Handling →Read CSV. JSON. Excel files → pd.read_csv() is your daily driver. #Python #AIEngineering #MachineLearning #DataScience #Python4Al #LearnPython #AlBeginners
To view or add a comment, sign in
-
-
🐍 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 7 of My Data Science Journey — Python Loops: for Loop from Basics to Patterns Today’s focus was on one of the most fundamental concepts in programming — Loops. Instead of repeating code multiple times, loops allow us to write it once and execute it efficiently. Building on the concepts from previous days, I explored how loops work in different scenarios and how they connect with other Python fundamentals. 𝐖𝐡𝐚𝐭 𝐈 𝐏𝐫𝐚𝐜𝐭𝐢𝐜𝐞𝐝: for Loop with range() – Used range(stop), range(start, stop), and range(start, stop, step) – Printed sequences like numbers, even/odd series, and reverse counting for Loop with Strings – Iterated through each character in a string – Used indexing with range(len()) to access position and value enumerate() — Cleaner Approach – Learned how to get index and value together – Improved readability and avoided manual indexing Nested for Loops – Understood how inner loops execute completely for each outer loop iteration – Applied logic similar to real-world repeating patterns Pattern Printing – Built patterns like triangles and pyramids using loops – Combined spaces and symbols for structured output Real Practice Examples – Created multiplication tables using input() and f-strings 𝐊𝐞𝐲 𝐈𝐧𝐬𝐢𝐠𝐡𝐭: Loops bring everything together — input handling, conditionals, string operations, and logic building. This is where programming becomes more dynamic and powerful. In Data Science, loops play a key role in processing data, iterating through datasets, and performing computations efficiently. Excited to continue building on this foundation. Read the full breakdown with examples on Medium 👇 https://lnkd.in/diqQivkQ #DataScienceJourney #Python #ForLoop #Loops #Programming #Learning
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
-
-
🚀 Day 11/60 – Sets in Python (Only Unique Values 🔥) What if you want no duplicates in your data? That’s where sets come in 👇 🧠 What is a Set? A set is a collection of unique values. numbers = {1, 2, 3, 3, 4} print(numbers) 👉 Output: {1, 2, 3, 4} Duplicates are automatically removed ✅ ➕ Add Items numbers.add(5) ❌ Remove Items numbers.remove(2) 🔁 Loop Through Set for num in numbers: print(num) ⚡ Real Example (Remove Duplicates from List) nums = [1, 2, 2, 3, 4, 4] unique_nums = set(nums) print(unique_nums) ❌ Common Mistake numbers = {} # ❌ This is a dictionary Correct: numbers = set() # ✅ Empty set 🔥 Pro Tip Sets are: ✅ Fast ✅ Unordered ✅ No duplicates 🔥 Challenge for today 👉 Create a list with duplicate values 👉 Convert it into a set 👉 Print unique values Comment “DONE” when finished ✅ Follow Adeel Sajjad to stay consistent for 60 days 🚀 #Python #LearnPython #PythonProgramming #Coding #Programming
To view or add a comment, sign in
-
-
Python isn't about being clever; it's about being concise. 👉 Here are 10 one-liners that actually save time in production. 1. Flatten a Nested List: [item for sublist in nested for item in sublist] – A list comprehension that turns a 2D list into a flat 1D list. 2. Swap Variables: a, b = b, a – Pythonic variable swapping using tuple unpacking (no temp variable needed). 3. Read File into Lines: open("f.txt").read().splitlines() – Efficiently reads a file and removes trailing newline characters. 4. Count Frequencies: from collections import Counter; Counter(data) – Quickly generates a dictionary of element counts. 5. Reverse Anything: value[::-1] – Uses slicing to reverse strings, lists, or tuples in one go. 6. Ternary Operator: x = "Yes" if condition else "No" – Compact inline conditional assignments. 7. Chained Comparisons: if 0 < x < 10: – Readable range checks that mirror mathematical notation. 8. List to String: ", ".join(map(str, values)) – Joins a list of items (even non-strings) into a single formatted string. 9. Pretty Print: from pprint import pprint; pprint(data) – Formats complex dictionaries or JSON into a readable structure. 10. Easter Eggs: import antigravity – A fun hidden feature that opens a classic XKCD comic about Python. #Python #CodingTips #DataEngineering #SoftwareEngineering #DataEngineer
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