SlideShare a Scribd company logo
Python String Functions
By - Aamir Abdullah Khan
Jason J Samuel
Sushanth
Manish
Objective of the Seminar:
 Python String Basics.
 Common String Methods
 String Concatenation
 Formatting Strings
 Escape Characters
 Slicing
 Conclusion
String and String Basics
 Python strings are sequences of characters used to represent and manipulate
text or data in Python. They are one of the fundamental data types in the
Python programming language. Strings are created by enclosing text within
single (''), double ("") or triple (''' or """) quotes. For example:
 Important characteristics and uses of Python strings:
1. Text Handling: Python strings are primarily used for text processing and
manipulation. They can represent anything from a single character to entire
documents.
2. Immutable: Strings are immutable, meaning once they are created, their
contents cannot be changed. Operations on strings create new strings rather
than modifying the original.
3. Sequence: Strings are sequences of characters, which means you can access
individual characters using indexing and perform various sequence operations
(e.g., slicing, concatenation).
4. Data Representation: Strings can be used to represent and work with data
other than text, such as binary data, serialized data (e.g., JSON, XML), and
more.
5. String Methods: Python provides a rich set of built-in string methods that
allow you to perform common string operations, such as converting to
uppercase or lowercase, splitting, joining, finding substrings, and replacing.
Common String Methods:
 len( ): Returns the length (number of characters) of a string.
Output: 13
 str.lower( ) , str.upper( ): Convert the string to lowercase or uppercase.
Output:
 str.strip( ) , str.lstrip( ) , str.rstrip( ): Remove leading and trailing whitespace.
Output:
 str.split( ): Split a string into a list of substrings based on a separator.
Output:
 str.join( ): Join a list of strings into a single string using a separator.
Output:
 str.replace( ): Replace a substring with another substring.
Output:
 str.find( ) , str.index( ): Find the index of a substring.
Output:
String Concatenation:
 In Python, you can concatenate strings using the ‘ +
‘operator, which allows you to join two or more strings
together. Here's how string concatenation works:
Output:
Another example: Output:
Formatting Strings:
 String formatting in Python allows you to create well-structured, dynamic strings
by incorporating variables and values within text. There are various methods for
string formatting in Python, including f-strings, %-formatting, and the
str.format() method. Here are examples of each:
 F-strings (Formatted String Literals):
 F-strings provide a concise and readable way to format strings by embedding
expressions within curly braces { }.
 Output:
 %-formatting: The ‘%’ operator allows you to format
strings by specifying placeholders using ‘%’ and then
providing values in a tuple.
 Example:
 Output: Here, ‘%s’ is a placeholder for a string, and ‘%d’ is a placeholder
for an integer.
 str.format( ) method: The ‘str.format( )’ method allows you
to format strings by specifying placeholders using curly
braces ‘{ }’ and then providing values within the ‘format( )’
method.
 Example:
 Output:
 These are three common methods for string formatting in Python. F-
strings are recommended in Python 3.6 and later due to their simplicity
and readability.
Escape Characters:
 Escape characters in Python are special characters that are used to
represent non-printable and special characters within strings. They
are preceded by a backslash ‘’. Here are some common escape
characters and their usage in Python strings:
 Newline Character (‘n’): Represents a line break or a new line.
Output:
 Tab Character (‘t’): Represents a tab or an indentation.
Output:
 Backslash Character (‘’): Represents a literal backslash.
Output:
 Single Quote (‘`’) and Double Quote (‘``’) Characters: To include a single
or double quote within a string.
Output:
 Unicode Escape (‘u’ and ‘U’): Represents Unicode characters using their
code points.
Output:
Slicing:
 String slicing in Python is a technique used to extract a portion
(substring) of a string. You can slice a string using square brackets
with a specified range of indices. Here are some examples of string
slicing:
 Basic String Slicing:
 Negative Index Slicing: Negative indices can be used to count characters
from the end of the string.
 Slicing with Stride (Step):You can include a third parameter to specify the
step (stride) between characters in the slice.
 Slicing with Length: You can use the length of the string to make your slices.
 String slicing is a powerful tool for working with text data in Python.
It allows you to extract specific portions of strings for various text
processing tasks.
Conclusion:
 In conclusion we learnt about basics of string functions in
python and learnt various methods and techniques that
can be used with strings in python. We've learned to
harness the power of built-in string methods, enabling
tasks such as splitting, and replacing text etc. with
precision. And we have learnt about String formatting,
including the elegant f-strings in modern Python, allows us
to create dynamic and structured text effortlessly.
Input and Output Functions
Objective:
 Importance of Input and Output Functions
 Python Output Functions
 Python Input Functions
 Conclusion
Importance I/O Functions
1. User Interaction: I/O operations allow a program to interact with users. They
enable input from users via keyboards, mice, touchscreens, or other devices,
and they provide output to users through screens, speakers, or other output
devices. This interaction is essential for creating user-friendly applications,
from command-line tools to graphical user interfaces.
2. Data Handling: Programs often need to read, process, and manipulate data.
I/O operations enable programs to access data from external sources like
files, databases, or network connections, and to display results or store data
for later use. Effective data handling is a core function of software
development.
3. Automation: I/O operations are vital for automation. They allow programs to
perform repetitive tasks, read and write data in bulk, and make decisions
based on input. Automation can lead to increased efficiency, reduced human
error, and the ability to perform tasks at scales that would be impractical
manually.
Python Output Functions
 In Python, we can simply use the print( ) function to print output. For example,
 Here, the print( ) function displays the string enclosed inside the single
quotation.
 Syntax of print( )
 In the above code, the print( ) function is taking a single parameter. However,
the actual syntax of the print function accepts 5 parameters
Here,
object - value(s) to be printed
sep (optional) - allows us to separate multiple objects inside print( )
end (optional) - allows us to add add specific values like new line “n”
file (optional) - where the values are printed. It's default value is sys.stdout
flush (optional) - Boolean specifying if the output is flushed or buffered. Default:
FALSE
 Example 1:
 Output:
 Example 2: Python print() with end Parameter:
 Output:
 Example 3: Python print() with sep parameter:
 Output:
 Example: Print Python Variables and Literals:
 Output:
Python Input Functions
 While programming, we might want to take the input from the user. In
Python, we can use the input( ) function.
Syntax of input()
 Example: Python User Input:
 Output:
Conclusion:
 In conclusion, this seminar has equipped us with the
essential knowledge and skills for effectively working
with input and output functions in Python. We've
learned how to gather user input using the ‘ input( ) ’
function and provide clear, informative output with the ‘
print( ) ’ function. These fundamental skills are the
backbone of Python programming, enabling us to build
user-friendly applications, automate tasks, and process
data efficiently.
Ad

Recommended

ppt notes python language operators and data
ppt notes python language operators and data
SukhpreetSingh519414
 
Python data handling
Python data handling
Prof. Dr. K. Adisesha
 
Python Programming-UNIT-II - Strings.pptx
Python Programming-UNIT-II - Strings.pptx
KavithaDonepudi
 
STRINGS IN PYTHON
STRINGS IN PYTHON
TanushTM1
 
strings in python (presentation for DSA)
strings in python (presentation for DSA)
MirzaAbdullahTariq
 
UNIT 4 python.pptx
UNIT 4 python.pptx
TKSanthoshRao
 
Strings3a4esrxdfgcbhjjjjjiiol;lkljiojoii
Strings3a4esrxdfgcbhjjjjjiiol;lkljiojoii
pawankamal3
 
trisha comp ppt.pptx
trisha comp ppt.pptx
Tapaswini14
 
Python-02| Input, Output & Import
Python-02| Input, Output & Import
Mohd Sajjad
 
Unit2 input output
Unit2 input output
deepak kumbhar
 
Python intro
Python intro
Abhinav Upadhyay
 
Python Strings and strings types with Examples
Python Strings and strings types with Examples
Prof. Kartiki Deshmukh
 
Python strings presentation
Python strings presentation
VedaGayathri1
 
Unit_I-Introduction python programming (1).pptx
Unit_I-Introduction python programming (1).pptx
arunbalaji707
 
Python workshop
Python workshop
Jibin Sabu
 
PPS_Unit 4.ppt
PPS_Unit 4.ppt
KundanBhatkar
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov
 
Python- strings
Python- strings
Krishna Nanda
 
Python Strings and its Featues Explained in Detail .pptx
Python Strings and its Featues Explained in Detail .pptx
parmg0960
 
Python basics
Python basics
Hoang Nguyen
 
Python basics
Python basics
Luis Goldster
 
Python basics
Python basics
Tony Nguyen
 
Python basics
Python basics
Fraboni Ec
 
Python basics
Python basics
Harry Potter
 
Python basics
Python basics
Young Alista
 
Python basics
Python basics
James Wong
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3
Syed Farjad Zia Zaidi
 
Introduction on basic python and it's application
Introduction on basic python and it's application
sriram2110
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 

More Related Content

Similar to PROGRAMMING FOR PROBLEM SOLVING FOR STRING CONCEPT (20)

Python-02| Input, Output & Import
Python-02| Input, Output & Import
Mohd Sajjad
 
Unit2 input output
Unit2 input output
deepak kumbhar
 
Python intro
Python intro
Abhinav Upadhyay
 
Python Strings and strings types with Examples
Python Strings and strings types with Examples
Prof. Kartiki Deshmukh
 
Python strings presentation
Python strings presentation
VedaGayathri1
 
Unit_I-Introduction python programming (1).pptx
Unit_I-Introduction python programming (1).pptx
arunbalaji707
 
Python workshop
Python workshop
Jibin Sabu
 
PPS_Unit 4.ppt
PPS_Unit 4.ppt
KundanBhatkar
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov
 
Python- strings
Python- strings
Krishna Nanda
 
Python Strings and its Featues Explained in Detail .pptx
Python Strings and its Featues Explained in Detail .pptx
parmg0960
 
Python basics
Python basics
Hoang Nguyen
 
Python basics
Python basics
Luis Goldster
 
Python basics
Python basics
Tony Nguyen
 
Python basics
Python basics
Fraboni Ec
 
Python basics
Python basics
Harry Potter
 
Python basics
Python basics
Young Alista
 
Python basics
Python basics
James Wong
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3
Syed Farjad Zia Zaidi
 
Introduction on basic python and it's application
Introduction on basic python and it's application
sriram2110
 
Python-02| Input, Output & Import
Python-02| Input, Output & Import
Mohd Sajjad
 
Python Strings and strings types with Examples
Python Strings and strings types with Examples
Prof. Kartiki Deshmukh
 
Python strings presentation
Python strings presentation
VedaGayathri1
 
Unit_I-Introduction python programming (1).pptx
Unit_I-Introduction python programming (1).pptx
arunbalaji707
 
Python workshop
Python workshop
Jibin Sabu
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov
 
Python Strings and its Featues Explained in Detail .pptx
Python Strings and its Featues Explained in Detail .pptx
parmg0960
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3
Syed Farjad Zia Zaidi
 
Introduction on basic python and it's application
Introduction on basic python and it's application
sriram2110
 

Recently uploaded (20)

Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Ad

PROGRAMMING FOR PROBLEM SOLVING FOR STRING CONCEPT

  • 1. Python String Functions By - Aamir Abdullah Khan Jason J Samuel Sushanth Manish
  • 2. Objective of the Seminar:  Python String Basics.  Common String Methods  String Concatenation  Formatting Strings  Escape Characters  Slicing  Conclusion
  • 3. String and String Basics  Python strings are sequences of characters used to represent and manipulate text or data in Python. They are one of the fundamental data types in the Python programming language. Strings are created by enclosing text within single (''), double ("") or triple (''' or """) quotes. For example:
  • 4.  Important characteristics and uses of Python strings: 1. Text Handling: Python strings are primarily used for text processing and manipulation. They can represent anything from a single character to entire documents. 2. Immutable: Strings are immutable, meaning once they are created, their contents cannot be changed. Operations on strings create new strings rather than modifying the original. 3. Sequence: Strings are sequences of characters, which means you can access individual characters using indexing and perform various sequence operations (e.g., slicing, concatenation). 4. Data Representation: Strings can be used to represent and work with data other than text, such as binary data, serialized data (e.g., JSON, XML), and more. 5. String Methods: Python provides a rich set of built-in string methods that allow you to perform common string operations, such as converting to uppercase or lowercase, splitting, joining, finding substrings, and replacing.
  • 5. Common String Methods:  len( ): Returns the length (number of characters) of a string. Output: 13  str.lower( ) , str.upper( ): Convert the string to lowercase or uppercase. Output:
  • 6.  str.strip( ) , str.lstrip( ) , str.rstrip( ): Remove leading and trailing whitespace. Output:  str.split( ): Split a string into a list of substrings based on a separator. Output:
  • 7.  str.join( ): Join a list of strings into a single string using a separator. Output:  str.replace( ): Replace a substring with another substring. Output:  str.find( ) , str.index( ): Find the index of a substring. Output:
  • 8. String Concatenation:  In Python, you can concatenate strings using the ‘ + ‘operator, which allows you to join two or more strings together. Here's how string concatenation works: Output: Another example: Output:
  • 9. Formatting Strings:  String formatting in Python allows you to create well-structured, dynamic strings by incorporating variables and values within text. There are various methods for string formatting in Python, including f-strings, %-formatting, and the str.format() method. Here are examples of each:  F-strings (Formatted String Literals):  F-strings provide a concise and readable way to format strings by embedding expressions within curly braces { }.  Output:
  • 10.  %-formatting: The ‘%’ operator allows you to format strings by specifying placeholders using ‘%’ and then providing values in a tuple.  Example:  Output: Here, ‘%s’ is a placeholder for a string, and ‘%d’ is a placeholder for an integer.
  • 11.  str.format( ) method: The ‘str.format( )’ method allows you to format strings by specifying placeholders using curly braces ‘{ }’ and then providing values within the ‘format( )’ method.  Example:  Output:  These are three common methods for string formatting in Python. F- strings are recommended in Python 3.6 and later due to their simplicity and readability.
  • 12. Escape Characters:  Escape characters in Python are special characters that are used to represent non-printable and special characters within strings. They are preceded by a backslash ‘’. Here are some common escape characters and their usage in Python strings:  Newline Character (‘n’): Represents a line break or a new line. Output:  Tab Character (‘t’): Represents a tab or an indentation. Output:
  • 13.  Backslash Character (‘’): Represents a literal backslash. Output:  Single Quote (‘`’) and Double Quote (‘``’) Characters: To include a single or double quote within a string. Output:  Unicode Escape (‘u’ and ‘U’): Represents Unicode characters using their code points. Output:
  • 14. Slicing:  String slicing in Python is a technique used to extract a portion (substring) of a string. You can slice a string using square brackets with a specified range of indices. Here are some examples of string slicing:  Basic String Slicing:
  • 15.  Negative Index Slicing: Negative indices can be used to count characters from the end of the string.  Slicing with Stride (Step):You can include a third parameter to specify the step (stride) between characters in the slice.
  • 16.  Slicing with Length: You can use the length of the string to make your slices.  String slicing is a powerful tool for working with text data in Python. It allows you to extract specific portions of strings for various text processing tasks.
  • 17. Conclusion:  In conclusion we learnt about basics of string functions in python and learnt various methods and techniques that can be used with strings in python. We've learned to harness the power of built-in string methods, enabling tasks such as splitting, and replacing text etc. with precision. And we have learnt about String formatting, including the elegant f-strings in modern Python, allows us to create dynamic and structured text effortlessly.
  • 18. Input and Output Functions
  • 19. Objective:  Importance of Input and Output Functions  Python Output Functions  Python Input Functions  Conclusion
  • 20. Importance I/O Functions 1. User Interaction: I/O operations allow a program to interact with users. They enable input from users via keyboards, mice, touchscreens, or other devices, and they provide output to users through screens, speakers, or other output devices. This interaction is essential for creating user-friendly applications, from command-line tools to graphical user interfaces. 2. Data Handling: Programs often need to read, process, and manipulate data. I/O operations enable programs to access data from external sources like files, databases, or network connections, and to display results or store data for later use. Effective data handling is a core function of software development. 3. Automation: I/O operations are vital for automation. They allow programs to perform repetitive tasks, read and write data in bulk, and make decisions based on input. Automation can lead to increased efficiency, reduced human error, and the ability to perform tasks at scales that would be impractical manually.
  • 21. Python Output Functions  In Python, we can simply use the print( ) function to print output. For example,  Here, the print( ) function displays the string enclosed inside the single quotation.  Syntax of print( )  In the above code, the print( ) function is taking a single parameter. However, the actual syntax of the print function accepts 5 parameters Here, object - value(s) to be printed sep (optional) - allows us to separate multiple objects inside print( ) end (optional) - allows us to add add specific values like new line “n”
  • 22. file (optional) - where the values are printed. It's default value is sys.stdout flush (optional) - Boolean specifying if the output is flushed or buffered. Default: FALSE  Example 1:  Output:  Example 2: Python print() with end Parameter:  Output:
  • 23.  Example 3: Python print() with sep parameter:  Output:  Example: Print Python Variables and Literals:  Output:
  • 24. Python Input Functions  While programming, we might want to take the input from the user. In Python, we can use the input( ) function. Syntax of input()  Example: Python User Input:  Output:
  • 25. Conclusion:  In conclusion, this seminar has equipped us with the essential knowledge and skills for effectively working with input and output functions in Python. We've learned how to gather user input using the ‘ input( ) ’ function and provide clear, informative output with the ‘ print( ) ’ function. These fundamental skills are the backbone of Python programming, enabling us to build user-friendly applications, automate tasks, and process data efficiently.