Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Lesson 6 - String Manipulation/FormatString.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
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.
"""
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()