<filename>Jan2019/12Jan2019/StringsDemo.py
class StringDataTypeDemo:
    Instances = 0

    def __init__(self):
        StringDataTypeDemo.Instances += 1

    def displayDetails(self, title, value):
        print(f"----- {title} -----")
        print(f'StringDataTypeDemo.Instances: {self.Instances}')
        print(f"Value: {value}")


title = "String Demo"
stringDemo = StringDataTypeDemo()

name = '<NAME>'
stringDemo.displayDetails(title, name)

name = "<NAME> with Double Quotes"
stringDemo.displayDetails(title, name)

multilineString = """
                This is first line. \n
                This is second line.
"""
stringDemo.displayDetails("Multiline Demo", multilineString)

# concatenate with + operator, and repeated with *
chant = "Hare " + "Krishna "
stringDemo.displayDetails("+ Add Strings", chant)

# Two or more string literals next to each other are automatically concatenated.
chant = "Hare " "Krishna "
stringDemo.displayDetails("+ Add Strings", chant)

chant = "<NAME> " * 3
stringDemo.displayDetails("Multiply Strings", chant)

# to break long strings
longText = ('Put several strings within parentheses '
            'to have them joined together.')
stringDemo.displayDetails("Long Strings", longText)

# in operator for string search
searchString = "Hare"
print(f'Is "{searchString}" present in "{chant}" {searchString in chant}')

<filename>Jan2019/12Jan2019/StringsDemo.py
class StringDataTypeDemo:
    Instances = 0

    def __init__(self):
        StringDataTypeDemo.Instances += 1

    def displayDetails(self, title, value):
        print(f"----- {title} -----")
        print(f'StringDataTypeDemo.Instances: {self.Instances}')
        print(f"Value: {value}")


title = "String Demo"
stringDemo = StringDataTypeDemo()

name = '<NAME>'
stringDemo.displayDetails(title, name)

name = "<NAME> with Double Quotes"
stringDemo.displayDetails(title, name)

multilineString = """
                This is first line. \n
                This is second line.
"""
stringDemo.displayDetails("Multiline Demo", multilineString)

# concatenate with + operator, and repeated with *
chant = "Hare " + "Krishna "
stringDemo.displayDetails("+ Add Strings", chant)

# Two or more string literals next to each other are automatically concatenated.
chant = "Hare " "Krishna "
stringDemo.displayDetails("+ Add Strings", chant)

chant = "<NAME> " * 3
stringDemo.displayDetails("Multiply Strings", chant)

# to break long strings
longText = ('Put several strings within parentheses '
            'to have them joined together.')
stringDemo.displayDetails("Long Strings", longText)

# in operator for string search
searchString = "Hare"
print(f'Is "{searchString}" present in "{chant}" {searchString in chant}')

This is first line. \n                 This is second line. # concatenate with + operator, and repeated with * # Two or more string literals next to each other are automatically concatenated. # to break long strings # in operator for string search