Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Python string Handling with example

Posted on June 8, 2017September 15, 2019

Python string handling with example

In this tutorial , we will discuss the python string handling with example.

A string is a set of characters inorder. E.g.  a letter, number and symbol may become a character.

We can print a string many way using single quote , double quote and triple quote in python.

1. print(‘hello’)        //print using with single quote

2. print(“hello”)      // print using with double quotes

3. print(”’hello”’)     //print using with triple- single  quotes

4. print(“””hello”””) // print using with triple – double quotes

Output here

Python string Handling with example
Example

We can print a string using single quote with variable.

5. first_string=’hello’          // assign a string to variable using single quote
print(first_string)           // print string with variable

We can print a string using double quote with variable.

6. second_string=”hello”   // assign a string to variable using double quote
print(second_string)       // print string with variable

We can print a string using triple – single quote with variable

7. third_string=”’hello”’      // assing a string to variable using triple – single quote
print(third_string)          // print string with variable

We can print a string using triple – double quote with variable

8. forth_string=”””hello”””    // assing a string to variable using triple – double quote
print(forth_string)              // print string with variable

Output here
 
Python string Handling with example
Example

Table of Contents

  • We can use the triple quote to print multiple line string
  • Code

We can use the triple quote to print multiple line string

1. using triple – single quote to print multiple line string

multiple_line_string=”’hello
how
are
you”’      // assing a string to variable using triple – single quote
print(multiple_line_string)          // print string with variable

2. using triple – single quote to print multiple line string

multiple_line_string=”””hello
how
are
you”””   // assing a string to variable using triple – single quote
print(multiple_line_string)          // print string with variable

 

Code

Python string Handling with example
Example
Output
 
 
 
 
Concatination of String
We can join two or more string in python, Known as concatination in python.
The plus operator (+) uses this operation for string
String concatination in python shell
Using + operator
Python string Handling with example
Example
Concatination with two or more string using variable
Python string Handling with example
Example
 
String concatination in python shell
Using single or double quotes
We can use single or double quotes to concatinate two or more string
Python string Handling with example
Example
Multiplication of String
Multiplication of one string is called multiplication of string in python.
The multiply operator (*) uses this operation in string
Python string Handling with example
Example
 

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes