Learning Python Part-11: Python Literals

Literal in Python, is a raw data that is passed on to a variable or constant as values. 

In Python programming language, there are various types of literals as listed below:

  • Numeric Literals:
    • Numeric Literals are immutable (unchangeable). 
    • Numeric literals can belong to different numerical types like Integer, Float, and Complex.
    • Examples:

  • String literals:
    • A string literal is a sequence of characters surrounded by quotes.
    • String literals are immutable (unchangeable).
    • We can use both single, double or triple quotes for a string. 
    • A character literal is a single character surrounded by single or double quotes.
    • Examples:

  • Boolean literals:
    • A Boolean literal can have any of the two values: True or False
    • Examples:

  • Special literals:
    • Python contains one special literal i.e. None. 
    • We use it to specify to that field that is not created.
    • Examples:

  • Literal Collections:
    • There are four different literal collections List literals, Tuple literals, Dictliterals, and Set literals.
    • Examples:
I will talk about each of these literals with more details in upcoming posts. 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.