diff --git a/Lesson 6 - String Manipulation/StringSlicing.py b/Lesson 6 - String Manipulation/StringSlicing.py index 1589d03..b56a305 100644 --- a/Lesson 6 - String Manipulation/StringSlicing.py +++ b/Lesson 6 - String Manipulation/StringSlicing.py @@ -4,20 +4,41 @@ #OBS: always stops at the previous index(number) -print(word[2:7]) -> #Result: otosy -> #strts from 2 and ends before 7 +print(word[2:7]) #Result: otosy -> #strts from 2 and ends before 7 -print(word[:5]) -> #Result: photo -> #ends before 5 +print(word[:5]) #Result: photo -> #ends before 5 -print(word[:]) -> #Result: photosynthesis -> #print whole string +print(word[:]) #Result: photosynthesis -> #print whole string -print(word[::3]) -> #Result: ptyhi -> #print 0 and multiple of 3 afterwards +print(word[::3]) #Result: ptyhi -> #print 0 and multiple of 3 afterwards -print(word[3::3]) -> #Result: tyhi -> #print 3 and multiple of 3 afterwards +print(word[3::3]) #Result: tyhi -> #print 3 and multiple of 3 afterwards -print(word[:-1]) -> #Result: photosynthesi -> #ends before -1 +print(word[:-1]) #Result: photosynthesi -> #ends before -1 -print(word[:-7]) -> #Result: photosy -> #ends before -7 +print(word[:-7]) #Result: photosy -> #ends before -7 -print(word[::-1]) -> #Result: sisehtnysotohp -> #print string in reverse +print(word[::-1]) #Result: sisehtnysotohp -> #print string in reverse -print(word[5::-1]) -> #Result: sotohp -> #print reverse till 5 +print(word[5::-1]) #Result: sotohp -> #print reverse till 5 + +# Using slicing with reverse and specific stop: +print(word[8:3:-1]) # Result: tonyt -> Starts from 8 and goes to index 3 (exclusive) in reverse + +# Entire string in reverse: +print(word[::-1]) # Result: sisehtnysotohp -> Reverses the whole string + +# Reverse from a specific index: +print(word[7::-1]) # Result: ynotohp -> Starts from index 7 and reverses to the beginning + +# Reverse from a specific index to a specific index: +print(word[10:4:-1]) # Result: ehtony -> Starts at index 10 and reverses to index 5 (exclusive) + +# Extract with a step: +print(word[1:12:2]) # Result: htsyhs -> From index 1 to index 12 (exclusive) with step of 2 + +# Negative indices with slicing: +print(word[-1:-6:-1]) # Result: siseh -> Starts at the last character and goes back 5 characters + +# Reverse specific part: +print(word[6:0:-1]) # Result: ysohto -> Starts at index 6 and reverses to index 1 (exclusive) \ No newline at end of file diff --git a/README.md b/README.md index a499cca..990be6f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,56 @@ # Learning-Object-Oriented-Python ![](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. + +# Learning Object-Oriented Python + +This repository walks you through the concepts of **Object-Oriented Programming (OOP)** in Python. It provides real-world examples, practical coding exercises, and solutions to help you master OOP concepts effectively. + +--- + +## Table of Contents + +- [Overview](#overview) +- [Features](#features) +- [Getting Started](#getting-started) + - [Prerequisites](#prerequisites) + - [Installation](#installation) +- [Lessons](#lessons) +- [Contributing](#contributing) +- [License](#license) + +--- + +## Overview + +This repository is a comprehensive guide to learning Object-Oriented Programming in Python. Whether you're a beginner or someone looking to strengthen your OOP skills, this project has resources for you. + +--- + +## Features + +- Detailed lessons covering OOP concepts. +- Practical examples and working code. +- Real-world problem-solving approaches. + +--- + +## Getting Started + +### Prerequisites + +Before using this repository, ensure you have the following installed: + +- Python 3.6 or higher +- A code editor (e.g., VS Code, PyCharm) +- Git (for version control) + + +## Lessons + +Introduction to Python - Basics of Python programming. +Using Functions - Understanding Python functions. +Introduction to OOP Concepts - Core OOP principles. +OOP Implementation - Practical OOP examples. +Web Scraping - Using Python for web scraping. +String Manipulation - Advanced string operations. \ No newline at end of file