Computer Science
What are tokens in Python ? How many types of tokens are allowed in Python ? Exemplify your answer.
Answer
The smallest individual unit in a program is known as a Token. Python has following tokens:
- Keywords — Examples are import, for, in, while, etc.
- Identifiers — Examples are MyFile, DS, DATE9777, etc.
- Literals — Examples are "abc", 5, 28.5, etc.
- Operators — Examples are +, -, >, or, etc.
- Punctuators — ' " # () etc.
Related Questions
How are floating constants represented in Python ? Give examples to support your answer.
How are keywords different from identifiers ?
What are literals in Python ? How many types of literals are allowed in Python ?
Can nongraphic characters be used in Python ? How ? Give examples to support your answer.