Member-only story
Interview question: What are the different literals in Python?
Literals in Python are defined as the raw data assigned to variables or constants while programming. There are five types of literals, to include:-
- String literals,
- Numeric literals,
- Boolean literals,
- Literal collections, and
- Special literals.
String literals
String literals are pieces of text enclosed in single, double, or triple quotes.
Numeric literals
Numeric literals contain digits only and are immutable.The types of numeric literals are:-
- Integer,
- Float,and
- Complex.
The types integer literals are: decimal, binary, octal, and hexadecimal:-
Float literals are real numbers and contain decimals within the number:-