Blog post: Understanding Python Objects: Mutable vs Immutable As part of my journey learning Python at Holberton School, I wrote a blog post about one of the most important concepts in Python: mutable and immutable objects. In this article, I cover: -What id() and type() are -The difference between mutable and immutable objects -Integer caching and string interning How arguments are passed to functions https://lnkd.in/ebnEVa9Y
Théo Caulet’s Post
More Relevant Posts
-
Day 32 of my python learning journey Today’s Python topic: Polymorphism🐍 Polymorphism = One name, many forms. Same function/method behaves differently based on object. Types I learned: 1. Duck Typing → If it walks like a duck and quacks like a duck, it’s a duck. Python cares about methods, not type. `def add(a, b): return a + b` works for int, str, list. 2. Method Overriding→ Child class changes parent class method. `class Dog(Animal): def sound(self): return "Bark"` 3. Method Overloading (sort of)→ Python doesn’t support true overloading, but we use default args or `*args` to handle it. 4. Operator Overloading → `+` works for numbers and strings. We can define `*add*` in our class too. Polymorphism makes code flexible and easy to extend. One interface, multiple behaviors. Special thanks to the CEO G.R NARENDRA REDDY Sir for constant guidance and motivation. #Python #OOP #Polymorphism
To view or add a comment, sign in
-
-
List comprehensions are one of those Python features that look intimidating at first and then become second nature fast. New tutorial on PythonCodeCrack walks through everything from the ground up: — The three-part syntax and what each part does — How a comprehension maps to an equivalent for loop — Adding filter conditions — Using enumerate() and zip() as source iterables — Ternary expressions vs. filter conditions (a common point of confusion) — When not to use a comprehension — How CPython executes them differently from for loops, including what changed in Python 3.12 — Dict and set comprehensions Includes an interactive syntax visualizer, step tracer, spot-the-bug challenges, quizzes, and a final exam with a certificate of completion. https://lnkd.in/g6VisquH #python #FreeCertificationCourse #tutorials
To view or add a comment, sign in
-
Bala Priya C walks beginners through recursion in Python, from the basics to real-world use cases like nested data and tree traversal. If you are learning Python and want to understand recursion clearly, this is a great starting point. Read it here:
To view or add a comment, sign in
-
I made a very classic beginner mistake — I underestimated Python. I thought I could skip the "essentials" and jump straight into Machine Learning like I had a mod. But ML doesn’t really do shortcuts. Turns out, it expects you to actually understand what you are doing. After spending time working with fundamentals like lists and dictionaries, I had a simple but uncomfortable realization: If your Python foundation is weak, Machine Learning doesn’t feel advanced— it just feels like you’re constantly struggling to keep up in a language you barely speak. So I’m doing the sensible thing now: going back and strengthening the basics. Yes, the “boring” stuff I tried to rush past. And honestly, Python was never the problem. My overconfidence was. #Python #MachineLearning #ProgrammingBasics #LearnToCode #NeverStopLearning #100DaysOfCode #TechLearning
To view or add a comment, sign in
-
🚀 #100DaysOfPython – Day 2: Dictionary & Set Comprehension Yesterday was list comprehension—today, taking it a step further. 👉 Dictionary comprehension squares_dict = {i: i*i for i in range(5)} 👉 Set comprehension unique_squares = {i*i for i in range(5)} ✨ Same idea, different data structures ✨ Clean and expressive 💡 When is this useful? Transforming data into key-value format Removing duplicates (sets) Quick data reshaping ⚠️ Watch out: Overcomplicating comprehensions can hurt readability. If it feels hard to read, use a loop. 🔍 My takeaway: Python gives multiple ways to solve a problem—choose the one that’s easiest to understand later. Read more: https://lnkd.in/dXMCutRw #Python #100DaysOfCode #CodingJourney #LearnPython
To view or add a comment, sign in
-
Dynamic Typing in Python — Flexibility With a Responsibility Attached When you write x = 10 in Python, something specific happens under the hood that most introductory courses don’t explain: Python doesn’t create a variable called x that holds the value 10. It creates an integer object with the value 10 in memory, and then makes x a label that points to it. That distinction matters more than it first appears. Because x is just a reference — not a fixed container — you can reassign it to something of an entirely different type: x = 10 x = "barcelona" x = 3.14 Each reassignment doesn’t overwrite the previous value in the same memory location. Python creates a new object and redirects the label. The old object, now unreferenced, gets collected automatically by the garbage collector. You never have to declare a type, and you never have to free memory manually. This is dynamic typing. The type isn’t attached to the variable — it’s attached to the object the variable currently points to. You can verify this yourself with type() and id(): x = 100 print(type(x), id(x)) x = "hello" print(type(x), id(x)) The id changes with each reassignment because x is now pointing to a completely different object in memory. The flexibility this gives you is real. But so is the responsibility. In a statically typed language, the compiler catches type mismatches before the program ever runs. In Python, those mismatches surface at runtime — which means the burden of keeping track of what a variable holds at any given moment falls on you, the developer. Dynamic typing makes Python fast to write. Understanding what it’s actually doing makes you less likely to be surprised by what it does. #Python #PythonMOOC2026 #BackendDevelopment #SoftwareEngineering #LearningInPublic #UniversityOfHelsinki
To view or add a comment, sign in
-
-
Day 27 Python Full Stack Development Journey Today’s focus was on understanding Polymorphism in Python and its key concepts. 🔹 Introduction to Polymorphism Polymorphism means “many forms”. In Python, it allows the same function, method, or operator to behave differently depending on the object or data type. Example: Python print(len("Hello")) # String length print(len([1,2,3])) # List length 🔹 Important Terminologies in Polymorphism Method Overriding Same method name in parent and child class, but different implementation. Duck Typing Python doesn’t check object type, it checks behavior. (“If it looks like a duck and acts like a duck, it is a duck.”) Dynamic Typing Variable type is decided at runtime, not fixed. 🔹 Operator Overloading Operator overloading allows operators to have different meanings for different objects. Example: Python print(5 + 3) # Addition print("Hello " + "World") # String concatenation We can also overload operators in user-defined classes. 🔹 Magic Methods (Dunder Methods) Magic methods are special methods in Python that start and end with double underscores (__). They are used to define behavior for operators and built-in functions. 👉 Common Magic Methods: __init__ → Constructor __str__ → String representation __add__ → Addition operator __len__ → Length __repr__ → Official representation 👉 Example: Python class Demo: def __init__(self, x): self.x = x def __str__(self): return f"Value is {self.x}" obj = Demo(10) print(obj) Thanks for our CEO G.R NARENDRA REDDY sir and Global Quest Technologies
To view or add a comment, sign in
-
-
💡 Python Learning – Handling User Input Errors Today I learned how to handle user input errors using try-except in Python. try → Runs code that may cause an error except → Handles the error and prevents the program from crashing Code Example: try: n = int(input("Enter Number\t")) if n > 0: print("Positive") elif n < 0: print("Negative") else: print("Zero") except ValueError: print("Please enter a valid number") Logic: n > 0 → Positive n < 0 → Negative else → Zero What I learned: input() takes data as a string int() converts it into a number If the input is invalid (like *), it throws an error We can handle this using try-except 📌 Key takeaway: Error handling makes programs more reliable and user-friendly. What should I learn next in Python? 🤔 #Python #DataAnalytics #LearningJourney #Coding #Seaborn #Matplotlib #Analytics #NareshDailyPost #DataAnalyst
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