Learn Python Programming with Examples — Post#7

Use of String in Python and a few string methods.

Ganapathy Narayanan
Operations Research Bit

--

Errata In Previous Post#6: The screen Shots shown are for Post#6, and not Post#12 as erred on the captions under the screen shots.

In previous posts examples, many ‘input’ and ‘print’ built-in functions have shown the use of string text in-between single or double quoted strings. In fact, Internal working of python are string based in terms of representations of data being characters, text, variable values or numbers. Three main characteristics of strings in python are:

(1) String Data Type: Strings are fundamental data types used to represent sequences of characters (text).

(2) String value Immutability: String values are immutable, meaning once created, their content cannot be directly modified. To change a string, you must create a new string.

(3) String Creation: Strings are created using single (‘) or double (“) quotes. Triple quotes (‘’’ or “””) can span multiple lines.

View below the screen shot#1 with string variables assigned to a character, a text, a number and printed output. The user input with the built-in ‘input’ function are received as string characters by default. If the user variable is a number, then the ‘eval’ built-in function can convert the string represented input number to an integer or a floating number. View examples in the previous post for the use of ‘eval’ function.

--

--