In this Python tutorial, we will learn: What is an Indexing in Python? How can we access specific character in a string? Forward indexing with examples, Backward indexing or Negative indexes with examples, What is slicing in Python? Examples of slicing, Indexing error with example, Type error with example.
We explained how concept of Indexing and Slicing with examples.
What is indexing in Python?
In Python, a string is a sequence of characters and stored in contiguous memory location.
Each character can be individually accessed using its index.
An index is an integer.
An index of a string stars from 0. Therefore, in the string of N characters, the last character has
an index of N-1.
Python test us two-way index value for each location.
1.Forward indexing
2. Backward Indexing or Negative indexes
Forward indexing:
The index of the first character of the string is 0.
The index of the second character of the string is 1.
Backward indexing or Negative indexes:
Indexes can also have negative values.
The index of the last character of the string is - 1.
The index of the second character of the string is -2.
Slicing:
While indexing can be used to get individual characters from a string, slicing can be used to get a substring (range of characters).
Slicing can be done by specifying the start index and the end index , separated by a colon.
Indexing Error:
Python will give you an IndexError error message if you use an index that needs the index value in your string.
TypeError error:
Indexes can be only integer values; floats data types will cause a TypeError error.
This video is for CBSE students.
This video is for engineering students.
This video is for anyone (BCA, MCA, BTECH, BSc, MSc, PGDCA, Diploma and computer engineering students, under graduate or post graduate computer science students) who is interested in learning Python programming.
This is the best Python tutorial on YouTube.
Our video series is a Python tutorial for beginners.This video series will guide you through how to learn Python from scratch.
And with Ambika, having 20 years of teaching experience. My mentor, friend, and guide, Situn (Anand), is a genius with an excellent academic record and is constantly working on machine learning.
Please like, share and subscribe to our channel.
Thank you.
With love,
SA Educational Hub
Link to Data types in Python:
• Data Types in Python | Numeric | Stri...
Literals in Python:
• Literals in Python | String Literals ...
Errors in Python:
• Errors in Python | Syntax Errors | Lo...
Rvalue and Lvalue
• Lvalue and Rvalue | Lvalue and Rvalue...
Links to other videos:
Channel :
/ @saeducationalhub5697
Pattern Programs:
• Pattern Programs in Python | Python P...
Summation Series:
• Summation series in Python | Python P...
Break and continue:
• Break and Continue in Python | Differ...
Flowchart :
• Flowchart | Flowchart symbols with e...
Indentation in Python
• Indentation in Python | Python Indent...
Errors in Python
• Errors in Python | Syntax Errors | Lo...
Accepting input from user
• Accepting input from the console in P...
Type conversation:
• Type conversion in Python | Implicit ...
Date types in Python:
• Data Types in Python | Numeric | Stri...
Precedence operator:
• Operator Precedence in Python | Assoc...
Evaluation of expression:
• Evaluation of Expressions in Python |...
Mutable and immutable:
• Mutable and Immutable in Python | dif...
String data type
• String data type in Python | String i...
List data type in Python:
• List data type in Python | List | Lis...
Tuple data type in Python:
• Tuple data type in Python | Tuple | T...
Dictionary data type:
• Dictionary data type in Python | Dict...
Boolean data type
• Boolean data type in Python | Boolean...
Comments
• Python Comments | Comments in Python ...
Rvalue and Lvalue
• Lvalue and Rvalue | Lvalue and Rvalue...
Variable python
• Python Variables | Variables in Pytho...
Identity operators in Python
• Identity operators in python | is ope...
Operators in python
• Operators in Python | Arithmetic | Co...
Literals in Python:
• Literals in Python | String Literals ...
Introduction To Python:
• Introduction To Python | what is pyth...
Features of Python
• Features of Python | Python Tutorial ...
Install python on Android
• How To Install Python On Android|Pyth...
Vs Interpreter
• compiler vs interpreter | difference ...
Hello World in python:
• Hello World in python | Interactive m...
Print Vs sys.stdout.write
• print vs sys.stdout.write in python |...
What does print return
• What does print () return in python |...
Character set in Python
• Python Character Set | Python Tokens|...
Identifier
• Identifiers in Python | Python Tutori...
Keywords
• Keywords in Python | Python Tutorial ...
What does print return
• What does print () return in python |...
What is a data type in Python
• What is a data type in Python | Diffe...
#pythontutorial
#python
#cbse
#cbseclass11
#cbseclass12
#cbsepython
#pythonprogramming
#learnpython
#pythontutorialforbeginners
#pythonlanguage