KnowledgeBoat Logo

Computer Science

What are tokens in Python ? How many types of tokens are allowed in Python ? Exemplify your answer.

Python Funda

67 Likes

Answer

The smallest individual unit in a program is known as a Token. Python has following tokens:

  1. Keywords — Examples are import, for, in, while, etc.
  2. Identifiers — Examples are MyFile, DS, DATE9777, etc.
  3. Literals — Examples are "abc", 5, 28.5, etc.
  4. Operators — Examples are +, -, >, or, etc.
  5. Punctuators — ' " # () etc.

Answered By

32 Likes


Related Questions