#python #datascience #dataanalytics #pythonlibraries
#pythonprogramming
Python, String - Indexing, Slicing, Quick Reference,
Python String Indexing, String Index,
Python String Slicing, String Slice,
Length of a string, Position,
Positive Index, Negative Index,
Indexing retrieves or extracts character from the specified position of string.
파이썬 문자열 인덱싱, 파이썬 문자열 슬라이싱,
파이썬 빠르게 배우기,
파이썬,
#파이썬 #파이썬독학 #파이썬기초 #파이썬강의
#파이썬문자열
String indexing
Indexing retrieves a single character from a string based on its position.
String slicing
Slicing extracts a substring using a range of indices. The full syntax is [start:stop:step].
#pythonprogramming #pythoncoding
#pythonstrings #pythonstring
University of Madras, Core 1 - Python Programming,
Semester - 1
B.Sc., Computer Science with Data Science,
B.Sc., Computer Science with Artificial Intelligence,
B.Sc., Computer Science,
B.Sc., Software Applications
BCA,
UGC NET Computer Science,
PG TRB 2025,
PG TRB Computer Science 2025,
PG TRB Computer Instructor 2025,
PG TRB Computer Science Syllabus 2025,
PG TRB Computer Instructor Syllabus 2025,
PG TRB Computer Science Study Material,
PG TRB Computer Instructor Study Material,
Unit Wise, Unit 7, Python Programming,
PG TRB Computer Science Study Material unit wise,
#pgtrb #pgtrbstudymaterialintamil
#pgtrb2025 #pgtrbcomputerscience #pgtrbcs
#tntrb #trbcssyllabus #trbexam
#trbpreparation
Quick Recap, Quick Guide
Quick Overview, Quick Tips, Quick Revision, Interview,
Python MCQ Questions and Answers,
Python MCQ O Level NIELIT Certification,
Python Flow Control Structures, Control Statements,
Quick guide to Python Control Structures,
Python Control Statements explained,
Python Control Structures for beginners,
Common Python Control Structures for Interview,
#python #pythonbasics #pythonstrings #pythonstring
#quickguide
#pythontutorial #pythonforbeginners
University of Madras,
Python Programming,
125C1A, 141C1A, 120C1A,
127C1A, 126C1A,
Anna University, UGC NET, TANCET, UGCNET, NTA,
TN SET,
#madrasuniversity #universityofmadras
#bsccomputerscience #bca #mca
#annauniversity
#btechfirstyear
#pythondeveloper #pythoncoding #learnpython
#pythonquiz #python3 #pythonskills #codingpython
#pythonbasics #pythonbeginner #pythonprogramming
#datascience #dataanalytics
#pythontips #pythontricks
#codingquiz #codingcommunity
#freshers #techtalk #top10
#interviewpreparation #interviewhacks #interviewquestions #interviewskills
#youtubeshorts #viral #foryoupage
Ace your Python exams with this Quick Reference Guide!
Covers various Python concepts, including Execution Modes, Built-in Functions, Data types,
Operators, Input/Output Statement, data structures, and more.
#PythonMCQs #PythonInterview #CodingQuiz #PythonProgramming #TechSkills
#ssitlecturestamil @ssitlecturestamilதமிழ்
String Indexing Example
(Code ➔ Output)
Indexing retrieves a single character from a string at a specified index (position).
Syntax: str[index]
Index refers to the numerical position of a character within a string.
Zero-based: First character of a string is at index 0, length of the string is n.
str = "Python"
P y t h o n
0 1 2 3 4 5
-6 -5 -4 -3 -2 -1
str[0] ➔ P
Positive Index: Counts forward from the left. Ranges from 0 to n-1.
str[2] ➔ t
Negative Index: Counts backward from the right. Ranges from -n to -1.
str[-3] ➔ h
Out of bound: Raises an IndexError: string index out of range if the index is outside the string's range.
str[6]➔ IndexError
String Slicing Example
(Code ➔ Output)
Slicing extracts a substring using start, end as a range of indices with step.
Syntax: str[start:end:step]
Slice of str from start i to end j with step k is the sequence of items with index x = i + t*k such that 0 lesser or equal t lesser (j-i)/k. The indices are i, i+k, i+2*k, i+3*k and so on.
Length of a slice is difference(i,j)/k, if i,j are within bounds. n is length of the string len(str).
str = "Python"
P y t h o n
0 1 2 3 4 5
-6 -5 -4 -3 -2 -1
str[1:4] ➔ yth
str[-4:-1] ➔ tho
Start: Starting index (included). Optional, defaults to 0 for positive step, n-1 for negative step.
str[:2] ➔ Py
End: Ending index (excluded). Optional, defaults to n for positive step, -n-1 for negative step.
str[2:] ➔ thon
Step: The interval between characters. Optional, defaults to 1. Negative values returns reverse of the slice by moving backwards (from right).
str[1::3] ➔ yo
str[-1:-5:-2] ➔ nh
str[::-1] ➔ nohtyP
Out of bound: Handled gracefully. Returns available substring or an empty string. If step is 0 then returns ValueError: slice step cannot be zero
str[:10] ➔ Python
str[10:] ➔
(empty string)
String is Immutable. So, index, slice cannot be used to change character(s) in a string but only to access character(s).
Информация по комментариям в разработке