While learning Conditional Operators and TRY / EXCEPT, I built this little program that honestly reflects real life more than I expected: The outcomes are brutally honest: ✅ Type 1 (Yes sunscreen) → Beach! 🏖️ 🧴 Type 2 (No sunscreen) → Library. No sunscreen, no fun. 📚 🤷 Type something random → Stay home, the program doesn't even argue. 🏠 💥 Type letters or symbols → Crash avoided, still staying home. 🏠 That's the real power of TRY / EXCEPT — instead of blowing up when something goes wrong, your code takes a deep breath and figures it out. No drama. Just solutions. 😂 #Python #DataScience #LearningInPublic #TryExcept #ConditionalOperators #CodingJourney #DataAnalytics
TRY/EXCEPT in Python: Real-Life Error Handling
More Relevant Posts
-
A single train-test split can make a weak model look strong. Cross-validation solves this by evaluating performance across multiple time windows. You train up to a cutoff, forecast forward, shift the cutoff, and repeat. But doing this for multiple models means writing separate loops, managing cutoffs, and combining outputs manually. TimeCopilot removes that overhead. With one method call, you get predictions from every model across every fold. Statistical models, foundation models, naive baselines. All evaluated together without separate pipelines. 🚀 Learn how to use cross-validation to compare foundation models in this example: https://lnkd.in/gx6QmA4S #TimeSeries #Forecasting #Python #CrossValidation
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
-
-
📌 Problem: Increasing Triplet Subsequence 💡 Approach: Traverse the array while maintaining two variables: first and second, representing the smallest and second smallest values found so far. If the current number is smaller than first, update first Else if it’s smaller than second, update second If a number is greater than both, we’ve found an increasing triplet This ensures an optimal single-pass solution. ⚙️ Key Insight: Track only two values instead of checking all triplets Greedy + optimization approach reduces complexity significantly ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) 📚 What I learned: Greedy strategy for subsequence problems Reducing brute-force O(n³) to optimal linear solution #LeetCode #DSA #Algorithms #Coding #ProblemSolving #Python #Greedy #InterviewPreparation #CodingJourney
To view or add a comment, sign in
-
Built a Rainfall Prediction model and deployed it live. Here is what actually happened behind the scenes Decision Tree gave me 100% training accuracy. I got excited. Then I checked the test score and realised the model had just memorised the data. It learned nothing real. Naive Bayes gave me 73.9% on both train and test. Consistent That is the one I deployed. 3 models trained. 1 deployed. 1 lesson — a consistent score beats a perfect score every time live app here: https://lnkd.in/d-xaufug Full project and code: https://lnkd.in/d_d2Tx7R Akarsh Vyas Tanishq Vyas #DataScience #MachineLearning #Python #Streamlit #BuildInPublic #MLProject
To view or add a comment, sign in
-
🚀 Day 13 of #100DaysOfDSA Today’s problem was simple but powerful: 👉 Calculate x raised to the power y (x^y) using a while loop. 💡 Key Learning: How to use a loop for repeated multiplication Understanding how exponentiation works internally Strengthening logic-building with basic iteration 🧠 Approach: Initialize power = 1 Multiply x repeatedly y times Decrease y in each iteration ✅ Code (Python): x = int(input()) y = int(input()) power = 1 while y > 0: power *= x y -= 1 print(power) ⚡ Time Complexity: O(y) ⚡ Space Complexity: O(1) 📌 Small problems like this build strong fundamentals for advanced topics like recursion and fast exponentiation. Consistency is the real game 🔥 See you on Day 14! #DSA #Python #CodingJourney #WhileLoop #100DaysChallenge
To view or add a comment, sign in
-
-
✅ Day 90 of 100 Days LeetCode Challenge Problem: 🔹 #476 – Number Complement 🔗 https://lnkd.in/gzE6gM7d Learning Journey: 🔹 Today’s problem focused on finding the complement of a number by flipping its binary bits. 🔹 I first converted the integer to its binary representation using bin(num)[2:]. 🔹 Then, I created a helper function to flip each bit: • '0' → '1' • '1' → '0' 🔹 After generating the flipped binary string, I converted it back to an integer using int(..., 2). 🔹 Returned the final complemented value. Concepts Used: 🔹 Binary Representation 🔹 Bit Manipulation 🔹 String Traversal 🔹 Base Conversion Key Insight: 🔹 The complement operation is essentially a bitwise NOT, but only within the significant bits of the number (ignoring leading zeros). 🔹 Converting to binary simplifies the flipping logic for beginners. Complexity: 🔹 Time: O(log n) 🔹 Space: O(log n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
The Shortcut That Became Your Default A quick fix. Skipping validation. Hardcoding values. Copying old logic without questioning. A faster way to get results. The steps you skipped writing down never got documented. “I’ll fix this later,” you told yourself. It felt temporary. But you didn’t fix it and days later the logic was already forgotten. And soon, it became the default—quietly shaping your process. 👉 Shortcuts don’t fail in isolation. They quietly build a system that works—until it doesn’t. 👉 In data work, shortcuts rarely stay short-term. #DataAnalytics #Python #LearningInPublic #AnalyticsThinking
To view or add a comment, sign in
-
🚀 LeetCode Grind: Find First and Last Position of Element in Sorted Array Just solved a classic searching problem! 💻 Problem: Given a sorted array, find the starting and ending position of a given target value. The Challenge: Achieving $O(\log n)$ runtime complexity. Key Takeaway: While a linear scan works, leveraging Binary Search twice (once for the left boundary and once for the right) is the key to meeting the performance constraints. It’s a great reminder of how powerful binary search is for optimizing search operations on sorted data. Checking off another one as I continue to sharpen my problem-solving skills! 🛠️ #LeetCode #CodingChallenge #Python #Algorithms #DataStructures #ProblemSolving #TechJourney #BinarySearch
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