Introduction to Computer Programming Strings
Strings are one of Python’s primary data types.
Strings can be used to represent anything that can be
encoded as text.
Examples: symbols, words, text
fi
les, Python programs, and
web pages.
We’ve already been using strings quite a bit and will now
focus on accessing and processing them.
String Data Type
Introduction to Computer Programming Strings
All characters have a corresponding character code.
Python uses Unicode to assign character codes.
Unicode is a common standard for encoding thousands of
symbols and characters from many languages.
The ord() function can be used to get the Unicode number
for any character.
The chr() function can be used to get the character for any
Unicode number.
Characters
Introduction to Computer Programming Strings
“Escape characters” are a special notation for whitespace and
other unprintable characters.
Used for characters without a standard symbol or symbols
Python sets aside.
Escape characters begin with a backslash: 
Escape sequences are considered one character.
Escape Characters
Introduction to Computer Programming Strings
Introduction to Computer Programming Strings
ASCII Table
Strings are de
fi
ned as ordered collections of characters.
Therefore, we can access these characters by position with
“indexing.”
Offsets start at 0 and end at one less than the length of the
string.
Offset can also be speci
fi
ed negatively.
String Indexing
Introduction to Computer Programming Strings
Introduction to Computer Programming Strings
0 1 2 3 4 5
p y t h o n
-6 -5 -4 -3 -2 -1
Slicing is for extracting substrings from a string.
To slice a string, indicate the
fi
rst character you want and one
past the last character.
First index location is always 0.
Last index location is always the length of the string minus
one.
String Slicing
Introduction to Computer Programming Strings
Testing methods
Searching methods
Formatting methods
Stripping methods
Splitting methods
Replacement methods
String Methods
Introduction to Computer Programming Strings
Introduction to Computer Programming Strings

More Related Content

PPT
Introduction to Python
PPT
Chapter05.ppt
PDF
Python data handling
PDF
Lecture 8 strings and characters
PDF
Character Array and String
PPTX
STRINGS IN PYTHON
PDF
strings in python (presentation for DSA)
PPT
Introduction to Python
Chapter05.ppt
Python data handling
Lecture 8 strings and characters
Character Array and String
STRINGS IN PYTHON
strings in python (presentation for DSA)

Similar to strings.pdf (20)

PPTX
An Introduction To Python - Strings & I/O
PPTX
Sequences: Strings, Lists, and Files
PDF
python_strings.pdf
PPTX
Python Strings and its Featues Explained in Detail .pptx
PPT
Lec 16. Strings
PPTX
trisha comp ppt.pptx
PDF
[ITP - Lecture 17] Strings in C/C++
PPTX
Engineering CS 5th Sem Python Module -2.pptx
PDF
Unit 1-Part-3 - String Manipulation.pdf
PPT
PPS_Unit 4.ppt
PPT
Strings
PPT
Strings
PPT
Strings
PPTX
Sanjana - Python--(presentation) comp. science .pptx
PPT
Strings(2007)
PPTX
Introduction To Programming with Python-3
PPTX
Programming in C - Fundamental Study of Strings
PPTX
Different uses of String in Python.pptx
PPTX
Chapter 9 python fundamentals
PDF
strings-150319180934-conversion-gate01.pdf
An Introduction To Python - Strings & I/O
Sequences: Strings, Lists, and Files
python_strings.pdf
Python Strings and its Featues Explained in Detail .pptx
Lec 16. Strings
trisha comp ppt.pptx
[ITP - Lecture 17] Strings in C/C++
Engineering CS 5th Sem Python Module -2.pptx
Unit 1-Part-3 - String Manipulation.pdf
PPS_Unit 4.ppt
Strings
Strings
Strings
Sanjana - Python--(presentation) comp. science .pptx
Strings(2007)
Introduction To Programming with Python-3
Programming in C - Fundamental Study of Strings
Different uses of String in Python.pptx
Chapter 9 python fundamentals
strings-150319180934-conversion-gate01.pdf

Recently uploaded (20)

PDF
ahaaaa shbzjs yaiw jsvssv bdjsjss shsusus s
PPT
Image processing and pattern recognition 2.ppt
PPTX
statsppt this is statistics ppt for giving knowledge about this topic
PPTX
ai agent creaction with langgraph_presentation_
PDF
Best Data Science Professional Certificates in the USA | IABAC
PPTX
AI AND ML PROPOSAL PRESENTATION MUST.pptx
PPTX
recommendation Project PPT with details attached
PPTX
MBA JAPAN: 2025 the University of Waseda
PPTX
The Data Security Envisioning Workshop provides a summary of an organization...
PDF
©️ 02_SKU Automatic SW Robotics for Microsoft PC.pdf
PPTX
DS-40-Pre-Engagement and Kickoff deck - v8.0.pptx
PDF
Session 11 - Data Visualization Storytelling (2).pdf
PPTX
chuitkarjhanbijunsdivndsijvndiucbhsaxnmzsicvjsd
PDF
Systems Analysis and Design, 12th Edition by Scott Tilley Test Bank.pdf
PPT
expt-design-lecture-12 hghhgfggjhjd (1).ppt
PPTX
SET 1 Compulsory MNH machine learning intro
PPTX
retention in jsjsksksksnbsndjddjdnFPD.pptx
PPTX
IMPACT OF LANDSLIDE.....................
PPTX
Machine Learning and working of machine Learning
PPTX
Copy of 16 Timeline & Flowchart Templates – HubSpot.pptx
ahaaaa shbzjs yaiw jsvssv bdjsjss shsusus s
Image processing and pattern recognition 2.ppt
statsppt this is statistics ppt for giving knowledge about this topic
ai agent creaction with langgraph_presentation_
Best Data Science Professional Certificates in the USA | IABAC
AI AND ML PROPOSAL PRESENTATION MUST.pptx
recommendation Project PPT with details attached
MBA JAPAN: 2025 the University of Waseda
The Data Security Envisioning Workshop provides a summary of an organization...
©️ 02_SKU Automatic SW Robotics for Microsoft PC.pdf
DS-40-Pre-Engagement and Kickoff deck - v8.0.pptx
Session 11 - Data Visualization Storytelling (2).pdf
chuitkarjhanbijunsdivndsijvndiucbhsaxnmzsicvjsd
Systems Analysis and Design, 12th Edition by Scott Tilley Test Bank.pdf
expt-design-lecture-12 hghhgfggjhjd (1).ppt
SET 1 Compulsory MNH machine learning intro
retention in jsjsksksksnbsndjddjdnFPD.pptx
IMPACT OF LANDSLIDE.....................
Machine Learning and working of machine Learning
Copy of 16 Timeline & Flowchart Templates – HubSpot.pptx

strings.pdf

  • 1. Introduction to Computer Programming Strings
  • 2. Strings are one of Python’s primary data types. Strings can be used to represent anything that can be encoded as text. Examples: symbols, words, text fi les, Python programs, and web pages. We’ve already been using strings quite a bit and will now focus on accessing and processing them. String Data Type Introduction to Computer Programming Strings
  • 3. All characters have a corresponding character code. Python uses Unicode to assign character codes. Unicode is a common standard for encoding thousands of symbols and characters from many languages. The ord() function can be used to get the Unicode number for any character. The chr() function can be used to get the character for any Unicode number. Characters Introduction to Computer Programming Strings
  • 4. “Escape characters” are a special notation for whitespace and other unprintable characters. Used for characters without a standard symbol or symbols Python sets aside. Escape characters begin with a backslash: Escape sequences are considered one character. Escape Characters Introduction to Computer Programming Strings
  • 5. Introduction to Computer Programming Strings ASCII Table
  • 6. Strings are de fi ned as ordered collections of characters. Therefore, we can access these characters by position with “indexing.” Offsets start at 0 and end at one less than the length of the string. Offset can also be speci fi ed negatively. String Indexing Introduction to Computer Programming Strings
  • 7. Introduction to Computer Programming Strings 0 1 2 3 4 5 p y t h o n -6 -5 -4 -3 -2 -1
  • 8. Slicing is for extracting substrings from a string. To slice a string, indicate the fi rst character you want and one past the last character. First index location is always 0. Last index location is always the length of the string minus one. String Slicing Introduction to Computer Programming Strings
  • 9. Testing methods Searching methods Formatting methods Stripping methods Splitting methods Replacement methods String Methods Introduction to Computer Programming Strings
  • 10. Introduction to Computer Programming Strings