I used to think tuples were just “lists with stricter rules”… but today showed me they have their own vibe. 🐍 Day 06 of my #30DaysOfPython journey was all about tuples, and this topic made one thing really clear: sometimes the best data structure is the one that stays put. A tuple is an ordered and unchangeable collection of different data types, created using round brackets (). Today I explored: 1. Creating tuples with tuple() 2. Accessing items using positive and negative indexing 3. Slicing tuples with positive and negative indexes 4. Checking whether an item exists using in 5. Counting items with count() 6. Finding item positions with index() 7. Joining tuples using + operator 8. Converting tuples to lists with list() 9. Deleting the whole tuple using del What stood out to me today was how tuples are built for stability. They are not meant to be edited over and over again — and that actually makes them really useful when you want data to stay consistent. One more day, one more topic, one more layer of Python making sense. Github Link - https://lnkd.in/gHwugKTU #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
Mastering Tuples in Python: Stability and Consistency
More Relevant Posts
-
Every data science person installs packages in Notebooks and offcourse we always start at !pip install. This should be quick. Twenty minutes later, still at 78%. ERROR: Failed building wheel for difficult-package. If you have never wanted to flip a desk over a failed package installation, have you even coded? When this happens, here is what actually fixes it: Update pip first: python -m pip install --upgrade pip Install wheel: pip install wheel Google the exact error message. Someone has already solved it. Installing packages is not glamorous. But knowing how to fix it when it breaks is a real developer skill. What is the most frustrating package you have ever tried to install? #Python #DataScience #LearnToCode #Debugging #PipInstall #StudentLife
To view or add a comment, sign in
-
-
Spent 5 days chasing ghosts—DLL hell and ABI mismatches. I followed the agentic debugger down the wrong path as it hallucinated at a wrong layer because it misread the WinError 1114 as a load-path issue rather than a missing export. The actual fix was two lines. I used TORCH_LIBRARY when I needed PYBIND11_MODULE. The Architecture Gap: - Use TORCH_LIBRARY to register ops into the PyTorch C++ Dispatcher (accessed via torch.ops). It fires static C++ constructors at DLL load time but does not create a PyInit_* function. Python can't "see" it as a module. - Use PYBIND11_MODULE to generate the standard Python C Extension entry point. This generates the PyInit_{name} entry point Python needs to "see" the module. The error was literal: "dynamic module does not define module export function." No PyInit_* existed because TORCH_LIBRARY isn't meant to be imported directly. {just correcting the record} #CPP #PyTorch #SystemsProgramming #MachineLearning #barebones #3D
To view or add a comment, sign in
-
𝗧𝗵𝗲 𝗣𝘆𝘁𝗵𝗼𝗻 "𝗥𝗲𝗳𝗲𝗿𝗲𝗻𝗰𝗲" 𝗧𝗿𝗮𝗽 I noticed something interesting today : changed a value inside a function, and it reflected outside too I didn’t return anything. I didn’t re-assign the variable ➡️ 𝗧𝗵𝗲 𝗖𝗮𝘁𝗰𝗵 : Python functions don't always create a new "𝗰𝗼𝗽𝘆" of your data Instead, they often work with 𝗮 𝗿𝗲𝗳𝗲𝗿𝗲𝗻𝗰𝗲 to the original object ▪️𝗠𝘂𝘁𝗮𝗯𝗹𝗲 𝗼𝗯𝗷𝗲𝗰𝘁𝘀 (Lists, Dicts, Sets) are modified in place. Any change inside the function affects the original data directly. ▪️𝗜𝗺𝗺𝘂𝘁𝗮𝗯𝗹𝗲 𝗼𝗯𝗷𝗲𝗰𝘁𝘀 (Integers, Strings,Tuples) are safe because they can't be changed in place. ➡️ 𝗧𝗵𝗲 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆 : If you’re working with Lists or Dictionaries and want to keep your original data safe, you must be explicit: update(my_list.copy()) Small detail, but missing it can lead to hours of debugging bugs #Python #30DaysOfCode #SoftwareEngineering #LearningInPublic #Day19
To view or add a comment, sign in
-
-
Today I worked on a classic string manipulation problem that looks simple but tests your understanding of logic and edge cases. 🔍 Problem: Given a string and a substring, count how many times the substring appears in the main string. ⚠️ The catch? 👉 You must count overlapping occurrences as well. 💡 Approach I Used: Instead of using built-in shortcuts, I applied a sliding window technique: ++Loop through the string ++Extract a substring of the same length ++Compare it with the target substring ++Increment count when matched This ensures we don’t miss overlapping patterns. 🧠 Key Learning: Sometimes, simple problems reveal powerful concepts. This one reinforces: ++String slicing ++Loop boundaries ++Sliding window logic 📌 Example: "ABCDCDC" → "CDC" appears 2 times (including overlap) 💻 Check out the visuals: 🖼️ Problem breakdown 🧑💻 Python solution 🔥 Why this matters? This pattern is widely used in: --Text processing --Pattern matching --Data parsing #Python #HackerRank #CodingPractice #DataStructures #ProblemSolving #100DaysOfCode #LearningInPublic #SoftwareEngineering
To view or add a comment, sign in
-
-
Here is an event scheduler I made in python that can handle creating a new event to be scheduled, cancel one by ID, update the priority, peek at the next one, pop the one ahead, outputs the events that are in an array, load a sample data. The point of this was to create a program where we learn about the implementation of heaps, hash table and ordered structure in an algorithmic setting.
To view or add a comment, sign in
-
🚀 Day 4/100: Randomization & Data Structures! 🎰⚔️ Continuing the #100DaysOfCode challenge! Today’s training was all about making programs unpredictable and managing organized data. I built the classic "Rock Paper Scissors" game, focusing on: ✅ Python Lists (Storing and accessing data) ✅ The Random Module (Generating unpredictable outcomes) ✅ Indexing & Nested Logic (Mapping user choices to game results) Mastering how to handle lists and random events is a huge power-up for simulation and data sampling! ⚡️ Check out my code here: 🔗 https://lnkd.in/gCkGcSg6 Progressing one day at a time. Day 5, I'm coming for you! 👊 #Python #100DaysOfCode #GameDev #LogicBuilding #PythonLists #Programming #CodingLife
To view or add a comment, sign in
-
I bet your advisor has already told you to make your "code faster"! Want to solve the problem? Then use an emulator, my friend! We have released PyGLAM 0.2.2 (beta version), a Python framework for emulating probability distributions based on Generalized Lambda Distributions. Our implementation is based on the paper "Replication-based emulation of the response distribution of stochastic simulators using Generalized Lambda Distributions" by Professor Bruno Sudret. Thanks to the partners Prof. Ketson dos Santos, Prof. Marcos Luiz, and the students Victor Hugo Moreira and Renata Maria Pensin. Simple to install: pip install pyglam Learn all about it at: https://lnkd.in/gutJNpDj Feedback is more than welcome! 👇 #Python #DataScience #Math #Coding #Reliability #Reliability #Statistics #Mechanics #CivilEngineering
To view or add a comment, sign in
-
Worked on an Event Scheduler project in today’s CPSC 335 (Algorithms) class, implementing it in Python using a combination of data structures. I used a min-heap for efficient priority handling, a hash table for O(1) lookups, and a sorted list for time-based queries. This exercise was a great way to see how different data structures can be combined to balance performance and functionality, and how trade-offs play a key role in algorithm design.
To view or add a comment, sign in
-
Built my first Python node in ROS 2 this week — a follow-up to my earlier post on core concepts. 𝗪𝗵𝗮𝘁 𝗜 𝗯𝘂𝗶𝗹𝘁: A CircleDrawer node that publishes velocity commands to TurtleSim, making the turtle draw an expanding spiral. 𝗦𝘁𝗲𝗽𝘀 𝗳𝗼𝗹𝗹𝗼𝘄𝗲𝗱: 1️⃣ Created a ROS 2 Python package with rclpy dependency 2️⃣ Wrote the node — a Python class inheriting from Node, using create_publisher() and create_timer() 3️⃣ Updated package.xml and setup.py (entry_points) 4️⃣ Built with colcon build → sourced the workspace → ran the node 𝗞𝗲𝘆 𝗰𝗼𝗻𝗰𝗲𝗽𝘁𝘀 𝗽𝗿𝗮𝗰𝘁𝗶𝗰𝗲𝗱: • OOP-based node structure in ROS 2 • Timer callbacks for periodic publishing • Building & running a custom package end-to-end • Visualizing node-topic connections with rqt_graph Going from theory to working code in ROS 2 is a big step. Colcon, entry points, sourcing the workspace — it's a lot of config, but once it runs, it's very rewarding. Next up: Services & Actions.
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