Topic 10/100 🚀 🧠 Topic 10 — Partial Functions What if you could pre-fill some arguments of a function and reuse it later? 🤯 👉 What is it? Partial functions allow you to fix a few arguments of a function and generate a new function with fewer parameters. 👉 Use Case: Used in real-world applications for: Pre-configuring functions Simplifying repeated function calls Building reusable utilities 👉 Why it’s Helpful: Reduces repetition Makes code cleaner Improves readability 💻 Example: from functools import partial def multiply(x, y): return x * y double = partial(multiply, 2) print(double(5)) # Output: 10 🧠 What’s happening here? We fixed the value of x = 2, creating a new function (double) that only needs one argument. ⚡ Pro Tip: Use partial functions when you find yourself passing the same arguments repeatedly. 💬 Follow this series for more Topics #Python #BackendDevelopment #100TopicOfCode #SoftwareEngineering #LearnInPublic
Partial Functions in Python: Simplify Repeated Calls
More Relevant Posts
-
🚀 Day 39/100 – LeetCode Challenge Today’s problem: 406. Queue Reconstruction by Height This problem focuses on applying a Greedy approach with sorting to reconstruct a queue based on height and positional constraints. 🔍 Key Insight: Sort people by height in descending order and k value in ascending order, then insert each person at their respective index. 💡 What I learned: Importance of sorting strategy in greedy problems How insertion at a specific index can maintain constraints Thinking from the perspective of "who affects whom" (taller vs shorter) 🧠 Approach: Sort the array → (-height, k) Insert each person at index k 💻 Code (Python): class Solution: def reconstructQueue(self, people): people.sort(key=lambda x: (-x[0], x[1])) queue = [] for p in people: queue.insert(p[1], p) return queue ⏱️ Time Complexity: O(n²) Consistency is the key — showing up every day and improving step by step. #Day39 #LeetCode #100DaysOfCode #DSA #Python #CodingChallenge #GreedyAlgorithm #SoftwareDevelopment
To view or add a comment, sign in
-
-
From “it works” to “it won’t break” While writing a code, Getting it to work is one thing, 𝗠𝗮𝗸𝗶𝗻𝗴 𝘀𝘂𝗿𝗲 𝗶𝘁 𝗱𝗼𝗲𝘀𝗻’𝘁 𝗯𝗿𝗲𝗮𝗸 is another. price = products["Laptop"] This works fine… until the 𝗸𝗲𝘆 𝗱𝗼𝗲𝘀𝗻’𝘁 𝗲𝘅𝗶𝘀𝘁 . That’s when the program crashes. So instead of assuming every piece of data is present, Its better to start thinking about what happens when it isn’t. In college projects, we often focus on making things work. In real-world scenarios, 𝗲𝗱𝗴𝗲 𝗰𝗮𝘀𝗲𝘀 matter just as much. 𝗗𝗮𝘆 𝟭𝟮/𝟯𝟬 #Python #LearningInPublic #Day12 #30DaysOfCode #SoftwareEngineering
To view or add a comment, sign in
-
If you're using a list comprehension just to pass results into functions like sum() or max(), those brackets might be unnecessary. Dropping them turns it into a generator, so Python processes each value on demand instead of storing everything in memory. ✅ Same result with less overhead—which is especially noticeable with large datasets. Use brackets when you actually need a list, skip them when you don’t. Check out this week's edition of #PythonTips Tuesday!
To view or add a comment, sign in
-
🚀 Day 36 – LeetCode Journey Today’s problem: String to Integer (atoi) ✔️ Handled leading spaces and signs (+/-) ✔️ Processed numeric characters step by step ✔️ Managed overflow conditions within 32-bit integer range 💡 Key Insight: Carefully handling edge cases (like spaces, signs, and overflow) is just as important as the core logic. Small conditions can make a big difference in correctness. This problem strengthened my understanding of string parsing, edge cases, and boundary conditions. Learning to write robust and reliable code every day 💪🔥 #LeetCode #Day36 #Strings #EdgeCases #Python #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 83 of #100DaysOfCode 📌 Problem Solved: Letter Combinations of a Phone Number (LeetCode 17) Today’s challenge was all about exploring backtracking and how recursive decision-making builds combinations efficiently. 🔍 Given a string of digits (2–9), the goal is to generate all possible letter combinations based on the classic phone keypad mapping. 💡 Key Learning: Instead of trying every possible string blindly, backtracking helps us build combinations step-by-step and explore only valid paths — making the solution clean and efficient. ⚡ Highlights: ✔️ Used recursion to explore all possibilities ✔️ Implemented a digit-to-letter mapping ✔️ Built combinations incrementally ✔️ Achieved optimal runtime performance 📈 Result: ✅ All test cases passed ⚡ 0 ms runtime (Beats 100%) Consistency is starting to compound — one problem at a time. 💪 #LeetCode #DSA #Python #CodingJourney #Backtracking #100DaysOfCode
To view or add a comment, sign in
-
-
Day 3 / 100 🚀 Solved “Reverse Integer” — a problem that looks simple but actually tests how carefully you handle edge cases. At first, reversing digits feels straightforward. But the real challenge is handling 32-bit overflow without using extra space. 💡 Key learning: Before updating the result, always check if multiplying by 10 will exceed the allowed range. Core idea: rev * 10 + digit must stay within [-2³¹, 2³¹ - 1] Highlights: • Time Complexity: O(log n) • Space Complexity: O(1) • Correctly handles negative numbers and overflow This problem reinforced a critical habit: Don’t just make the logic work — validate boundary conditions. #100DaysOfCode #LeetCode #DSA #Python #ProblemSolving #CodingInterview
To view or add a comment, sign in
-
-
Today: LeetCode 88 — Merge Sorted Array. Saw "sorted arrays" in the problem. My brain immediately said: two pointers. Started coding. Got stuck pretty fast. The issue? When you're merging into an existing array without extra space, two pointers aren't enough — you need a third one tracking where to place elements. And you have to go backwards through nums1, or you'll overwrite values you still need. Took longer than I'd like to admit. Used hints. Eventually got it — and it beat 100% on runtime. The real lesson wasn't the algorithm. It was this: pattern recognition gets you to the door, but you still have to figure out which version of the pattern fits. "Two pointers" is a family of techniques, not a single move. Knowing the name isn't the same as understanding the shape of the problem. Day 36 of #1000DaysOfLearning #DSA #Python #LearningInPublic
To view or add a comment, sign in
-
-
Day 8/30 - Taking a Revision Day No new topic today and that's completely intentional. Learning to code isn't just about pushing forward every day. Sometimes the best move is to slow down and let things sink in. So today I'm going back over Days 1–7 and making sure I actually understand what I've covered before moving on: 📌 Day 1 — Setting up Python & printing 📌 Day 2 — Variables & data types 📌 Day 3 — Strings & string methods 📌 Day 4 — Lists in python 📌 Day 5 — String formatting 📌 Day 6 — Type casting: int(), float(), str() 📌 Day 7 — User input & simple programs If you're following along , this is your sign to do the same. Go back. Re-read your notes. Re-run your code. Ask yourself: can I explain this to someone else? Because revision is not a step back. It's how you make sure the foundation is solid before you build higher. Tomorrow I'll be back with Day 9 — and I'll be ready. 💪 #30DaysOfPython #Python #LearnToCode #CodingJourney #WomenInTech
To view or add a comment, sign in
-
📈 Day 53 of #GeekStreak60 🧩 Today’s problem was about checking whether a matrix is a Toeplitz Matrix. 🧠 Core Idea Every element should match its top-left diagonal neighbor ↖️ If all such pairs match → the matrix is Toeplitz ✅ 💡 What I Did ➡️ Traversed the matrix starting from (1,1) ➡️ Compared each element with its top-left neighbor mat[i-1][j-1] 🔍 ➡️ Returned ❌ false immediately if any mismatch was found 📚 What I Learned ✨ Simple observations about patterns (like diagonals) can lead to clean and efficient solutions ✨ You don’t always need complex logic — sometimes local checks are enough! 🔥 Day 53 complete Consistency + clarity = growth 🚀 #GeekStreak60 #GeeksforGeeks #NPCI #Day53 #ProblemSolving #Python #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 32/60 — LeetCode Discipline Problem Solved: Find the Index of the First Occurrence in a String Difficulty: Easy Today’s problem was about locating a substring within a string — a classic example of pattern searching. Using a straightforward approach, I iterated through the string and checked each possible starting point where the substring could match. This reinforces how simple logic, when applied cleanly, can be highly effective. 💡 Focus Areas: • Strengthened understanding of string traversal • Practiced substring comparison • Improved handling of boundary conditions • Learned importance of index-based iteration • Focused on writing clean and readable code ⚡ Performance Highlight: Achieved 0 ms runtime (100% performance) Sometimes the answer isn’t hidden deep — it’s right there… waiting for a careful eye to notice it. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #Strings #Algorithms #ProblemSolving #CodingJourney #SoftwareEngineering #Python #Developers #Consistency #TechGrowth
To view or add a comment, sign in
-
More from this author
-
🚀 Just Took My First Steps with the OpenAI Python API — Here's How Easy It Is!
HIMANSHU MAHESHWARI 2mo -
Beyond the Hype: A Practical Guide to Integrating AI & ML Into Your Projects
HIMANSHU MAHESHWARI 6mo -
🧠 Laravel Jobs & Queues vs Django Celery: A Backend Developer's Guide to Async Task Management 🚀
HIMANSHU MAHESHWARI 1y
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