☞We will perform the following operators on the string.
1. Concatenation(+) Operator 2. Replication(*) Operator 3. Membership (in,not in) Operator 4. Comparison(<, >, <=, >=, ==, !=) Operator
☞Concatenation(+) Operator :
S1 = "inspire" + "web" + "soft"
print(S1)
inspirewebsoft
S1 = "inspire" + 3
print(S1)
S1 = "inspire" + 3
TypeError: can only concatenate str (not "int") to str
☞Replication(*) Operator :
S1 = "inspire" * 3
print(S1)
inspireinspireinspire
S1 = "inspire" * 3.5
print(S1)
S1 = "inspire" * 3.5
TypeError: can't multiply sequence by non-int of type 'float'
☞Membership (in,not in) Operator :
S1 = "ins" in "inspireWEBsoft.com"
print(S1)
S2 = "web" in "inspireWEBsoft.com"
print(S2)
True
False
☞Comparison(<, >, <=, >=, ==, !=) Operator :
S1 = 'abc' > "Abc"
print(S1)
S2 = 'abc' < "Abc"
print(S2)
S3 = 'abc' >= "Abc"
print(S1)
S4 = 'abc' <= "Abc"
print(S2)
S5 = 'abc' < "aBc"
print(S3)
S6 = 'abc' <= "aBc"
print(S6)
True
False
True
False
True
False