🚨 𝗣𝘆𝘁𝗵𝗼𝗻 𝗙𝘂𝗻 𝗙𝗮𝗰𝘁 𝗗𝗮𝘆 𝟱 A tuple is 𝘪𝘮𝘮𝘶𝘵𝘢𝘣𝘭𝘦… right? 👀 Then explain THIS 😳 𝚝 = ([𝟷, 𝟸, 𝟹], [𝟺, 𝟻]) 𝚝[𝟶].𝚊𝚙𝚙𝚎𝚗𝚍(𝟿𝟿) 𝚙𝚛𝚒𝚗𝚝(𝚝) 𝗘𝘅𝗽𝗲𝗰𝘁𝗲𝗱: Error because tuple is immutable 𝗔𝗰𝘁𝘂𝗮𝗹 𝗢𝘂𝘁𝗽𝘂𝘁: ([𝟷, 𝟸, 𝟹, 𝟿𝟿], [𝟺, 𝟻]) 𝗪𝗵𝗮𝘁’𝘀 𝗴𝗼𝗶𝗻𝗴 𝗼𝗻? Yes, tuples are immutable… BUT: They only protect the 𝘀𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲, not the 𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝘀 So: • You can’t change the tuple itself • But you can modify objects inside it In this case: • The list inside the tuple is still mutable • So .append() works perfectly fine 𝗦𝗶𝗺𝗽𝗹𝗲 𝗯𝗿𝗲𝗮𝗸𝗱𝗼𝘄𝗻: Tuple = locked container But items inside = free to move 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗺𝗮𝘁𝘁𝗲𝗿𝘀: • Can lead to unexpected data changes • Important in nested data structures • Common confusion in interviews 😅 𝗣𝘆𝘁𝗵𝗼𝗻 𝗯𝗲 𝗹𝗶𝗸𝗲: “Main bahar se strict hoon… andar se flexible” 📌 𝗗𝗮𝘆 𝟲 𝗰𝗼𝗺𝗶𝗻𝗴 𝘁𝗼𝗺𝗼𝗿𝗿𝗼𝘄: A clean Python trick that replaces 3 lines with just 1 😎 Follow for more “yeh allowed hai??” moments 😄 #Python #Programming #Developers #Coding #AI #DataScience #LearnPython
Uman Sheikh’s Post
More Relevant Posts
-
🚨 𝗣𝘆𝘁𝗵𝗼𝗻 𝗙𝘂𝗻 𝗙𝗮𝗰𝘁 𝗗𝗮𝘆 𝟲 You don’t need a temp variable to swap values 😏 𝚊 = 𝟻 𝚋 = 𝟷𝟶 𝚊, 𝚋 = 𝚋, 𝚊 𝚙𝚛𝚒𝚗𝚝(𝚊, 𝚋) 𝗢𝘂𝘁𝗽𝘂𝘁: 𝟷𝟶 𝟻 𝗪𝗮𝗶𝘁… 𝗵𝗼𝘄 𝗱𝗶𝗱 𝘁𝗵𝗮𝘁 𝗲𝘃𝗲𝗻 𝘄𝗼𝗿𝗸? In many languages, you’d do: 𝚝𝚎𝚖𝚙 = 𝚊 𝚊 = 𝚋 𝚋 = 𝚝𝚎𝚖𝚙 But Python says: “3 lines? Nah… 1 hi kaafi hai” 😌 𝗪𝗵𝗮𝘁’𝘀 𝗵𝗮𝗽𝗽𝗲𝗻𝗶𝗻𝗴 𝘂𝗻𝗱𝗲𝗿 𝘁𝗵𝗲 𝗵𝗼𝗼𝗱: Python creates a tuple behind the scenes: (𝚊, 𝚋) = (𝚋, 𝚊) Then it unpacks values back into variables. 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗶𝘀 𝗽𝗼𝘄𝗲𝗿𝗳𝘂𝗹: • Cleaner code • Less chance of bugs • Widely used in real-world Python 𝗕𝗼𝗻𝘂𝘀 𝘁𝗿𝗶𝗰𝗸: You can swap more than 2 variables too: 𝚊, 𝚋, 𝚌 = 𝟷, 𝟸, 𝟹 𝚊, 𝚋, 𝚌 = 𝚌, 𝚊, 𝚋 𝚙𝚛𝚒𝚗𝚝(𝚊, 𝚋, 𝚌) 𝗣𝘆𝘁𝗵𝗼𝗻 𝗯𝗲 𝗹𝗶𝗸𝗲: “Shortcut bhi elegant hona chahiye” 📌 𝗗𝗮𝘆 𝟳 𝗰𝗼𝗺𝗶𝗻𝗴 𝘁𝗼𝗺𝗼𝗿𝗿𝗼𝘄: Two variables that look the same… but behave totally differently 😈 Follow for more “yeh itna simple tha??” moments 😄 #Python #Programming #Developers #Coding #AI #DataScience #LearnPython
To view or add a comment, sign in
-
-
🚨 𝗣𝘆𝘁𝗵𝗼𝗻 𝗙𝘂𝗻 𝗙𝗮𝗰𝘁 𝗗𝗮𝘆 𝟴 Python can remove duplicates… in ONE line 🔥 𝚗𝚞𝚖𝚜 = [𝟷, 𝟸, 𝟸, 𝟹, 𝟺, 𝟺] 𝚞𝚗𝚒𝚚𝚞𝚎_𝚗𝚞𝚖𝚜 = 𝚕𝚒𝚜𝚝(𝚜𝚎𝚝(𝚗𝚞𝚖𝚜)) 𝚙𝚛𝚒𝚗𝚝(𝚞𝚗𝚒𝚚𝚞𝚎_𝚗𝚞𝚖𝚜) 𝗢𝘂𝘁𝗽𝘂𝘁 (𝗼𝗿𝗱𝗲𝗿 𝗺𝗮𝘆 𝘃𝗮𝗿𝘆): [1, 2, 3, 4] Wait… that’s it?? Yup. 𝚜𝚎𝚝() automatically removes duplicates Because sets only store 𝘂𝗻𝗶𝗾𝘂𝗲 𝘃𝗮𝗹𝘂𝗲𝘀 𝗕𝘂𝘁 𝘁𝗵𝗲𝗿𝗲’𝘀 𝗮 𝗰𝗮𝘁𝗰𝗵 Sets are 𝘂𝗻𝗼𝗿𝗱𝗲𝗿𝗲𝗱, so you might get: [𝟸, 𝟷, 𝟺, 𝟹] If you want order preserved: 𝚗𝚞𝚖𝚜 = [𝟷, 𝟸, 𝟸, 𝟹, 𝟺, 𝟺] 𝚞𝚗𝚒𝚚𝚞𝚎_𝚗𝚞𝚖𝚜 = 𝚕𝚒𝚜𝚝(𝚍𝚒𝚌𝚝.𝚏𝚛𝚘𝚖𝚔𝚎𝚢𝚜(𝚗𝚞𝚖𝚜)) 𝚙𝚛𝚒𝚗𝚝(𝚞𝚗𝚒𝚚𝚞𝚎_𝚗𝚞𝚖𝚜) 𝗢𝘂𝘁𝗽𝘂𝘁: [𝟷, 𝟸, 𝟹, 𝟺] 𝗥𝗲𝗮𝗹-𝘄𝗼𝗿𝗹𝗱 𝘂𝘀𝗲 𝗰𝗮𝘀𝗲𝘀: • Data cleaning (your daily scene 😏) • Removing duplicate users/emails • Preprocessing datasets for ML 𝗣𝘆𝘁𝗵𝗼𝗻 𝗯𝗲 𝗹𝗶𝗸𝗲: “𝘒𝘢𝘮 𝘤𝘰𝘥𝘦, 𝘻𝘺𝘢𝘥𝘢 𝘬𝘢𝘢𝘮” 📌 𝗗𝗮𝘆 𝟵 𝗰𝗼𝗺𝗶𝗻𝗴 𝘁𝗼𝗺𝗼𝗿𝗿𝗼𝘄: A comparison trick that looks illegal… but works perfectly 😳 Follow for more “yeh itna easy tha?” moments 😄 #Python #Programming #Developers #Coding #AI #DataScience #LearnPython
To view or add a comment, sign in
-
-
Day 9/60 Starting Chapter 2: Flow Control Topic l - Making Decisions 1. Conditions Smart programs use booleans to make decisions on whether to run lines of code or skip them. We use an if statement to write code that responds to different situations. We recognize it by the keyword if . The if statement runs code only if it is evaluated as true. It's like saying, if something is true, then do this. Let's make the evaluation true by simply using the boolean value True to display "Hello" in the console. 🧩Code if True: print("Hello!") 🖥️Output Hello! But what if we want to skip the code? In that case, we need the statement to evaluate as false. Let's easily make the statement evaluate to false by simply using the boolean value False . Nothing will print. 🧩Code if False: print("Hello!") 🖥️Output will be empty Values like True are called conditions. Statements relying on conditions are called conditionals. Conditions decide if the code runs or gets skipped. They come in between if and the colon : . 🧠Challenge of the day: Let’s see if you paid enough attention What is the output of following? 🧩Code: if true: print("3, 2, 1 GO") #python #ai #programming #bigtech
To view or add a comment, sign in
-
🚀 Built a Multi-Format PDF Data Extractor in Python I created a basic Python project that extracts structured data from different types of PDFs and raw text files, even when formats are inconsistent. 🔹 Handles multiple PDF layouts 🔹 Fallback extraction pipeline (regex → text → tables → OCR) 🔹 Extracts: PO, Brand, Size, Inseam, Quantity 🔹 Cleans and filters data automatically using pandas 🔹 Displays a clean table in terminal 🔹 Exports results to Excel 🔹 Works with messy and unstructured documents This is the first version. Next, I plan to add batch processing, logging, verification logic, and smarter format detection for higher accuracy. Learning by building real-world automation tools step by step. Feedback is welcome! #Python #PythonProgramming #PythonDeveloper #Automation #DataExtraction #PDFProcessing #Pandas #Regex #Camelot #pdfplumber #PyTesseract #OCR #DataEngineering #OpenPyXL #Tabulate #MachineLearning #AI #Developer #Coding #Tech #Programming #BuildInPublic #LearningByDoing
To view or add a comment, sign in
-
🚀 Automated My Email Workflow with Python! The Problem: Manually replying to dozens of emails daily with document attachments - 2-3 minutes each, that’s hours of repetitive work every week! The Solution: Built a Python script that: ✅ Monitors a folder for new files ✅ Finds matching emails by reference number ✅ Auto-replies with personalized greetings & attachments ✅ Runs 24/7 in the background How I Did It: Used AI (Claude) to generate the code, then customized it for my needs - Reply All, multi-folder search, duplicate prevention, and HTML formatting. The Impact: ⏱️ Saves 1-2 hours daily ✅ Zero errors 📈 Consistent responses Key Takeaway: You don’t need to be a developer to automate. With AI assistance, anyone can build practical solutions. Tools: Python | pywin32 | Claude AI #Automation #Python #ProductivityHacks #AI #WorkSmarter
To view or add a comment, sign in
-
🚨 𝗣𝘆𝘁𝗵𝗼𝗻 𝗙𝘂𝗻 𝗙𝗮𝗰𝘁 𝗗𝗮𝘆 𝟭𝟮 𝘚𝘰𝘮𝘦𝘵𝘪𝘮𝘦𝘴 𝘪𝘴 𝘣𝘦𝘤𝘰𝘮𝘦𝘴 𝘛𝘳𝘶𝘦… 𝘧𝘰𝘳 𝘯𝘰 𝘰𝘣𝘷𝘪𝘰𝘶𝘴 𝘳𝘦𝘢𝘴𝘰𝘯 𝚊 = 𝟸𝟻𝟼 𝚋 = 𝟸𝟻𝟼 𝚙𝚛𝚒𝚗𝚝(𝚊 𝚒𝚜 𝚋) 𝗢𝘂𝘁𝗽𝘂𝘁: 𝚃𝚛𝚞𝚎 𝗡𝗼𝘄 𝘁𝗿𝘆 𝘁𝗵𝗶𝘀: 𝚊 = 𝟸𝟻𝟽 𝚋 = 𝟸𝟻𝟽 𝚙𝚛𝚒𝚗𝚝(𝚊 𝚒𝚜 𝚋) 𝗢𝘂𝘁𝗽𝘂𝘁: 𝙵𝚊𝚕𝚜𝚎 (…𝘸𝘢𝘪𝘵 𝘸𝘩𝘢𝘵??) 𝗪𝗵𝗮𝘁’𝘀 𝗴𝗼𝗶𝗻𝗴 𝗼𝗻? Python does a hidden optimization called 𝘪𝘯𝘵𝘦𝘨𝘦𝘳 𝘤𝘢𝘤𝘩𝘪𝘯𝘨: Numbers from -5 to 256 are pre-stored in memory So Python reuses the same object That’s why: 𝟸𝟻𝟼 𝚒𝚜 𝟸𝟻𝟼 → 𝚃𝚛𝚞𝚎 𝟸𝟻𝟽 𝚒𝚜 𝟸𝟻𝟽 → 𝙵𝚊𝚕𝚜𝚎 (new objects created) 𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗻𝗼𝘁𝗲: This behavior can vary depending on: • Python version • Environment (REPL, script, etc.) So never rely on this in real code 𝗚𝗼𝗹𝗱𝗲𝗻 𝗿𝘂𝗹𝗲: Use == for value comparison Use 𝚒𝚜 only for identity (like None) 𝚒𝚏 𝚡 𝚒𝚜 𝙽𝚘𝚗𝚎: # 𝚌𝚘𝚛𝚛𝚎𝚌𝚝 𝗣𝘆𝘁𝗵𝗼𝗻 𝗯𝗲 𝗹𝗶𝗸𝗲: “Optimization bhi karunga… confuse bhi karunga” 𝗥𝗲𝗮𝗹-𝘄𝗼𝗿𝗹𝗱 𝗹𝗲𝘀𝘀𝗼𝗻: If you don’t understand 𝚒𝚜 vs ==, bugs will find you 📌 𝗗𝗮𝘆 𝟭𝟯 𝗰𝗼𝗺𝗶𝗻𝗴 𝘁𝗼𝗺𝗼𝗿𝗿𝗼𝘄: 𝘈 𝘰𝘯𝘦-𝘭𝘪𝘯𝘦 𝘭𝘪𝘴𝘵 𝘵𝘩𝘢𝘵 𝘤𝘳𝘦𝘢𝘵𝘦𝘴 𝘢 𝘉𝘐𝘎 𝘩𝘪𝘥𝘥𝘦𝘯 𝘣𝘶𝘨 𝘍𝘰𝘭𝘭𝘰𝘸 𝘧𝘰𝘳 𝘮𝘰𝘳𝘦 “𝘺𝘦𝘩 𝘬𝘺𝘢 𝘤𝘩𝘢𝘭 𝘳𝘢𝘩𝘢 𝘩𝘢𝘪 𝘗𝘺𝘵𝘩𝘰𝘯?” 𝘮𝘰𝘮𝘦𝘯𝘵𝘴 😄 #Python #Programming #Developers #Coding #AI #DataScience #LearnPython
To view or add a comment, sign in
-
-
Day 3/60 Continuing Chapter 1- Topic lll - True and False 1. True and False: There's a special value that's neither a string nor a number: True. There are no quotes around it, and it's not a numeric value True is great for situations like checking if a feature is on or if data is available. We can see it here when we set powered_on to True . 🧩Code powered_on = True False is another special value and the opposite of True . 🧩Code powered_on = False print(powered_on) 🖥️ Output False 2. Negating Values: The code not in front of True makes the expression result in False . If something is not true, it has to be false. not is the negation operator. It turns values into their opposite. When we change a value to its opposite with not , we negate it, like here with not True 🧩Code print(not True) 🖥️ Output False Similarly, The not operator before False changes its value. If a value is not False , it has to be True . We can use the not operator with variables to negate their values. By displaying not available here, we'll see its negated value. 🧩Code available = True print(not available) 🖥️ Output False 🧠Challenge of the day: 🧩Code morning = True is_evening = ? print(is_evening) what would you logically store in is_evening variable using morning variable so that it prints False in the Output shell? #python #programming #ai #bigtech
To view or add a comment, sign in
-
Most AI coding benchmarks test for syntax, but they often overlook real-world scalability. A script can pass every unit test and still crash a production data pipeline. This issue is prevalent: frontier models frequently default to naive O(n²) loops and costly memory reallocation instead of leveraging O(n) or O(1) architecture. To address this, we have open-sourced a sample of OptiRefine's Python Direct Preference Optimization (DPO) dataset on Hugging Face. This dataset provides the exact "rejected" (O(n²)) versus "chosen" (O(n)) trajectories necessary to train agents to refactor bottlenecks using set theory, hash map grouping, and vectorized operations. What is the worst LLM Python anti-pattern you’ve had to debug in production? Link to the Apache 2.0 dataset in the comments.
To view or add a comment, sign in
-
FastAPI starts to feel powerful when you move beyond just defining routes. That shift becomes clear when you understand how data is actually handled and validated in your APIs. While learning, I wanted a clearer picture of how request bodies, query parameters, and validation work together so I put together this breakdown: FastAPI Request Body, Query Parameter Validation, and Pydantic Settings Explained In this article, I cover: • how request bodies and query parameters are handled differently • how FastAPI uses Pydantic for automatic validation • how to structure request models cleanly • how to manage environment variables with Pydantic settings Here’s the full guide: https://lnkd.in/eF7itMXX I’m currently exploring opportunities and always open to connecting with others. What part of FastAPI took you the longest to understand? #FastAPI #Python #BackendDevelopment #APIs #Pydantic #OpenToWork #SoftwareEngineering
To view or add a comment, sign in
-
Data interpretation will be paramount in the future Not because there will be more data There is already more data than most organizations know what to do with Not because tools are lacking Between Python, AI copilots, and frameworks like Streamlit, building analysis and apps is easier than ever The shift is happening somewhere else We are moving from a world where people struggle to get answers To a world where people struggle to trust the answers they get Dashboards will be everywhere Models will be everywhere Predictions will be everywhere But interpretation will be rare Because interpretation requires something tools cannot automate easily Context Judgment Understanding variation Knowing when a change is signal and when it is noise This is where most decisions break down Not in the data Not in the code But in how the results are understood Two people can look at the same chart One reacts One interprets One makes a decision based on movement The other makes a decision based on behavior That gap is where outcomes are won or lost The future will not belong to the people who can generate insights It will belong to the people who can explain what those insights actually mean And what to do next
To view or add a comment, sign in
More from this author
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