Concatenate two strings using Python. This program uses strings initialisation, concatenation and print function. This program is for mid level python programmers.
Concatenate two strings
String are array of bytes representing Unicode characters. Python doesn’t have a character data type. All the character are string of one length 1.
To concatenate two strings or concatenate two array of length we have to do as per this example. first enter the first string and then second string then put + sign between them. Then they are concatenated means joined. Their length become the sum of their individual strings. Example-
first string : archit
second string : is a good programmer
fist string + second string # where this + is used as concatenated operator.
then the output after the concatenated operator is : archit is a good programmer
Source code: Program to Concatenate two strings using Python
# Defining strings
string1 = "Archit "
string2 = "is a good boy"
# + Operator is used to strings concatenation
string3 = string1 + string2
print(string3) # Printing the new combined string
Source Code Explanation: Program to Concatenate two strings using Python
step1:Python program to show string concatenation
step 2:Defining strings
string1 = “Archit “
string2 = “is a good boy”
step 3:+ Operator is used to strings concatenation
string3 = string1 + string2
print(string3) step 4: Printing the new combined string
Output :
RESTART: C:/csstudy/source code file 2/Concatenate two strings using Python.py Archit is a good boy >>>
Output Explanation :
RESTART: C:/csstudy/source code file 2/Concatenate two strings using Python.py
Archit is a good boy
>>>
Strings was initialized in the program with string 1 equal to Archit and string 2 equal to is a good boy and then the string is concatenated with operator + to Archit is a good boy.
Conclusion:
The Program is running fine.
Thank you for reading, learning and copying the Program to Concatenate two strings using Python. This program uses strings initialisation, concatenation and print function. This program is for mid level python programmers. For more programs and python project click below :
/category/python-programs/
Python Projects for Class 12 with Source Code (Mysql Connectivity) – CS Study