Page 99 - 2611_SmartGPT Pro V(5.0) C-8
P. 99
STRING OPERATORS
There are two basic string operators in Python, + and *. Python uses + for concatenation and * for
replication:
String Concatenation Operator (+): String concatenation operator joins two or more strings
into one string.
Program 7: To join two or more strings using string concatenation operator
Program7.py Output
File Edit Format Run Options Window Help HereIsPython
s1 = 'Here'
s2 = 'Is'
s3 = 'Python'
s = s1 + s2 + s3
print(s)
String Replication Operator (*): The replication operator is used to repeat the string for a
given number of times.
Program 8: To repeat a string using string replication operator
Program8.py Output
File Edit Format Run Options Window Help HelloHelloHello
s1 = 'Hello'
s = s1 * 3
print(s)
PURE
There are around 700 separate programming languages. Some of the most
popular ones are JavaScript, Swift, Scala, Python, PHP, Go, Rust, Ruby and C#. FACT
STRING BUILT-IN FUNCTIONS
Python includes the following built-in functions to manipulate strings:
len(): The len() function calculates and returns the length of a string supplied as an argument.
The syntax of using the len() function is:
len(string_name)
lower(): The lower() function converts all uppercase letters to lowercase. The syntax of using
the lower() function is:
string_name.lower()
upper(): The upper() function converts all lowercase letters to uppercase. The syntax of using
the upper() function is:
string_name.upper()
Functions and String in Python 97

