How do we use double quotation in Python?


Double quotes are used to represent a string or a character as well as can be used in the print function to print the defined statement as the output. The functionality of the single quotes and double quotes is same. We can use any type quotes as per our requirement. The following is the syntax to create a string using the double quotes in the python programming language.

str = “text”

Where,

  • “ ” are the double quotations

  • text is the data to be in string format

Example

Let’s see an example to understand the functionality and usage of the double quotes in python. Initially, we have created a string by passing the sentence in the double quotes and assigned it to the variable str. Next we printed the created string by calling the string variable name st. After that, we printed the type of the string by using the type function.

str = "Double quotes in python programming"
print(str)
print(type(str))

Output

Double quotes in python programming
<class 'str'>

Example

When we pass the sentence in the double quotes to the print function then the sentence will be printed.

print("Double quotes used in print statement")

Output

The following is the output of the double quotes used in the print statement. In the output we can see the statement passed in the print within the double quotes.

Double quotes used in print statement

Example

Let’s see another example to understand the functionality and usage of the double quotes in python.

In the code, firstly we created a string with single quote combination by passing the sentence in the double quotes and assigned it to the variable st. Next we printed the created string by calling the string variable name st. After that we printed the type of the string by using the type function.

st = "Welcome to 'Python Tutorial' from TutorialsPoint"
print(st)
print(type(st))

Output

Welcome to 'Python Tutorial' from TutorialsPoint
<class 'str'>

Example

In this example when we pass a paragraph in double quotes and assigned it to the variable.

st = " Example to understand the working, and functionality of the 'double quotations' in python programming language. The following code format can \n be used for using the double quotations."
print(st)

Output

Example to understand the working, and functionality of the 'double quotations' in python programming language. The following code format can 
 be used for using the double quotations.

Updated on: 15-May-2023

439 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements