- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
What are different types of quotes in Python?
There are different types of quotes in python. Each quotation is used in different scenarios as per the requirement. The following are the different types of quotations which we can use in the python programming language.
What are Single quotes?
Single quotes (' ') are used to create strings and characters in Python programming. Since the print() function accepts string values we can directly pass values to it wrapping them within the single quotes.
In this example, we will create a string using the single quotes and assign it to the variable before printing the output.
s = 'Welcome to Tutorialspoint' print(s) print(type(s))
Welcome to Tutorialspoint <class 'str'>
In here, we are directly passing the string value to the print() function −
print('Python Programming Language')
Python Programming Language
What are Double quotes?
We can also use the Double quotes (" ") to create strings and characters. The functionality of single (') and double (") quotes is the same; you can use either one depending on your requirements.
In this example, we are creating a string value using the double quotes.
st = "Double quotes in python programming" print(st) print(type(st))
Double quotes in python programming <class 'str'>
If we want to print a statement, we can also directly pass the desired text, placing it with in double quotes, to the print() function.
print("Double quotes used in print statement")
Double quotes used in print statement
What are Triple quotes?
The Triple quotes are used for commenting and representing the docString in the python.
In a part of the code, if we want to use the sentences which are not part of code lines, then we will pass those sentences in the triple quotes. The following is the code.
string = "Hello world" '''The triple quotes are mainly used for commenting the lines in python programming language''' print(string)
The following is the output of the triple quotes used for commenting the lines. In the output we can see that the lines given in the triple quotes are not displayed in the output.
Instead of the triple quotes we can also use the triple double quotes for commenting the lines in the code.
s = "Hello world" """The triple quotes are mainly used for commenting the lines in python programming language""" print(s)
- Related Articles
- What are different types of quotes in Python?
- What are different Identity operators types in Python?
- What are different assignment operators types in Python?
- What are different bitwise operators types in Python?
- What are the different built-in types in Python?
- What are different types of interrupts?
- What are Different Types of Testing?
- What are different types of Respiration?
- What are different types of plant?
- What are Different Types of Mutagenesis?
- What are the different types of Python data analysis libraries used?
- What are different types of constants in C++?
- What are different types of eating disorders?
- What are the different types of psychotherapy?
- What are different types of finite automata?
- What are the different types of DBMS?