SlideShare a Scribd company logo
1 of 13
Download to read offline
Strings in Python
Vikram Neerugatti
Sri Venkateswara College of Engineering
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
1
Content
• A String sequence
• Len
• Traversal with a for loop
• String slices
• Strings are immutable
• Searching
• Looping and counting
• String methods
• In operator
• String comparisons
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
2
A Sequence types
• There are six sequence types:
• strings, “nani” or ‘c’
• Unicode strings,
• lists,
• tuples,
• buffers,
• and xrange objects.
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
3
Len
• It is a function to know the length
• It can be applied to any datatype or data structure
• For example:
• a="n"
• b="nani"
• print(a)
• print(b)
• d=len(a)
• g=len(b)
• x=[3,4,5]
• c=len(x)
• print(d,g,c)
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
4
Traversal with a for loop
Example:
b="nani is learnng python"
for v in b:
print(v)
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
5
String slices
• With the slicing we can create the substring
• Example:
• c="nani is good“
• print(c)
• d=c[5:7]
• print(d)
• e=c[8:12]
• print(e)
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
6
Strings are immutable
• Cant modify the strings once declared
• c="nani is good"
• print(c)
• d=c[6]
• print(d)
• #c[4]="7“
• but for lists, its possible(mutable)
• v=[5,6,7]
• print(v)
• v[2]=4
• print(v)
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
7
Searching
• To search a substring in a string is possible with find() method
• It returns the starting position of a substring in a sting and returnes -1 if not found.
• Example:
• c="nani is good"
• print(c)
• a=c.find("is")
• print(a)
• b=c.find("sonali")
• print(b)
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
8
Looping and counting
• Example:
• c="nani is good"
• total=0
• for i in c:
• total= total + 1
• print(total)
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology,
Chittoor 9
String methods
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
10
String methods
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering
andTechnology, Chittoor
11
In operator
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology,
Chittoor 12
Summary
• A String sequence
• Len
• Traversal with a for loop
• String slices
• Strings are immutable
• Searching
• Looping and counting
• String methods
• In operator
• String comparisons
01-04-2020
Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology,
Chittoor 14

More Related Content

Similar to Strings in Python

Introduction to Exploratory Data Analysis with the sci-analysis Python Package
Introduction to Exploratory Data Analysis with the sci-analysis Python PackageIntroduction to Exploratory Data Analysis with the sci-analysis Python Package
Introduction to Exploratory Data Analysis with the sci-analysis Python PackageChrisMorrow28
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms masterHossam Hassan
 
358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7sumitbardhan
 
DSA_Module 1-PPT for engineering students
DSA_Module 1-PPT for engineering studentsDSA_Module 1-PPT for engineering students
DSA_Module 1-PPT for engineering studentsriotsush12
 
Data Structure_Array_and_sparse matrix.pptx
Data Structure_Array_and_sparse matrix.pptxData Structure_Array_and_sparse matrix.pptx
Data Structure_Array_and_sparse matrix.pptxpubgnewstate1620
 
CS341 Algorithms Analysis and Design-Sec7.pptx
CS341 Algorithms Analysis and Design-Sec7.pptxCS341 Algorithms Analysis and Design-Sec7.pptx
CS341 Algorithms Analysis and Design-Sec7.pptxhussein zayed
 
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...Runwei Qiang
 
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...Runwei Qiang
 
DSA-Day-2-PS.pptx
DSA-Day-2-PS.pptxDSA-Day-2-PS.pptx
DSA-Day-2-PS.pptxamanbhogal7
 
Notes_456_PolygonClipping2_10 (1).pdf
Notes_456_PolygonClipping2_10 (1).pdfNotes_456_PolygonClipping2_10 (1).pdf
Notes_456_PolygonClipping2_10 (1).pdfPranavRawat14
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)teach4uin
 
Network Construction and Visualization.pdf
Network Construction and Visualization.pdfNetwork Construction and Visualization.pdf
Network Construction and Visualization.pdfFrancisco Restivo
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxsabithabanu83
 
UnSupervised Learning Clustering
UnSupervised Learning ClusteringUnSupervised Learning Clustering
UnSupervised Learning ClusteringFEG
 

Similar to Strings in Python (20)

Introduction to Exploratory Data Analysis with the sci-analysis Python Package
Introduction to Exploratory Data Analysis with the sci-analysis Python PackageIntroduction to Exploratory Data Analysis with the sci-analysis Python Package
Introduction to Exploratory Data Analysis with the sci-analysis Python Package
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms master
 
358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7358 33 powerpoint-slides_7-structures_chapter-7
358 33 powerpoint-slides_7-structures_chapter-7
 
L1_intro.pptx
L1_intro.pptxL1_intro.pptx
L1_intro.pptx
 
Clustering: A Scikit Learn Tutorial
Clustering: A Scikit Learn TutorialClustering: A Scikit Learn Tutorial
Clustering: A Scikit Learn Tutorial
 
DSA_Module 1-PPT for engineering students
DSA_Module 1-PPT for engineering studentsDSA_Module 1-PPT for engineering students
DSA_Module 1-PPT for engineering students
 
Data Structure_Array_and_sparse matrix.pptx
Data Structure_Array_and_sparse matrix.pptxData Structure_Array_and_sparse matrix.pptx
Data Structure_Array_and_sparse matrix.pptx
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
 
CS341 Algorithms Analysis and Design-Sec7.pptx
CS341 Algorithms Analysis and Design-Sec7.pptxCS341 Algorithms Analysis and Design-Sec7.pptx
CS341 Algorithms Analysis and Design-Sec7.pptx
 
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
 
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
Feature Extraction for Effective Microblog Search and Adaptive Clustering Alg...
 
DSA-Day-2-PS.pptx
DSA-Day-2-PS.pptxDSA-Day-2-PS.pptx
DSA-Day-2-PS.pptx
 
Notes_456_PolygonClipping2_10 (1).pdf
Notes_456_PolygonClipping2_10 (1).pdfNotes_456_PolygonClipping2_10 (1).pdf
Notes_456_PolygonClipping2_10 (1).pdf
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
 
Network Construction and Visualization.pdf
Network Construction and Visualization.pdfNetwork Construction and Visualization.pdf
Network Construction and Visualization.pdf
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptx
 
UnSupervised Learning Clustering
UnSupervised Learning ClusteringUnSupervised Learning Clustering
UnSupervised Learning Clustering
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 

More from Vikram Nandini

IoT: From Copper strip to Gold Bar
IoT: From Copper strip to Gold BarIoT: From Copper strip to Gold Bar
IoT: From Copper strip to Gold BarVikram Nandini
 
Linux File Trees and Commands
Linux File Trees and CommandsLinux File Trees and Commands
Linux File Trees and CommandsVikram Nandini
 
Introduction to Linux & Basic Commands
Introduction to Linux & Basic CommandsIntroduction to Linux & Basic Commands
Introduction to Linux & Basic CommandsVikram Nandini
 
Manufacturing - II Part
Manufacturing - II PartManufacturing - II Part
Manufacturing - II PartVikram Nandini
 
Prototyping Online Components
Prototyping Online ComponentsPrototyping Online Components
Prototyping Online ComponentsVikram Nandini
 
Artificial Neural Networks
Artificial Neural NetworksArtificial Neural Networks
Artificial Neural NetworksVikram Nandini
 
Design Principles for Connected Devices
Design Principles for Connected DevicesDesign Principles for Connected Devices
Design Principles for Connected DevicesVikram Nandini
 
Communication in the IoT
Communication in the IoTCommunication in the IoT
Communication in the IoTVikram Nandini
 
Introduction to Cyber Security
Introduction to Cyber SecurityIntroduction to Cyber Security
Introduction to Cyber SecurityVikram Nandini
 
cloud computing UNIT-2.pdf
cloud computing UNIT-2.pdfcloud computing UNIT-2.pdf
cloud computing UNIT-2.pdfVikram Nandini
 
Introduction to Web Technologies
Introduction to Web TechnologiesIntroduction to Web Technologies
Introduction to Web TechnologiesVikram Nandini
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style SheetsVikram Nandini
 

More from Vikram Nandini (20)

IoT: From Copper strip to Gold Bar
IoT: From Copper strip to Gold BarIoT: From Copper strip to Gold Bar
IoT: From Copper strip to Gold Bar
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Linux File Trees and Commands
Linux File Trees and CommandsLinux File Trees and Commands
Linux File Trees and Commands
 
Introduction to Linux & Basic Commands
Introduction to Linux & Basic CommandsIntroduction to Linux & Basic Commands
Introduction to Linux & Basic Commands
 
INTRODUCTION to OOAD
INTRODUCTION to OOADINTRODUCTION to OOAD
INTRODUCTION to OOAD
 
Ethics
EthicsEthics
Ethics
 
Manufacturing - II Part
Manufacturing - II PartManufacturing - II Part
Manufacturing - II Part
 
Manufacturing
ManufacturingManufacturing
Manufacturing
 
Business Models
Business ModelsBusiness Models
Business Models
 
Prototyping Online Components
Prototyping Online ComponentsPrototyping Online Components
Prototyping Online Components
 
Artificial Neural Networks
Artificial Neural NetworksArtificial Neural Networks
Artificial Neural Networks
 
IoT-Prototyping
IoT-PrototypingIoT-Prototyping
IoT-Prototyping
 
Design Principles for Connected Devices
Design Principles for Connected DevicesDesign Principles for Connected Devices
Design Principles for Connected Devices
 
Introduction to IoT
Introduction to IoTIntroduction to IoT
Introduction to IoT
 
Embedded decices
Embedded decicesEmbedded decices
Embedded decices
 
Communication in the IoT
Communication in the IoTCommunication in the IoT
Communication in the IoT
 
Introduction to Cyber Security
Introduction to Cyber SecurityIntroduction to Cyber Security
Introduction to Cyber Security
 
cloud computing UNIT-2.pdf
cloud computing UNIT-2.pdfcloud computing UNIT-2.pdf
cloud computing UNIT-2.pdf
 
Introduction to Web Technologies
Introduction to Web TechnologiesIntroduction to Web Technologies
Introduction to Web Technologies
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 

Recently uploaded

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Strings in Python

  • 1. Strings in Python Vikram Neerugatti Sri Venkateswara College of Engineering 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 1
  • 2. Content • A String sequence • Len • Traversal with a for loop • String slices • Strings are immutable • Searching • Looping and counting • String methods • In operator • String comparisons 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 2
  • 3. A Sequence types • There are six sequence types: • strings, “nani” or ‘c’ • Unicode strings, • lists, • tuples, • buffers, • and xrange objects. 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 3
  • 4. Len • It is a function to know the length • It can be applied to any datatype or data structure • For example: • a="n" • b="nani" • print(a) • print(b) • d=len(a) • g=len(b) • x=[3,4,5] • c=len(x) • print(d,g,c) 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 4
  • 5. Traversal with a for loop Example: b="nani is learnng python" for v in b: print(v) 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 5
  • 6. String slices • With the slicing we can create the substring • Example: • c="nani is good“ • print(c) • d=c[5:7] • print(d) • e=c[8:12] • print(e) 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 6
  • 7. Strings are immutable • Cant modify the strings once declared • c="nani is good" • print(c) • d=c[6] • print(d) • #c[4]="7“ • but for lists, its possible(mutable) • v=[5,6,7] • print(v) • v[2]=4 • print(v) 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 7
  • 8. Searching • To search a substring in a string is possible with find() method • It returns the starting position of a substring in a sting and returnes -1 if not found. • Example: • c="nani is good" • print(c) • a=c.find("is") • print(a) • b=c.find("sonali") • print(b) 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 8
  • 9. Looping and counting • Example: • c="nani is good" • total=0 • for i in c: • total= total + 1 • print(total) 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 9
  • 10. String methods 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 10
  • 11. String methods 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 11
  • 12. In operator 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 12
  • 13. Summary • A String sequence • Len • Traversal with a for loop • String slices • Strings are immutable • Searching • Looping and counting • String methods • In operator • String comparisons 01-04-2020 Vikram Neerugatti, Sri Venkateswara College of Engineering andTechnology, Chittoor 14