Strings.pdf - Strings A string is a sequence of characters...

This preview shows page 1 - 3 out of 8 pages.

Strings A string is a sequence of characters. Computers do not deal with characters, they deal with numbers (binary). Ev en though you may see characters on your screen, internally it is stored a nd manipulated as a combination of 0's and 1's. This conversion of character to a number is called encoding, and the rever se process is decoding. ASCII and Unicode are some of the popular encoding used. In Python, string is a sequence of Unicode character. For more details about unicode () How to create a string? Strings can be created by enclosing characters inside a single quote or double quotes. Even triple quotes can be used in Python but generally used to represent multiline strings and docstrings. In [0]: Hello Hello Hello myString = 'Hello' print (myString) myString = "Hello" print (myString) myString = '''Hello''' print (myString)
How to access characters in a string? We can access individual characters using indexing and a range of characters using slicing.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture