string 1
string 1
L.Pavithra
Assistant Professor
SCOPE
VIT AP
• Syntax: –
Chr(Unicode character)
• Python Code2:
TextExample=“Welcome+chr(9)+CSE1001“
print(TextExample)
• Output:
11/10/2022 CSE1001 - Problem Solving and Programmi 5
ng
String methods
• In Python, a method is a function that is
defined with respect to a particular object.
• The syntax is
<object>.<method>(<parameters>)
Methods:
S.upper()
S.lower()
S.count(substring)
S.replace(old,new)
S.find(substring)
S.startswith(substring), S. endswith(substring)
Printing:
print var1,var2,var3 # print multiple variables
print "text",var1,"text" # print a combination of explicit text (strings) and variables
Splits the string from the specified separator and returns a list
string.split() object with string elements.
11/10/2022 CSE1001 - Problem Solving and Programmi 16
ng
Method Description
import sys
print sys.argv[1]
import sys
print sys.argv[1].replace(“T”, “U”)
import sys
print sys.argv[1].replace(“T”, “U”).replace(“t”, “u”)