Strings in Python can be created using single quotes, double quotes, or triple quotes. A string is a sequence of characters that can be accessed using indexes. Common string operations include creating and traversing strings, using escape characters to include special characters in a string, and using string methods and built-in functions.
Strings in Python can be created using single quotes, double quotes, or triple quotes. A string is a sequence of characters that can be accessed using indexes. Common string operations include creating and traversing strings, using escape characters to include special characters in a string, and using string methods and built-in functions.
Strings in Python can be created using single quotes, double quotes, or triple quotes. A string is a sequence of characters that can be accessed using indexes. Common string operations include creating and traversing strings, using escape characters to include special characters in a string, and using string methods and built-in functions.
Click to join telegram channel: Computer by Govind rathore
https://t.me/computer_by_govind_rathore
Key Points of this chapter:
• What is Strings • Creating Strings • Traversing a String • Special String Operators • String Methods and Built-in-function What is String: A string is a sequence of characters. We can enclose characters in quotes (single, double or triple.) For example: fruits=’Mango Apple Grapes’ Creating String: str1=’Hello world’, str2=”Python Programming” Escape Characters: By using the escape character \" we are able to use double quotes to enclose a string that includes text quoted between double quotes. Escape character How it formats
\ New line in a multi-line string
\ Backslash
\n Line break Escape character How it formats
\t Tab (horizontal indentation)
Empty String: An empty string is a string without any characters inside.
str=” ” , str=’ ‘ Multiple line String: Multiline strings are represented using triple quotes (‘’’ ‘’’) or even single or double quotes.
Traversing a String: Traversing a string means
accessing all the elements of the string one after the other by using the subscript / index value.