Member-only story

Interview question: What are the different literals in Python?

Crystal X
3 min readFeb 27, 2023

--

Literals in Python are defined as the raw data assigned to variables or constants while programming. There are five types of literals, to include:-

  1. String literals,
  2. Numeric literals,
  3. Boolean literals,
  4. Literal collections, and
  5. 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:-

  1. Integer,
  2. Float,and
  3. Complex.

The types integer literals are: decimal, binary, octal, and hexadecimal:-

Float literals are real numbers and contain decimals within the number:-

--

--

Crystal X
Crystal X

Written by Crystal X

I have over five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.

No responses yet