Today I practiced Set Operations: Subset, Superset, Disjoint # Set Operations in Python # Subset, Superset, Disjoint Example # Creating Sets A = {1, 2, 3, 4} B = {1, 2} C = {5, 6} print("Set A:", A) print("Set B:", B) print("Set C:", C) # 1️⃣ Subset print("\nIs B subset of A?") print(B.issubset(A)) # True # 2️⃣ Superset print("\nIs A superset of B?") print(A.issuperset(B)) # True # 3️⃣ Disjoint print("\nAre A and C disjoint?") print(A.isdisjoint(C)) # True #Python #Learning #CodingJourney
Rushikesh Choudhari’s Post
More Relevant Posts
-
Let’s think together 👇 def change_value(x): x = x + 10 return x num = 5 change_value(num) print(num) 🤔 What do you think the output will be? Is it: 15 5 Error ✅ The correct answer is: 5 Wait… why not 15? 😏 Because in Python, integers are immutable. When we passed num into the function: The value 5 was copied into x The function modified x But the original variable num was never reassigned So num stays the same. 🔥 The real twist If we did this instead: num = change_value(num) print(num) Now the output becomes 15 Because we reassigned the returned value. 💡 Key Insight Python doesn’t magically change your variables. You must explicitly reassign them. This small concept explains: Why integers behave differently than lists Why some bugs happen silently The core idea behind mutable vs immutable objects Now your turn 👇 What do you think would happen if we used a list instead of an integer? 😏 #Python #Coding #100DaysOfCode #Programming #Backend #LearningJourney
To view or add a comment, sign in
-
When I wrote Cookiecutter in 2013, I also created the first Cookiecutter template ever, a template for the ultimate Python package. 13 years later I've only just released v0.4.0. It took me this long because I didn't see a great use case for releasing it on PyPI until I started using uv/uvx heavily. Now you or your AI agent can get my boilerplate for a modern, fully-featured Python package by running one command: uvx cookiecutter-pypackage It comes with Audrey-level obsession over best practices, of course. I thought of making this release 1.0.0 but wanted to keep the version number humble. Be gentle and patient if you try it: I'm sure there will be a ton of embarrassing bugs that need fixing. There's also so much more that I want to do with it. https://lnkd.in/gBCJpz6P
To view or add a comment, sign in
-
🐍 Day 60 — Bar Charts in Matplotlib Day 60 of #python365ai 📊 Bar charts compare categories. Example: plt.bar(["A", "B", "C"], [5, 7, 3]) plt.show() 📌 Why this matters: Bar charts are common in reports and dashboards. 📘 Practice task: Create a bar chart for three products. #python365ai #BarChart #DataAnalysis #Python
To view or add a comment, sign in
-
-
Working with data often begins by narrowing things down. Rarely does someone need to look at an entire dataset all at once. Instead, the question is usually more specific: Which transactions were unusually large? Which users joined recently? Which records meet a particular condition? Before any analysis happens, the relevant cases have to be separated from the rest. In data work, this step is essentially a process of filtering. Each record is examined, and only the ones that meet a defined condition are kept. What matters here is not just the rule itself, but the consistency with which it is applied. The same condition must be evaluated across every record. That is where programming becomes useful. Instead of applying the rule manually, the program evaluates it repeatedly and produces the subset that matches the criteria. The dataset remains the same. Only the portion we choose to focus on changes. Day 27 / 30 #30DaysOfDataScience #Python #DataThinking #LearningInPublic
To view or add a comment, sign in
-
-
Day 12 of #50DaysOfPython Today’s concept: Finding missing numbers in a sequence. A practical problem to understand list operations, iteration, and logical comparison in Python. 🔎 Code Explanation: 1. Store the array arr = [1,2,3,5,6] This list contains numbers where one value is missing. 2. Find the total count including the missing number n = len(arr) + 1 len(arr) gives the count of numbers present (5). Since one number is missing, we add 1 → n = 6 3. Calculate the expected sum expected_sum = n * (n + 1) // 2 This formula calculates the sum of numbers from 1 to n. For n = 6 → 6 × 7 / 2 = 21 4. Calculate the actual sum actual_sum = sum(arr) Add the numbers in the list → 1 + 2 + 3 + 5 + 6 = 17 5. Find the missing number missing = expected_sum - actual_sum 21 − 17 = 4 6. Print the result print("Missing number:", missing) 👉This approach shows how mathematical logic can simplify problems instead of using loops. Swipe through the slides to see the explanation, code, and output 👇 #50DaysOfPython #PythonLearning #CodingLife #LearnToCode
To view or add a comment, sign in
-
Day 25 – divmod() print(divmod(10, 3)) Use: Quotient & remainder Content: Used divmod() to get quotient and remainder. Useful in math logic. #Python generate like a cartoon style image Image created Generated image Generated image Generated image Share Gulive description to post in. Linked in Here’s a clean LinkedIn-ready description for your post: 🚀 Day 25 of #30DaysOfCode – Learning divmod() in Python Today I explored the divmod() function in Python. print(divmod(10, 3)) 🔹 divmod() returns both the quotient and remainder in a single step. 🔹 Output: (3, 1) 🔹 It combines the functionality of // (floor division) and % (modulus). This function is especially useful in mathematical logic, time calculations, and problem-solving scenarios where both values are needed together. Small functions, big impact! 💡 #Python #PythonBasics #CodingJourney #LearnToCode #Programming #30DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 4 – DSA Daily Series Move Zeroes (LeetCode 283) using Python. 🧠 Problem Given an integer array nums, move all 0’s to the end of the array while maintaining the relative order of the non-zero elements. Important constraints: • The operation must be done in-place • No extra array should be created Example: Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0] 💡 Approach Used the Two Pointer technique. • Maintain a pointer k to track the position for the next non-zero element • Traverse the array using index i • Whenever a non-zero element is found, swap it with the element at position k • Increment k This ensures: • Non-zero elements move to the front • Zeros automatically shift toward the end ⏱ Complexity Time Complexity: O(n) – single pass through the array Space Complexity: O(1) – in-place modification 🔎 Key Learning This problem helps strengthen: • Two Pointer pattern • In-place array manipulation • Maintaining relative order while rearranging elements Consistency is key when practicing DSA — solving one problem at a time. 🚀 #DSA #LeetCode #Python #Algorithms #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 54 of 365 Days of code 1) Capacity to Ship Packages Within D Days Approach: Binary search 1)set low = max(weights) 2) high= low*sum(weights) 3) perform the below steps until low<=high condition fails i) mid=low+(high-low)//2;res=0 ii) set w = mid and initialize day=1 iii) iterate through the loop and perform the stuff i put in screenshot (ahh life hurts :") ) iv) if the day <= days: set res=mid ; set high=mid-1 v) else low=mid+1 4) return res #365daysOfCode #NeetCode #leetcode #DSA #python #LeetCode #ProblemSolving #Algorithms #365dayschallenge
To view or add a comment, sign in
-
-
🧠 Python Concept That Makes Functions Remember State: Function Attributes Functions aren’t just code. They’re objects 👀 🤔 The Surprise You can attach attributes to functions. def counter(): counter.count += 1 return counter.count counter.count = 0 print(counter()) # 1 print(counter()) # 2 No class. No global variable. Still remembers state 🎯 🧠 Why This Works Because in Python: def demo(): pass print(type(demo)) # function And functions have their own __dict__. 🧒 Simple Explanation 👩🏫 Imagine a teacher 📒 She keeps a notebook 📒 Every time you ask something, she checks her notebook. 📒 That notebook = function attribute. 💡 Why This Is Powerful ✔ Lightweight state ✔ Memoization tricks ✔ Decorator helpers ✔ Cleaner than globals ✔ Interview flex 😄 ⚡ Proof print(counter.__dict__) 🐍 In Python, even functions can store data 🐍 They’re not just instructions — they’re full objects with memory. #Python #PythonTips #PythonTricks #AdvancedPython #CleanCode #LearnPython #Programming #DeveloperLife #DailyCoding #100DaysOfCode
To view or add a comment, sign in
-
-
Python Clarity Series – Episode 3 Topic: input() confusion (string vs int) 🤯 Why does this code not work? x = input("Enter a number: ") print(x + 5) Many students get an error here. Reason? 👇 👉 input() always takes value as STRING So: "x" + 5 ❌ (Error) int(x) + 5 ✅ (Correct) 💡 Fix: x = int(input("Enter a number: ")) This small concept is tested frequently in exams. Students—did this ever confuse you? #PythonLearning #CodingBasics #StudentConfusion
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