- Python Code to Read two Strings & Concatenate the Strings.
- Python code implementation without user-defined functions & classes
- Python code implementation using function
- Python code implementation using Classes
</p> <h3><span class="ez-toc-section" id="Python_code_implementation_without_user-defined_functions_classes"></span><strong><span style="color:#ff0000">Python code implementation without user-defined functions & classes</span></strong><span class="ez-toc-section-end"></span></h3> <h5><span style="color:#339966"><strong>Code: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="atomic"># Python code to Read two Strings & Concatenate the Strings a = input["Enter First String: "] b = input["Enter Second String: "] c = a+b print["Concatenated String is: ",c] </pre> <h5></h5> <h5><span style="color:#339966"><strong>Executing Python Script: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="classic">python program.py Enter First String: I love Enter Second String: Python Programming </pre> <p><span id="ezoic-pub-ad-placeholder-125" class="ezoic-adpicker-ad"></span><span class="ezoic-ad ezoic-at-0 medrectangle-3 medrectangle-3125 adtester-container adtester-container-125 ezoic-ad-adaptive" data-ez-name="pythonbaba_com-medrectangle-3"><span class="ezoic-ad medrectangle-3 medrectangle-3-multi-125 adtester-container adtester-container-125" data-ez-name="pythonbaba_com-medrectangle-3"><span id="div-gpt-ad-pythonbaba_com-medrectangle-3-0" ezaw="290" ezah="250" style="position:relative;z-index:0;display:inline-block;padding:0;min-height:250px;min-width:290px" class="ezoic-ad"><script data-ezscrex="false" data-cfasync="false" type="text/javascript" style="display:none">if[typeof ez_ad_units != 'undefined']{ez_ad_units.push[[[250,250],'pythonbaba_com-medrectangle-3','ezslot_3',125,'0','0']]};__ez_fad_position['div-gpt-ad-pythonbaba_com-medrectangle-3-0'];if[typeof ez_ad_units != 'undefined']{ez_ad_units.push[[[250,250],'pythonbaba_com-medrectangle-3','ezslot_4',125,'0','1']]};__ez_fad_position['div-gpt-ad-pythonbaba_com-medrectangle-3-0_1']; </p> <h5><span style="color:#339966"><strong>Output: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="classic">Concatenated String is: I lovePython Programming </pre> <p> </p> <p> </p> <h3><span class="ez-toc-section" id="Python_code_implementation_using_function"></span><strong><span style="color:#ff0000">Python code implementation using function</span></strong><span class="ez-toc-section-end"></span></h3> <h5><span style="color:#339966"><strong>Code: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="atomic"># Python code to Read two Strings & Concatenate the Strings using Function def concatenate_string_function[a_string, b_string]: return a_string + b_string a = input["Enter First String: "] b = input["Enter Second String: "] c = concatenate_string_function[a, b] print["Concatenated String is: ",c] </pre> <p> </p> <h5><span style="color:#339966"><strong>Executing Python Script: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="classic">python program.py Enter First String: I love Enter Second String: Python Programming </pre> <p> </p> <h5><span style="color:#339966"><strong>Output: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="classic">Concatenated String is: I lovePython Programming </pre> <p> </p> <p> </p> <p> </p> <h3><span id="ezoic-pub-ad-placeholder-127" class="ezoic-adpicker-ad"></span><span class="ezoic-ad ezoic-at-0 large-leaderboard-2 large-leaderboard-2127 adtester-container adtester-container-127" data-ez-name="pythonbaba_com-large-leaderboard-2"><span id="div-gpt-ad-pythonbaba_com-large-leaderboard-2-0" ezaw="250" ezah="250" style="position:relative;z-index:0;display:inline-block;padding:0;width:100%;max-width:1200px;margin-left:auto!important;margin-right:auto!important;min-height:250px;min-width:970px" class="ezoic-ad"><script data-ezscrex="false" data-cfasync="false" type="text/javascript" style="display:none">if[typeof ez_ad_units != 'undefined']{ez_ad_units.push[[[250,250],'pythonbaba_com-large-leaderboard-2','ezslot_5',127,'0','0']]};__ez_fad_position['div-gpt-ad-pythonbaba_com-large-leaderboard-2-0'];</script></span></span><span class="ez-toc-section" id="Python_code_implementation_using_Classes"></span><strong><span style="color:#ff0000">Python code implementation using</span></strong><strong><span style="color:#ff0000"> Classes</span></strong><span class="ez-toc-section-end"></span></h3> <h5><span style="color:#339966"><strong>Code: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="atomic"># Python code to Read two Strings & Concatenate the Strings using Class class Concatenate_string_class[object]: def concatenate_string_function[self, a_string, b_string]: self.a_string = a_string self.b_string = b_string return self.a_string + self.b_string a = input["Enter First String: "] b = input["Enter Second String: "] #Create the Object Object_1 = Concatenate_string_class[] #Call the function using created Object c = Object_1.concatenate_string_function[a, b] print["Concatenated String is: ",c] </pre> <h5></h5> <h5><span style="color:#339966"><strong>Executing Python Script: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="classic">python program.py Enter First String: I love Enter Second String: Python Programming </pre> <p> </p> <h5><span style="color:#339966"><strong>Output: </strong></span></h5> <pre class="EnlighterJSRAW" data-enlighter-theme="classic">Concatenated String is: I lovePython Programming </pre> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p><strong>Enjoy Python Code By Pythonbaba 🙂</strong></p> <p> </p> <div class="fb-comments" data-href="//developers.facebook.com/docs/plugins/comments#configurator" data-width="" data-numposts="5"></div> <div class="saboxplugin-wrap" itemtype="//schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img srx="//pythonbaba.com/wp-content/uploads/2019/10/Pythonbaba-logo.png" width="100" height="100" alt="Learn Python Programming at PythonBaba.com" itemprop="image" src="//pythonbaba.com/wp-content/uploads/2019/10/Pythonbaba-logo.png" class="lazyload"><noscript><img srx="//pythonbaba.com/wp-content/uploads/2019/10/Pythonbaba-logo.png" width="100" height="100" alt="Learn Python Programming at PythonBaba.com" itemprop="image"></noscript></div><div class="saboxplugin-authorname"><a target="_blank" href="//pythonbaba.com/author/pythonbaba/" class="vcard author" rel="author" itemprop="url"><span class="fn" itemprop="name">PythonBaba</span></a></div><div class="saboxplugin-desc"><div itemprop="description"><p>Our team loves to write in Python, Linux, Bash, HTML, CSS Grid, CSS Flex, and Javascript. We love to write technical articles.</p> <p>Currently exploring Data Science, Machine learning and Artificial intelligence.</p> </div></div><div class="clearfix"></div></div></div> <div class="td-g-rec td-g-rec-id-content_bottom tdi_5 td_block_template_1"> <style> /* custom css */ .tdi_5.td-a-rec{ text-align: center; }.tdi_5 .td-element-style{ z-index: -1; }.tdi_5.td-a-rec-img{ text-align: left; }.tdi_5.td-a-rec-img img{ margin: 0 auto 0 0; } @media [max-width: 767px] { .tdi_5.td-a-rec-img { text-align: center; } }