str = "Hello"
str1 = " world"
print(str*3) # prints HelloHelloHello
print(str+str1)# prints Hello world
print(str[4]) # prints o
print(str[2:4]); # prints ll
print('w' in str) # prints false as w is not present in str
print('wo' not in str1) # prints false as wo is present in str1.
print(r'C://python37') # prints C://python37 as it is written
print("The string str : %s"%(str)) # prints The string str : Hello
Output
HelloHelloHello
Hello world
o
ll
False
False
C://python37
The string str : Hello
================================================
Program
s1="hari taraka"
s2="prabhu manyam"
s2="prabhu manyam"
print("s1 value is:", s1)
print(" ")
print("s2 value is:", s2)
print(" ")
print("s1+s2 is:", s1+s2)
print(" ")
print("s1*3 is:", s1*3)
print(" ")
print("len(s1) is:", len(s1))
print(" ")
print("len(s1)*3 is:", len(s1)*3)
print(" ")
print("min(s1) is:", min(s1))
print(" ")
print("max(s1) is:", max(s1))
print(" ")
Output:
s1 value is: hari taraka
s2 value is: prabhu manyam
s1+s2 is: hari tarakaprabhu manyam
s1*3 is: hari tarakahari tarakahari taraka
len(s1) is: 11
len(s1)*3 is: 33
min(s1) is:
max(s1) is: t