Friday brings #Python Let's talk about Protocol today. It allows you to have "duck typing". If an object has the required fields/methods, then the type checker keeps silent and no inheritance is required. It's a powerful thing to build interfaces. Take a look.
Ivan Karabadzhak’s Post
More Relevant Posts
-
GAN-like Synthetic Data Generation Examples (on univariate, multivariate distributions, digits recognition, Fashion-MNIST, stock returns, and Olivetti faces) with DistroSimulator https://lnkd.in/eHwpXVGd #python #rstats
To view or add a comment, sign in
-
-
#Problem: write a #python program to find missing and addtional values in two lists. #Solution: list1 = [1,2,3,4,5,6] list2 = [3,4,5,6,7,8] missing_num = [] for x in list1: if x not in list2: missing_num.append(x) print(missing_num) addition = [] for x in list2: if x not in list1: addition.append(x) print(addition)
To view or add a comment, sign in
-
🚀 Python Tip of the Day Ever wondered how to handle multiple conditions cleanly in one line? Check out this elegant one-liner that decides the discount type based on the customer’s tier 👇 # Decide discount type based on customer type customer = {"type": "Gold"} discount_type = ( "Platinum Discount" if customer["type"] == "Platinum" else "Gold Discount" if customer["type"] == "Gold" else "Silver Discount" if customer["type"] == "Silver" else "Regular Discount" ) print(discount_type) 💡 Output: Gold Discount What’s Happening: Each condition is checked in order — Python picks the first one that’s true! It’s a clean way to replace multiple if-elif-else blocks when your logic is short and simple. #Python #CodingTips #SoftwareDevelopment #100DaysOfCode #PythonDeveloper #LearningPython
To view or add a comment, sign in
-
Python Day 5 Tip: Difference Between append() and extend() Both are used to add elements to a list , but they work differently! # Example list1 = [1, 2, 3] list1.append([4, 5]) print(list1) #output is [1, 2, 3, [4, 5]] list1 = [1, 2, 3] list1.extend([4, 5]) print(list1) #output is [1, 2, 3, 4, 5] 1) append() adds the entire object as a single element. 2) extend() adds each element from the iterable individually. Tip: Use append() for single items and extend() for adding multiple items at once. #Python #30DaysOfpythonCode #PythonTips #Coding #FullStackDeveloper #LearnPython #PythonLearning
To view or add a comment, sign in
-
LeetCode POTD 🫠: Description: You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros. In one operation you can choose any subarray from initial and increment each value by one. Return the minimum number of operations to form a target array from initial. The test cases are generated so that the answer fits in a 32-bit integer. Here's my solution: https://lnkd.in/gUKAaRQG #Python #DSA #Leetcode #DailyChallenge
To view or add a comment, sign in
-
-
🚀 Set in Python - A Set in Python is a collection data type that is unordered, unindexed, and contains unique elements. It is mainly used when you want to store non-duplicate items and perform mathematical set operations like union, intersection, and difference. 🧩 Key Features: ▪️ Unordered: Elements have no defined order. ▪️ Mutable: You can add or remove items after creation. ▪️ No duplicates: Automatically removes repeated elements. ▪️ Supports set operations like union(), intersection(), difference(), etc. 💡 When to Use: 🔸 You need unique values. 🔸 You want to perform fast membership testing. 🔸 You need set-based operations (like finding common elements). #Python #PythonLearning #PythonBasics #DataStructures #Coding #LearnPython #SetInPython
To view or add a comment, sign in
-
-
🚀 Calculating Time Differences with Timedelta (Python) You can calculate the difference between two `datetime` objects by subtracting one from the other. The result is a `timedelta` object representing the duration between the two points in time. This is useful for measuring elapsed time, calculating deadlines, or determining the length of events. Ensure both `datetime` objects are timezone-aware or naive to avoid incorrect results. #Python #PythonDev #DataScience #WebDev #professional #career #development
To view or add a comment, sign in
-
-
🚀 The 'in' Operator: Checking Membership in Data Structures (Python) The 'in' operator is used to check if a value exists within a data structure like a list, tuple, set, or dictionary. For lists and tuples, it checks if the value is present as an element. For sets, it provides efficient membership testing due to their underlying hash table implementation. For dictionaries, it checks if the value is present as a key. #Python #PythonDev #DataScience #WebDev #professional #career #development
To view or add a comment, sign in
-
-
Python MarkItDown: Convert Documents Into LLM-Ready Markdown Get started with Python MarkItDown to turn PDFs, Office files, images, and URLs into clean, LLM-ready Markdown in seconds. https://lnkd.in/eUbCyEiF
To view or add a comment, sign in
-
Python MarkItDown: Convert Documents Into LLM-Ready Markdown Get started with Python MarkItDown to turn PDFs, Office files, images, and URLs into clean, LLM-ready Markdown in seconds. https://lnkd.in/eUbCyEiF
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