𝗗𝗮𝘆 𝟭3: 𝗧𝘂𝗽𝗹𝗲𝘀 𝗶𝗻 𝗣𝘆𝘁𝗵𝗼𝗻 🐍 🔹 Tuples are ordered and immutable collections of items, separated by commas and enclosed in round brackets. 🔹 Items can be of multiple data types 🔹 Once created, tuples cannot be changed, added to, or deleted 𝗖𝗿𝗲𝗮𝘁𝗶𝗻𝗴 𝗧𝘂𝗽𝗹𝗲𝘀: ✔ Single-item tuple (comma is mandatory) ✔ Using parentheses: (1, 2, 3) ✔ Without parentheses: tup = 1, 2, 3 𝗖𝗼𝗺𝗺𝗼𝗻 𝗢𝗽𝗲𝗿𝗮𝘁𝗶𝗼𝗻𝘀: ✔ Indexing and slicing (same as lists) ✔ Unpacking – assign tuple values to multiple variables ✔ Concatenation – combine tuples using + 📝𝗡𝗼𝘁𝗲: 🔸 Tuples cannot be modified directly. 🔸 To make changes, convert the tuple to a list, modify it, and convert it back to a tuple. Building strong Python fundamentals, one concept at a time 🚀 #Python #Tuples #LearningPython #LearningInPublic #AspiringDataScientist #Consistency
Python Tuples: Ordered Immutable Collections
More Relevant Posts
-
𝗗𝗮𝘆 𝟭𝟰: 𝗦𝗲𝘁𝘀 𝗶𝗻 𝗣𝘆𝘁𝗵𝗼𝗻 🐍 𝗦𝗲𝘁𝘀: 🔹 Sets are unordered collections of items 🔹 Elements are unique (no duplicate values) 🔹 Items are separated by commas and enclosed in curly brackets { } 🔹 Sets do not maintain order 𝗖𝗿𝗲𝗮𝘁𝗶𝗻𝗴 𝗮 𝗦𝗲𝘁: 🔹 s = {1, 2, 3} 🔹 Use set() to create an empty set : s = set() ⚠️ {} creates an empty dictionary, not a set 𝗦𝗲𝘁 𝗢𝗽𝗲𝗿𝗮𝘁𝗶𝗼𝗻𝘀: 1️⃣𝗨𝗻𝗶𝗼𝗻 (|) → combines elements 2️⃣𝗜𝗻𝘁𝗲𝗿𝘀𝗲𝗰𝘁𝗶𝗼𝗻 (&) → common elements 3️⃣𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲 (-) → elements in one set but not the other 4️⃣𝗦𝘆𝗺𝗺𝗲𝘁𝗿𝗶𝗰 𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲 (^) → elements not common 📝Important Notes: 🔹 Sets do not support indexing or slicing 🔹 Elements must be immutable (int, string, tuple) Building strong Python fundamentals, one concept at a time 🚀 #Python #Tuples #LearningPython #LearningInPublic #AspiringDataScientist #Consistency
To view or add a comment, sign in
-
🐍 Day 22 — Functions in Python Day 22 of #python365ai 🧩 Functions group reusable code. Example: def greet(name): print("Hello", name) 📌 Why this matters: Functions improve readability and reduce repetition. 📘 Practice task: Write a function that adds two numbers. #python365ai #PythonFunctions #CleanCode #LearnPython
To view or add a comment, sign in
-
-
One concept I understand better now is List Comprehensions. Sometimes I felt like my python scripts were getting cluttered with repetitive for loops and .append() calls. I used to think list comprehensions were just a shorthand trick, but they are actually a more efficient way to handle data transformation. It’s the difference between writing a paragraph and writing a perfectly concise sentence. The syntax used to look intimidating, but here is how it finally clicked for me: new_list = [expression for item in iterable if condition] The Expression: What do you want to keep? (e.g., x or x**2) The Loop: Where is it coming from? (e.g., for x in my_list) The Filter: Do you want all of them or just some? (e.g., if x > 10) Why I’m using it from now on: Readability: Once you know the syntax, you can read the logic in a single line. Speed: It’s technically faster than a standard loop. Less Room for Error: No need to initialize empty lists or manage counters. Small shifts in syntax lead to big jumps in code quality. NativesPlug @locus.ioe #LOCUS2026 #NativesPlug #LearningChallenge #15DayChallenge #NepalTech #LearnAndWin #PythonTips
To view or add a comment, sign in
-
𝐈𝐟 𝐏𝐲𝐭𝐡𝐨𝐧 𝐟𝐞𝐞𝐥𝐬 𝐜𝐨𝐧𝐟𝐮𝐬𝐢𝐧𝐠, 𝐭𝐡𝐢𝐬 𝐢𝐬 𝐮𝐬𝐮𝐚𝐥𝐥𝐲 𝐭𝐡𝐞 𝐫𝐞𝐚𝐬𝐨𝐧 𝐰𝐡𝐲. Data structures decide how you store, access, and work with information. If you get them wrong, everything would feel harder than it should. Lists, tuples, and dictionaries show up in almost every data and ML task. You will use them daily, not occasionally. 𝐒𝐚𝐯𝐞 𝐭𝐡𝐢𝐬 𝐜𝐡𝐞𝐚𝐭 𝐬𝐡𝐞𝐞𝐭. 𝐈𝐭 𝐰𝐢𝐥𝐥 𝐬𝐚𝐯𝐞 𝐲𝐨𝐮 𝐡𝐨𝐮𝐫𝐬 𝐥𝐚𝐭𝐞𝐫. 𝐖𝐡𝐢𝐜𝐡 𝐝𝐚𝐭𝐚 𝐬𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞 𝐝𝐨 𝐲𝐨𝐮 𝐮𝐬𝐞 𝐦𝐨𝐬𝐭? #HEMPIMLBootcamp #MachineLearningAfrica #TechInNigeria #NYSC #CareerGrowth #PythonLearning #30DaysToMLMastery #Python
To view or add a comment, sign in
-
-
Pandas 3.0 is here! 🎉https://lnkd.in/dfAUP2bH - Copy-on-Write (CoW) fully implemented: SettingWithCopyWarning is gone ✅. No more debugging mysterious copies - chained assignments just work - pd.col() syntax: Clean column references in assign() and loc() without messy lambdas. E.g., df.assign(c=pd.col('a') + pd.col('b')) - Faster UDFs 🚀: No more "slow as molasses" user-defined functions - major perf boosts via better optimization (full Arrow backend didn't land, but it's solid) I made a Kaggle notebook to try https://lnkd.in/d-SsfryV #Pandas #DataScience #Python #DataAnalysis #MachineLearning
To view or add a comment, sign in
-
𝗽𝗮𝗻𝗱𝗮𝘀 𝟯.𝟬: 𝗧𝗵𝗲 𝗘𝗻𝗱 𝗼𝗳 𝗦𝗲𝘁𝘁𝗶𝗻𝗴𝗪𝗶𝘁𝗵𝗖𝗼𝗽𝘆𝗪𝗮𝗿𝗻𝗶𝗻𝗴 New Feature: new default string dtype 🤖Problem When you filter a DataFrame and modify the result, you expect the original to stay unchanged. But sometimes pandas modified your original data anyway, triggering the SettingWithCopyWarning. 🌝Solution pandas 3.0 fixes this. Filtering now always creates a separate copy, so modifying the result never affects your original data. Upgrade to pandas 3.0 with “pip install -U pandas”. #data #dataanalysis #Pandas3 #datascience #tech #python
To view or add a comment, sign in
-
-
𝐕𝐚𝐫𝐢𝐚𝐛𝐥𝐞𝐬 𝐬𝐨𝐮𝐧𝐝 𝐭𝐞𝐜𝐡𝐧𝐢𝐜𝐚𝐥. 𝐓𝐡𝐞𝐲’𝐫𝐞 𝐧𝐨𝐭. Body A variable is just a name for something you want to remember in your code. Instead of writing the same value again and again, you store it once and reuse it. That’s how programs stay clean and readable. 1. 𝑾𝒉𝒂𝒕 𝒂 𝒗𝒂𝒓𝒊𝒂𝒃𝒍𝒆 𝒊𝒔 A variable is a label that points to a value. Just like saving a contact name instead of memorizing a phone number. 2. 𝑯𝒐𝒘 𝒕𝒐 𝒂𝒔𝒔𝒊𝒈𝒏 𝒐𝒏𝒆 You create a variable using the equals sign: age = 20 This tells Python: store 20 under the name age. 3. 𝑹𝒆𝒂𝒍-𝒘𝒐𝒓𝒍𝒅 𝒆𝒙𝒂𝒎𝒑𝒍𝒆𝒔 name = "Alex" price = 2500 is_student = True These look like everyday things because that’s exactly what they represent. Once you get this, half of Python stops feeling confusing. 𝐃𝐫𝐨𝐩 𝐚 𝐯𝐚𝐫𝐢𝐚𝐛𝐥𝐞 𝐧𝐚𝐦𝐞 𝐲𝐨𝐮 𝐜𝐚𝐧 𝐜𝐫𝐞𝐚𝐭𝐞 𝐭𝐨𝐝𝐚𝐲. 𝐂𝐥𝐢𝐜𝐤 𝐭𝐡𝐞 𝐥𝐢𝐧𝐤 𝐭𝐨 𝐫𝐞𝐠𝐢𝐬𝐭𝐞𝐫 𝐟𝐨𝐫 𝐨𝐮𝐫 𝐌𝐋 𝐁𝐨𝐨𝐭𝐜𝐚𝐦𝐩 𝐢𝐧 𝐭𝐡𝐞 𝐜𝐨𝐦𝐦𝐞𝐧𝐭𝐬 𝐬𝐞𝐜𝐭𝐢𝐨𝐧. #PythonBeginners #LearnPython #CodingBasics #TechStudents #MachineLearningJourney #HEMPI
To view or add a comment, sign in
-
What if you could write multi-condition logic without nested function calls? pandas requires np.where() for conditional columns, which breaks method chaining and becomes nested fast. The apply() alternative is slow and also breaks the DataFrame workflow. Polars replaces nested np.where() with readable when().then().otherwise() chains that scale cleanly to any number of conditions. Better yet, you can combine them with any other Polars expression like string or date operations. 🚀 Article comparing pandas, polars, and DuckDB: https://bit.ly/4qfdtDd ☕️ Run this code: https://bit.ly/4qKPn3H #Python #Polars #DataScience #pandas
To view or add a comment, sign in
-
-
Flagging outliers in time series is tricky. You need to decompose the series, calculate the residuals, choose a threshold, and then check if the results make sense. That's a lot of manual steps. And a lot of room for error. TimeCopilot handles it differently. You pass your data to detect_anomalies() and get: • Prediction intervals built with conformal methods • Anomalies flagged based on the confidence level you choose • Visualization with forecasts and anomalies together No separate tools. No manual calculations. 🚀Full tutorial: https://lnkd.in/ePEjshey #TimeSeries #AnomalyDetection #Python #DataScience
To view or add a comment, sign in
-
-
🚀 𝗗𝗮𝘆 𝟯/𝟯𝟬 — 𝗗𝗦𝗔 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲 Consistency check ✔️ Today was about working with counting and uniqueness patterns — figuring out when a set or dictionary can save you from writing unnecessary loops (and unnecessary headaches). 🔎 𝗗𝗮𝘆 𝟯 𝗙𝗼𝗰𝘂𝘀 • Frequency/count tracking • Using sets for uniqueness checks • Solved: ✅ Majority Element ✅ Missing Number ✅ Single Number Small progress, fewer overcomplicated solutions, and only mild confusion — I’ll take that as a win On to Day 4 💪 #DSA #Python #LeetCode #LearningInPublic #Consistency #SoftwareEngineering
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