in Python by
What are Literals in Python and explain about different Literals?

1 Answer

0 votes

Literals in Python refer to the data that is given in a variable or constant. Python has various kinds of literals including:

  1. String Literals: It is a sequence of characters enclosed in codes. There can be single, double and triple strings based on the number of quotes used. Character literals are single characters surrounded by single or double-quotes. 
  2. Numeric Literals: These are unchangeable kind and belong to three different types – integer, float and complex.
  3. Boolean Literals: They can have either of the two values- True or False which represents ‘1’ and ‘0’ respectively. 
  4. Special Literals: Special literals are sued to classify fields that are not created. It is represented by the value ‘none’.