diff --git a/Lesson 6 - String Manipulation/FormatString.py b/Lesson 6 - String Manipulation/FormatString.py index 4fa20f7..24ae802 100644 --- a/Lesson 6 - String Manipulation/FormatString.py +++ b/Lesson 6 - String Manipulation/FormatString.py @@ -2,4 +2,28 @@ print("PYTHON IS KING".lower()) print("python is hot".upper()) print("Harry potter and the half-blood prince".title()) -print("AVENGER:the war of infinity".swapcase()) \ No newline at end of file +print("AVENGER:the war of infinity".swapcase()) + + +text = "python is FUN" +result = text.capitalize() +print("Original:", text) +print("After capitalize():", result) + +text2 = "123hello world" +print("\nOriginal:", text2) +print("After capitalize():", text2.capitalize()) + +text3 = " hello world" +print("\nOriginal with spaces:", repr(text3)) +print("After capitalize():", repr(text3.capitalize())) + +""" +This lesson explains the .capitalize() string method in Python. + +Key Points: +1. Converts the first character to uppercase if it is a letter. +2. Converts all other characters to lowercase. +3. If the first character is not a letter (e.g., space, number, symbol), + no capitalization occurs. +""" \ No newline at end of file diff --git a/README.md b/README.md index a499cca..e166fa0 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,88 @@ ![](https://www.codetriage.com/josharsh/learning-object-oriented-python/badges/users.svg) This repository walks you through the Object Oriented Programming in python. Illustrates real world examples, working codes and going about finding a coding solution. +# OPython-Init + +A beginner-friendly collection of **Object-Oriented Programming (OOP)** examples in Python. + +This repository aims to help learners **understand OOP concepts in Python through simple, clear, and practical code examples**. +It’s designed for students, self-learners, and anyone transitioning from procedural programming to Python OOP. + +--- + +## πŸ‘₯ Who Is This For? + +This repository is best suited for: + +- πŸ§‘β€πŸ’» Beginners who already know **basic Python syntax** (variables, loops, conditionals, functions) +- πŸ’‘ Learners who understand **OOP concepts theoretically** but want to see how they work in Python +- πŸ“š Students preparing for programming assignments or building their first Python projects + +If you’ve just started learning Python and want to move beyond basic scripting β€” this repo is for you! + +--- + +## πŸ“˜ Prerequisites + +Before exploring the lessons, make sure you are familiar with: + +- Writing and running Python scripts (`.py` files) +- Basic concepts like: + - Variables and Data Types + - Lists, Tuples, Dictionaries, and Sets + - Functions and Parameters + - If-Else Statements and Loops + +If you’re missing these, you can review the new lesson: +[`Lesson_DataStructures.py`](./Lesson_DataStructures.py) + +--- + +## 🎯 Learning Goals + +By the end of these lessons, you will: + +- Understand how **classes** and **objects** work in Python +- Learn how to use **constructors (`__init__`)** and **instance variables** +- Implement **inheritance, polymorphism, and encapsulation** +- Know how to organize and reuse code using OOP design +- Write **real-world examples** that use OOP principles effectively + +--- + +## 🧩 Repository Structure + +| Folder / File | Description | +|----------------|-------------| +| `Lesson_1_Introduction.py` | Basics of Python syntax | +| `Lesson_2_ClassesObjects.py` | Classes and Objects explained | +| `Lesson_3_Inheritance.py` | Inheritance and subclassing | +| `Lesson_4_Polymorphism.py` | How methods behave differently in subclasses | +| `Lesson_5_Encapsulation.py` | Private and protected members | +| `Lesson_6_Abstraction.py` | Abstract classes and interfaces | +| `Lesson_DataStructures.py` | *(New)* Basic Data Structures in Python | +| `Lesson_StringMethods.py` | *(New)* Common String Methods like `.capitalize()` | + +--- + +## 🧠 Example Lesson Format + +Each lesson follows this format for clarity: + +1. **Concept Introduction** β€” short description of what’s being taught +2. **Code Example** β€” simple, syntax-highlighted Python code +3. **Explanation** β€” plain-English breakdown of what happens +4. **Try It Yourself** β€” small challenge or modification to practice + + +# Example: Defining a Class +class Student: + def __init__(self, name): + self.name = name + + def greet(self): + print(f"Hello, I'm {self.name}") + +student1 = Student("Aarav") + +student1.greet() \ No newline at end of file