Submit Search
Upload
Python Programming Essentials - M7 - Strings
•
5 likes
•
2,194 views
P3 InfoTech Solutions Pvt. Ltd.
Follow
Slides from the training on the topic "Python Programming Essentials"
Read less
Read more
Technology
Report
Share
Report
Share
1 of 23
Recommended
Python 3.x quick syntax guide
Python 3.x quick syntax guide
Universiti Technologi Malaysia (UTM)
L14 exception handling
L14 exception handling
teach4uin
Data Types, Variables, and Operators
Data Types, Variables, and Operators
Marwa Ali Eissa
Polymorphism in java
Polymorphism in java
Elizabeth alexander
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
Atul Sehdev
Polymorphism presentation in java
Polymorphism presentation in java
Ahsan Raja
Package in Java
Package in Java
lalithambiga kamaraj
Interface in java
Interface in java
PhD Research Scholar
Recommended
Python 3.x quick syntax guide
Python 3.x quick syntax guide
Universiti Technologi Malaysia (UTM)
L14 exception handling
L14 exception handling
teach4uin
Data Types, Variables, and Operators
Data Types, Variables, and Operators
Marwa Ali Eissa
Polymorphism in java
Polymorphism in java
Elizabeth alexander
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
Atul Sehdev
Polymorphism presentation in java
Polymorphism presentation in java
Ahsan Raja
Package in Java
Package in Java
lalithambiga kamaraj
Interface in java
Interface in java
PhD Research Scholar
Threads in JAVA
Threads in JAVA
Haldia Institute of Technology
Java Data Types
Java Data Types
Spotle.ai
Oops concept on c#
Oops concept on c#
baabtra.com - No. 1 supplier of quality freshers
C++ Language
C++ Language
Syed Zaid Irshad
Classes objects in java
Classes objects in java
Madishetty Prathibha
Java abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
Program control statements in c#
Program control statements in c#
Dr.Neeraj Kumar Pandey
String handling(string class)
String handling(string class)
Ravi_Kant_Sahu
String, string builder, string buffer
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
Java interface
Java interface
BHUVIJAYAVELU
Object Oriented Programming with Java
Object Oriented Programming with Java
backdoor
Java IO
Java IO
UTSAB NEUPANE
Java access modifiers
Java access modifiers
Srinivas Reddy
Java static keyword
Java static keyword
Lovely Professional University
Oops ppt
Oops ppt
abhayjuneja
Control Statements in Java
Control Statements in Java
Niloy Saha
Java Threads
Java Threads
M Vishnuvardhan Reddy
Java Lambda Expressions.pptx
Java Lambda Expressions.pptx
SameerAhmed593310
Character Array and String
Character Array and String
Tasnima Hamid
Inheritance in java
Inheritance in java
Lovely Professional University
Python Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String Formatting
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M8 - String Methods
Python Programming Essentials - M8 - String Methods
P3 InfoTech Solutions Pvt. Ltd.
More Related Content
What's hot
Threads in JAVA
Threads in JAVA
Haldia Institute of Technology
Java Data Types
Java Data Types
Spotle.ai
Oops concept on c#
Oops concept on c#
baabtra.com - No. 1 supplier of quality freshers
C++ Language
C++ Language
Syed Zaid Irshad
Classes objects in java
Classes objects in java
Madishetty Prathibha
Java abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
Program control statements in c#
Program control statements in c#
Dr.Neeraj Kumar Pandey
String handling(string class)
String handling(string class)
Ravi_Kant_Sahu
String, string builder, string buffer
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
Java interface
Java interface
BHUVIJAYAVELU
Object Oriented Programming with Java
Object Oriented Programming with Java
backdoor
Java IO
Java IO
UTSAB NEUPANE
Java access modifiers
Java access modifiers
Srinivas Reddy
Java static keyword
Java static keyword
Lovely Professional University
Oops ppt
Oops ppt
abhayjuneja
Control Statements in Java
Control Statements in Java
Niloy Saha
Java Threads
Java Threads
M Vishnuvardhan Reddy
Java Lambda Expressions.pptx
Java Lambda Expressions.pptx
SameerAhmed593310
Character Array and String
Character Array and String
Tasnima Hamid
Inheritance in java
Inheritance in java
Lovely Professional University
What's hot
(20)
Threads in JAVA
Threads in JAVA
Java Data Types
Java Data Types
Oops concept on c#
Oops concept on c#
C++ Language
C++ Language
Classes objects in java
Classes objects in java
Java abstract class & abstract methods
Java abstract class & abstract methods
Program control statements in c#
Program control statements in c#
String handling(string class)
String handling(string class)
String, string builder, string buffer
String, string builder, string buffer
Java interface
Java interface
Object Oriented Programming with Java
Object Oriented Programming with Java
Java IO
Java IO
Java access modifiers
Java access modifiers
Java static keyword
Java static keyword
Oops ppt
Oops ppt
Control Statements in Java
Control Statements in Java
Java Threads
Java Threads
Java Lambda Expressions.pptx
Java Lambda Expressions.pptx
Character Array and String
Character Array and String
Inheritance in java
Inheritance in java
Viewers also liked
Python Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String Formatting
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M8 - String Methods
Python Programming Essentials - M8 - String Methods
P3 InfoTech Solutions Pvt. Ltd.
Debugging of (C)Python applications
Debugging of (C)Python applications
Roman Podoliaka
The scarlet letter
The scarlet letter
Jayshree Kunchala
Python Programming Essentials - M4 - Editors and IDEs
Python Programming Essentials - M4 - Editors and IDEs
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime module
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M21 - Exception Handling
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M1 - Course Introduction
Python Programming Essentials - M1 - Course Introduction
P3 InfoTech Solutions Pvt. Ltd.
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
Marc Huang
Python Programming Essentials - M40 - Invoking External Programs
Python Programming Essentials - M40 - Invoking External Programs
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdb
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M31 - PEP 8
Python Programming Essentials - M31 - PEP 8
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M44 - Overview of Web Development
Python Programming Essentials - M44 - Overview of Web Development
P3 InfoTech Solutions Pvt. Ltd.
Using Quotes in Newswriting
Using Quotes in Newswriting
CubReporters.org
Viewers also liked
(15)
Python Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String Formatting
Python Programming Essentials - M8 - String Methods
Python Programming Essentials - M8 - String Methods
Debugging of (C)Python applications
Debugging of (C)Python applications
The scarlet letter
The scarlet letter
Python Programming Essentials - M4 - Editors and IDEs
Python Programming Essentials - M4 - Editors and IDEs
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M1 - Course Introduction
Python Programming Essentials - M1 - Course Introduction
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
Python Programming Essentials - M40 - Invoking External Programs
Python Programming Essentials - M40 - Invoking External Programs
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M31 - PEP 8
Python Programming Essentials - M31 - PEP 8
Python Programming Essentials - M44 - Overview of Web Development
Python Programming Essentials - M44 - Overview of Web Development
Using Quotes in Newswriting
Using Quotes in Newswriting
Similar to Python Programming Essentials - M7 - Strings
Python Programming Essentials - M6 - Code Blocks and Indentation
Python Programming Essentials - M6 - Code Blocks and Indentation
P3 InfoTech Solutions Pvt. Ltd.
Introduction to python3.pdf
Introduction to python3.pdf
Mohammed Aman Nawaz
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
ANUSUYA S
lab-assgn-practical-file-xii-cs.pdf
lab-assgn-practical-file-xii-cs.pdf
JeevithaG22
Python fundamentals
Python fundamentals
natnaelmamuye
Introduction to python.pptx
Introduction to python.pptx
pcjoshi02
Basic Concepts in Python
Basic Concepts in Python
Sumit Satam
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
KosmikTech1
OOPS using C++
OOPS using C++
cpjcollege
Python Tutorial
Python Tutorial
AkramWaseem
Python tutorial
Python tutorial
Dominik KAszubowski
Python component in mule
Python component in mule
Ramakrishna kapa
unit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptx
usvirat1805
basics of python programming5.pdf
basics of python programming5.pdf
Pushkaran3
علم البيانات - Data Sience
علم البيانات - Data Sience
App Ttrainers .com
python presentation
python presentation
VaibhavMawal
Python Programming by Dr B P Sharma for Everyone
Python Programming by Dr B P Sharma for Everyone
info560863
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
PVS-Studio
python-ppt.ppt
python-ppt.ppt
MohammadSamiuddin10
python-ppt.ppt
python-ppt.ppt
MohammadSamiuddin10
Similar to Python Programming Essentials - M7 - Strings
(20)
Python Programming Essentials - M6 - Code Blocks and Indentation
Python Programming Essentials - M6 - Code Blocks and Indentation
Introduction to python3.pdf
Introduction to python3.pdf
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
lab-assgn-practical-file-xii-cs.pdf
lab-assgn-practical-file-xii-cs.pdf
Python fundamentals
Python fundamentals
Introduction to python.pptx
Introduction to python.pptx
Basic Concepts in Python
Basic Concepts in Python
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
OOPS using C++
OOPS using C++
Python Tutorial
Python Tutorial
Python tutorial
Python tutorial
Python component in mule
Python component in mule
unit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptx
basics of python programming5.pdf
basics of python programming5.pdf
علم البيانات - Data Sience
علم البيانات - Data Sience
python presentation
python presentation
Python Programming by Dr B P Sharma for Everyone
Python Programming by Dr B P Sharma for Everyone
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
python-ppt.ppt
python-ppt.ppt
python-ppt.ppt
python-ppt.ppt
More from P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M39 - Unit Testing
Python Programming Essentials - M39 - Unit Testing
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & Generators
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M34 - List Comprehensions
Python Programming Essentials - M34 - List Comprehensions
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M29 - Python Interpreter and Files
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M27 - Logging module
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modules
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M24 - math module
Python Programming Essentials - M24 - math module
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M22 - File Operations
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M20 - Classes and Objects
Python Programming Essentials - M20 - Classes and Objects
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M18 - Modules and Packages
Python Programming Essentials - M18 - Modules and Packages
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M17 - Functions
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M15 - References
Python Programming Essentials - M15 - References
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M14 - Dictionaries
Python Programming Essentials - M14 - Dictionaries
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M13 - Tuples
Python Programming Essentials - M13 - Tuples
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M12 - Lists
Python Programming Essentials - M12 - Lists
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M11 - Comparison and Logical Operators
Python Programming Essentials - M11 - Comparison and Logical Operators
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M5 - Variables
Python Programming Essentials - M5 - Variables
P3 InfoTech Solutions Pvt. Ltd.
More from P3 InfoTech Solutions Pvt. Ltd.
(20)
Python Programming Essentials - M39 - Unit Testing
Python Programming Essentials - M39 - Unit Testing
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M34 - List Comprehensions
Python Programming Essentials - M34 - List Comprehensions
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M24 - math module
Python Programming Essentials - M24 - math module
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M20 - Classes and Objects
Python Programming Essentials - M20 - Classes and Objects
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M18 - Modules and Packages
Python Programming Essentials - M18 - Modules and Packages
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M15 - References
Python Programming Essentials - M15 - References
Python Programming Essentials - M14 - Dictionaries
Python Programming Essentials - M14 - Dictionaries
Python Programming Essentials - M13 - Tuples
Python Programming Essentials - M13 - Tuples
Python Programming Essentials - M12 - Lists
Python Programming Essentials - M12 - Lists
Python Programming Essentials - M11 - Comparison and Logical Operators
Python Programming Essentials - M11 - Comparison and Logical Operators
Python Programming Essentials - M5 - Variables
Python Programming Essentials - M5 - Variables
Recently uploaded
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
Deakin University
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Delhi Call girls
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
null - The Open Security Community
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
Slack Application Development 101 Slides
Slack Application Development 101 Slides
praypatel2
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
Neo4j
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
naman860154
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
naman860154
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Alan Dix
The transition to renewables in India.pdf
The transition to renewables in India.pdf
Competition Advisory Services (India) LLP
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
AndikSusilo4
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Safe Software
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
shyamraj55
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Michael W. Hawkins
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
null - The Open Security Community
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
Mark Billinghurst
Recently uploaded
(20)
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Slack Application Development 101 Slides
Slack Application Development 101 Slides
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
The transition to renewables in India.pdf
The transition to renewables in India.pdf
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
Python Programming Essentials - M7 - Strings
1.
http://www.skillbrew.com /SkillbrewTalent brewed by
the industry itself Strings Pavan Verma Python Programming Essentials @YinYangPavan
2.
© SkillBrew http://skillbrew.com What
is a String A string is a sequence of characters message = "Welcome to Python" 2
3.
© SkillBrew http://skillbrew.com Access
a character in string 3 message = 'Welcome to Python' print message[0] print message[1] print message[2] print message[3] print message[4] Output: W e l c o str[index]
4.
© SkillBrew http://skillbrew.com Negative
Indexes 4 message = 'Welcome to Python' print message[-1] print message[-2] print message[-3] print message[-4] Output: n o h t str[-index]
5.
© SkillBrew http://skillbrew.com Length
of a string 5 message = 'Welcome to Python' print len(message) Output: 17 len(string)
6.
© SkillBrew http://skillbrew.com Single
quotes Vs Double quotes You can use either single quotes or double quotes for string literals – they are the same 6 >>> text = 'some text' >>> text = "some text"
7.
© SkillBrew http://skillbrew.com Single
quotes Vs Double quotes (2) Need to escape double quotes in double quoted strings • Use single quotes for strings that contain double quotes >>> s = "He said "Hello"" >>> s 'He said "Hello"' Need to escape single quotes in single quoted strings • Use double quotes for strings that contain single quotes >>> s = 'You've got an error!' >>> s "You've got an error!" 7
8.
© SkillBrew http://skillbrew.com Triple
quoted strings Python also has triple quoted strings available In some cases, when you need to include really long string using triple quoted strings is useful >>> message = """ This is a multi line message use triple quotes if the text is too long """ 8
9.
© SkillBrew http://skillbrew.com Triple
quoted strings (2) You can also uses triple single quotes, there is no difference between single triple quoted strings and double triple quoted strings >>> message = ''' This is a multi line message use triple quotes if the text is too long ''' 9 Triple quoted strings are also used as Docstrings which will be covered in functions
10.
© SkillBrew http://skillbrew.com Note
for C/C++ Programmers There is no separate char data type in Python In Python, a character is just a string of length 1 eg: text ='f' 10
11.
© SkillBrew http://skillbrew.com Note
for Perl/PHP Programmers Remember that single-quoted strings and double- quoted strings are the same – they do not differ in any significant way 11
12.
© SkillBrew http://skillbrew.com String
Concatenation 12 >>> 'foo' + 'bar' 'foobar' >>> 'foo' + 'bar' + '123' 'foobar123' >>> name = 'Monty' >>> last_name = 'Python' >>> name + last_name 'MontyPython' + operator is used to concatenate strings
13.
© SkillBrew http://skillbrew.com String
Concatenation (2) 13 >>> 'foo' + 'bar' + 123 TypeError: cannot concatenate 'str' and 'int' objects string concatenation does not works with other types
14.
© SkillBrew http://skillbrew.com String
Concatenation (2) 14 >>> 'foo' + 'bar' + str(123) 'foobar123' Use built in str() function to convert to a string
15.
© SkillBrew http://skillbrew.com Strings
are immutable 15 >>> message = 'Python is awesome' >>> message[0] = 'j' TypeError: 'str' object does not support item assignment >>> message = 'Python is awesome' >>> del message[0] TypeError: 'str' object does not support item deletion. Python strings cannot be changed
16.
© SkillBrew http://skillbrew.com Strings
are immutable (2) 16 Strings are immutable but that does not mean the variable cannot change, variable can point to anything >>> message = 'Python is awesome' >>> message 'Python is awesome' >>> message = 'Python is dynamicaly typed' >>> message 'Python is dynamicaly typed'
17.
© SkillBrew http://skillbrew.com What
is Slicing 17 slicing in Python is powerful way of extracting sub-parts of a string, lists, tuples Use Case: You can use slicing to extract sub-string out of a string
18.
© SkillBrew http://skillbrew.com Slicing 18 message
= 'Python is awesome' print message[0:5] print message[7:10] print message[10:17] print message[:] print message[5:] print message[:6] Outputs: Pytho is awesome Python is awesome n is awesome Python str[start:end] start: substring starts from this element end: end of substring excluding the element at this index
19.
© SkillBrew http://skillbrew.com Slicing
(2) 19 str[start:end] 1. Slicing always returns a new string. Remember strings are immutable 2. If you don’t provide start the substring starts from the beginning of the string. eg: message[:5] 3. If end is not provided the substring runs till the end of the string 4. If both start and end are missing the entire string is returned
20.
© SkillBrew http://skillbrew.com in
operator in is a Boolean operator which takes two strings and returns True if the first string is a sub-string of the second string, False otherwise 't' in 'Welcome to Python' True 'Python' in 'Welcome to Python' True 'Python' in 'Welcome to Python' True 20
21.
Summary What is
a string Access characters in a string Negative indexes Length of string Single quotes Vs Double quotes Triple quoted strings String concatenation Strings are Immutable in operator 21
22.
© SkillBrew http://skillbrew.com Resources
Tutorial on python strings http://www.tutorialspoint.com/Python/Python_strings.htm Single vs double strings http://docs.ckan.org/en/latest/Python-coding-standards.html 22
23.
23
Editor's Notes
Since Strings are immutable therefore operations like updating and deleting a string do not work