Python Tokens

Python Tokens are individual units in a program. The following are the types of Tokens:

  1. Keywords
  2. Identifiers
  3. Literals

Keywords

Keywords are reserved words used in programming languages. The compiler/ interpreter already knows these names, so you cannot use them as variable names.

List of Keywords in Python

Keywords in Python

Identifiers in Python

Identifiers in Python are used for naming of variables, functions and arrays. Do not use keywords as identifiers.

An identifier begins with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9). That means, it is a combination of character digits and underscore.

Python Identifiers

Literals

Literals are the values assigned to each constant variable. Python has the following literals:

  • String Literals: Enclose text in quotes. Can use both single as well as double quotes. Use triple-quotes for multi-line string.
  • Numeric Literals: Includes int, long, float and complex.
  • Boolean Literals: Can have either True or False values

Let us now see examples of Literals in Python:

String Literals in Python

The output is as follows:

Numeric Literals in Python

The output is as follows:

Boolean Literals in Python

The output is as follows:

Python Tutorial (English)

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Read More:

Python Sets With Examples
Python Comments
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading