String Slicing TRB CSI › Python Programming › string slicing,

String Slicing

String slicing என்பது ஒரு String-ல் இருந்து நமக்கு தேவையான ஒரு character அல்லது குறிப்பிட்ட portion / substring-ஐ எடுத்துக்கொள்ள பயன்படும் technique. Simple-a: String-ஐ cut செய்து தேவையான பகுதியை மட்டும் எடுப்பது = String Slicing.

Premium — locked Intermediate 9 min 94 cards 16 programs 5 MCQs v2
This is a premium lesson. You can see the shape of every card — unlock to read them. Unlock

STRING SLICING IN PYTHON…

Premium This card is part of the premium lesson. Unlock
Definition

String slicing என்பது ஒரு String-ல் இருந்து நமக்கு தேவையான ஒரு character அல்லது குறிப்பிட்ட……

Premium This card is part of the premium lesson. Unlock
Program
Example

இங்கே "PYTHON"-ல் முதல் 3 cha……

Premium This card is part of the premium lesson. Unlock
Simple Explanation

ஒரு String: PYTHON இதில் ஒவ்வொரு character-க்கும் ஒரு index number இருக்கும். Cha……

Premium This card is part of the premium lesson. Unlock

ஒரே character எடுத்தால் Indexi……

Premium This card is part of the premium lesson. Unlock
Explanation

String slicing-ன் முக்கிய syntax: string[start : stop : step] இதில்: start → எங்கிருந்து ஆரம்பிக்க வேண்டும் s……

Premium This card is part of the premium lesson. Unlock
Explanation

text = "PYTHON" String உருவாக்குகிறோம். text[0:3] இதன் பொருள்:……

Premium This card is part of the premium lesson. Unlock

இதில் start value கொடுக்கவில்……

Premium This card is part of the premium lesson. Unlock

என்று எடுத்துக்கொள்ளும். So: ……

Premium This card is part of the premium lesson. Unlock
Algorithm

1. STOP VALUE OMITTED…

Premium This card is part of the premium lesson. Unlock

text = "PYTHON"…

Premium This card is part of the premium lesson. Unlock
Program
இங்கே

Index: 2 → T 3 → H 4 → O 5 → N…

Premium This card is part of the premium lesson. Unlock
Output
Result
Algorithm

1. BOTH START AND STOP OMITTED…

Premium This card is part of the premium lesson. Unlock

text = "PYTHON"…

Premium This card is part of the premium lesson. Unlock

[:] என்றால் entire string.…

Premium This card is part of the premium lesson. Unlock
Algorithm

1. STEP VALUE…

Premium This card is part of the premium lesson. Unlock
Explanation
Syntax

text[start:stop:step] text = ……

Premium This card is part of the premium lesson. Unlock
Explanation

Index: 0 → P ✅ 1 → Y 2 → T ✅ 3 → H 4 → O ……

Premium This card is part of the premium lesson. Unlock
Explanation

1. DEFAULT STEP…

Premium This card is part of the premium lesson. Unlock
Explanation

Normally: step = 1 அதனால்: te……

Premium This card is part of the premium lesson. Unlock
Explanation

1. NEGATIVE INDEXING…

Premium This card is part of the premium lesson. Unlock
Explanation

Python String-ல் right side-லிருந்தும் index செய்யலாம். Character : P Y T H……

Premium This card is part of the premium lesson. Unlock
Program
Second last
Algorithm

1. NEGATIVE INDEX SLICING…

Premium This card is part of the premium lesson. Unlock

text = "PYTHON"…

Premium This card is part of the premium lesson. Unlock
Explanation

-4 → T -3 → H -2 → O -1 → N S……

Premium This card is part of the premium lesson. Unlock
Explanation

1. STRING REVERSE USING SLICI……

Premium This card is part of the premium lesson. Unlock
Explanation

Very important Python questio……

Premium This card is part of the premium lesson. Unlock
Program
means

அதனால் string reverse directi……

Premium This card is part of the premium lesson. Unlock
Algorithm

1. EVERY SECOND CHARACTER…

Premium This card is part of the premium lesson. Unlock

text = "PYTHON"…

Premium This card is part of the premium lesson. Unlock

Indexes: 0, 2, 4…

Premium This card is part of the premium lesson. Unlock
Algorithm

1. EVERY THIRD CHARACTER…

Premium This card is part of the premium lesson. Unlock

text = "ABCDEFGHIJ"…

Premium This card is part of the premium lesson. Unlock

Indexes: 0 → A 3 → D 6 → G 9 ……

Premium This card is part of the premium lesson. Unlock
Algorithm

1. REVERSE WITH STEP -2…

Premium This card is part of the premium lesson. Unlock

text = "PYTHON"…

Premium This card is part of the premium lesson. Unlock

Reverse indexes: 5 → N 3 → H ……

Premium This card is part of the premium lesson. Unlock
Comparison
Indexing vs slicing
Explanation
Example

text = "PYTHON"…

Premium This card is part of the premium lesson. Unlock
Program
But
Important

Rule 1 Python String indexing starts from: 0 Rule 2 Slicing: [start:stop] start included, stop excluded. Rule……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 1

Stop included என்று நினைப்பது text = "PYTHON" print(tex……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 2

Index out of range text = "PY……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error

IndexError ஆனால் slicing inte……

Premium This card is part of the premium lesson. Unlock

Slicing-ல் stop index பெரியதாக ……

Premium This card is part of the premium lesson. Unlock
Memory Trick

இந்த formula மட்டும் நினைவில் வைத்துக்கொள்ளுங்கள்: [start : stop ……

Premium This card is part of the premium lesson. Unlock
TRB Point

TRB / NET / SET exams-ல் அதிகமாக கேட்கக்கூடிய concepts: s……

Premium This card is part of the premium lesson. Unlock
Interview Point
Question

How can you reverse a string ……

Premium This card is part of the premium lesson. Unlock
Explanation
Example

name = "Python"…

Premium This card is part of the premium lesson. Unlock
MCQ

What is the output? s = "PYTH……

Premium This card is part of the premium lesson. Unlock
MCQ

What is the output? s = "PYTH……

Premium This card is part of the premium lesson. Unlock
MCQ

What is the output? s = "PYTH……

Premium This card is part of the premium lesson. Unlock
MCQ

What does this return? s[::-1]…

Premium This card is part of the premium lesson. Unlock
MCQ

Default step value in slicing……

Premium This card is part of the premium lesson. Unlock
Practice

Given: s = "COMPUTER" Find the output: print(s[0:3]) print(s[2:6]) print(s[:4])……

Premium This card is part of the premium lesson. Unlock
Summary

String slicing என்பது String-ல் இருந்து ஒரு spec……

Premium This card is part of the premium lesson. Unlock
Remember

Start → Included Stop → Excluded Step → Jump value Examples: s[:3] # Beginning to index 2 s[2:] # Index 2 to ……

Premium This card is part of the premium lesson. Unlock
Text size
17px
Theme
Contents
Print / PDF
Program