🚀 Day 3/30 – Python OOPs Challenge 💡 __init__() Constructor in Python In Day 2, we learned about Class & Object. Today let’s understand how objects get initial data. 🔹 What is __init__()? __init__() is a constructor. It runs automatically when we create an object. We use it to initialize (set) values for an object. 🔹 Simple Example: ``` class Student: def __init__(self, name, roll_no): self.name = name self.roll_no = roll_no def display(self): print(self.name, self.roll_no) s1 = Student("Argha", 101) s1.display() ``` 🔹 Why use __init__()? - To pass data while creating an object - To avoid writing extra code later - Makes code clean and readable 📌 Key takeaway: __init__() helps us give starting values to objects. 👉 Day 4: Instance variables vs Class variables (coming tomorrow) 👍 Like | 💬 Comment | 🔁 Share 📍 Follow me to learn Python OOP step by step #Python #OOP #LearningInPublic #30DaysOfPython #CodingJourney
Argha Chatterjee’s Post
More Relevant Posts
-
🚀 Day 12/30 – Python OOPs Challenge 💡 Types of Inheritance in Python Yesterday we learned what Inheritance is. Today let’s see the different types of inheritance in Python. 🔹 1️⃣ Single Inheritance One child class inherits from one parent class. ``` class Parent: def show(self): print("Parent class") class Child(Parent): pass c = Child() c.show() ``` 🔹 2️⃣ Multiple Inheritance One child class inherits from more than one parent class. ``` class Father: def skill1(self): print("Gardening") class Mother: def skill2(self): print("Cooking") class Child(Father, Mother): pass c = Child() c.skill1() c.skill2() ``` 🔹 3️⃣ Multilevel Inheritance Inheritance chain (Grandparent → Parent → Child) ``` class Grandparent: def home(self): print("Owns a house") class Parent(Grandparent): pass class Child(Parent): pass c = Child() c.home() ``` 🔹 Other Types (Conceptually) - Hierarchical Inheritance - Hybrid Inheritance 📌 Key takeaway: Inheritance helps reuse code in different structures. 👉 Day 13: Method Overriding (coming tomorrow) 👍 Like | 💬 Comment | 🔁 Share 📍 Follow me to learn Python OOP step by step #Python #OOP #LearningInPublic #30DaysOfPython #CodingJourney
To view or add a comment, sign in
-
Lists in Python Python lists just saved me hours of manual work. Here's how: 📊 Instead of creating separate variables for each student score: score1 = 85 score2 = 92 score3 = 78 I learned to use a list: scores = [85, 92, 78, 95, 88] One line. Five values. Infinite possibilities. Lists are mutable (changeable) and can store multiple items — making data management so much easier. This is why Python is loved by data analysts and developers alike. What's your go-to Python data structure for organizing information? #Python #PythonLists #DataStructures #CodingTips #TechLearning #ProgrammingBasics #PythonForBeginners
To view or add a comment, sign in
-
-
👋 Welcome back! 📅 Python Learning – Day 31 Today is about understanding how files behave when you open them: Python File Modes. When you open a file, Python needs to know what you want to do with it. Read it, write new data, add to it, or create it safely. That’s exactly what file modes control. 📘 In this lesson, I’ve explained: 📖 `r` — read an existing file ✍️ `w` — write (and overwrite) a file ➕ `a` — append data to a file 🆕 `x` — create a new file safely Most file-related bugs happen because the wrong mode is used. Once you understand these four modes, file handling becomes predictable and safe. Choosing the right mode protects your data and your logic. 🔗 Tutorial link is in the comments. ⏭️ Tomorrow: Python OOP #PythonFileModes #FileHandlingPython #LearnPythonDaily #ProgrammingFoundations #PythonForBeginners #BackendConcepts #CleanCoding #DeveloperSkills #TechLearning #codepractice #codepracticelearning #pythonlearning #python
To view or add a comment, sign in
-
-
🚀 Day 9/30 – Python OOPs Challenge 💡 Public vs Private Variables in Python Yesterday we learned about Encapsulation. Today let’s understand the difference between: 👉 Public Variables 👉 Private Variables 🔹 1️⃣ Public Variable - Can be accessed from anywhere - Default type in Python Example: ``` class Student: def __init__(self): self.name = "Argha" # Public variable s1 = Student() print(s1.name) # Accessible ``` 🔹 2️⃣ Private Variable - Cannot be accessed directly outside the class - Written using double underscore __ Example: ``` class Student: def __init__(self): self.__marks = 90 # Private variable s1 = Student() print(s1.__marks) # ❌ This will give an error ``` 🔹 Why use Private Variables? - Protect sensitive data - Avoid accidental changes - Better control using methods 📌 Key takeaway: Public → accessible everywhere Private → restricted access 👉 Day 10: Getter and Setter Methods (coming tomorrow) 👍 Like | 💬 Comment | 🔁 Share 📍 Follow me to learn Python OOP step by step #Python #OOP #LearningInPublic #30DaysOfPython #CodingJourney
To view or add a comment, sign in
-
🚀 Day 9 – Understanding Abstraction & Special Methods in Python (OOP) Today I continued my OOP learning journey by studying Abstraction and Special (Dunder) Methods in Python. 🔹 Abstraction Abstraction focuses on hiding complex implementation details and exposing only the essential functionality, making systems easier to use and maintain. 🔹 Special (Dunder) Methods I also explored Python’s special methods like __init__, __str__, and __len__. These methods allow objects to interact naturally with Python’s built-in functions and operators. Learning these concepts helped me understand how Python classes can be designed to behave more like built-in objects while keeping code structured and maintainable. 📚 References: https://lnkd.in/eUYYx8sU https://lnkd.in/egUvmRrf Step by step strengthening my Python OOP fundamentals. #DataEngineering #Python #AI #NewCareer #SelfLearning #OOP
To view or add a comment, sign in
-
-
🐍 Python Concept I Use Often: Dictionary vs Defaultdict One small choice in Python can make your code cleaner, faster, and less error-prone. Problem Counting occurrences in a list using a normal dictionary usually looks like this: counts = {} for item in data: if item in counts: counts[item] += 1 else: counts[item] = 1 It works—but it’s verbose and easy to mess up. Better Approach Using defaultdict from collections: from collections import defaultdict counts = defaultdict(int) for item in data: counts[item] += 1 Why this matters ✔ Removes conditional checks ✔ Improves readability ✔ Reduces chances of KeyError ✔ Scales well in data processing pipelines Curious—what’s your go-to Python feature that instantly improves code quality? #Python #PythonDeveloper #CleanCode #BackendDevelopment #DataEngineering #ProgrammingTips #SoftwareEngineering
To view or add a comment, sign in
-
🐍 Python Basics: Syntax, Variables & Data Types Python is beginner-friendly, but mastering the fundamentals is key to writing clean and efficient code. 1️⃣ Syntax Python uses indentation instead of {} to define code blocks. if True: print("Hello, Python!") 2️⃣ Variables Variables are containers for data. No need to declare type explicitly; Python is dynamically typed. name = "Alice" age = 25 3️⃣ Data Types Numbers: int, float, complex Text: str Boolean: bool (True / False) Collections: list, tuple, set, dict numbers = [1, 2, 3] person = {"name": "Bob"} ✅ Pro Tip: Use meaningful variable names—it makes your code much easier to read! Python’s simplicity lets you focus on logic, not syntax. Master these basics and you’re ready to dive into loops, functions, and more. 💡 Comment “Python Basics” if you want a full beginner-friendly guide next! #Python #Programming #Coding #LearnPython #Developer #Tech #DataScience #SoftwareEngineering #ProgrammingBasics #PythonTips
To view or add a comment, sign in
-
🐍 Day 12 of my Python Full-Stack Journey — Mastering Lists! Today I went deep into one of Python's most powerful built-in data structures: Lists. Here's what I covered: ✅ Creating and indexing lists ✅ Slicing (list[1:4], negative indexing) ✅ List methods — append(), extend(), insert(), remove(), pop(), sort(), reverse() ✅ List comprehensions (honestly a game-changer 🤯) ✅ Nested lists and iterating with loops The "aha moment" today? List comprehensions. Instead of writing 4 lines to filter a list, you can do it in ONE: squares = [x**2 for x in range(10) if x % 2 == 0] Clean. Pythonic. Beautiful. 🧠 Lists feel simple at first — but understanding how they work under the hood (mutability, references, shallow vs. deep copy) is where real Python thinking begins. 12 days in. The foundation is getting solid. Drop a 💬 if you're also learning Python — would love to connect and grow together! #Python #100DaysOfCode #FullStackDeveloper #LearningInPublic #PythonJourney #CodeNewbie #SoftwareDevelopment
To view or add a comment, sign in
-
-
Day 25 | The Python Feature That Made My Code Cleaner 🐍 One small Python concept that felt confusing at first — but now I love: List Comprehensions. Earlier, I used to write: squares = [] for i in range(10): squares.append(i * i) Then I learned this: squares = [i * i for i in range(10)] Same result. Cleaner. Shorter. More readable. At first it looked complicated. Now it feels natural. That’s the thing about Python — Many concepts look hard until you understand the pattern. List comprehensions taught me: • Think in expressions • Write concise logic • Read code more efficiently Still practicing. Still improving. What Python concept took time to “click” for you? #Day25 #PythonLearning #ListComprehension #CodingJourney #AIJourney #DataScienceStudent #LearningInPublic #TechGrowth
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
🧠 Practice Question – Day 3 Create a class `Book` with: - title - author - price Use `__init__()` to initialize values. Create one object and print the details. Try it yourself 👇 Comment your code 🚀