Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python tokens

"""
Tokens: Python breaks each logical line into a sequence of elementary
lexical components known as tokens. Each token corresponds to a substring
of the logical line. The normal token types are identifiers, keywords,
operators, delimiters, and literals, as covered in the following sections.

Keywords: Keywords are words that have some special meaning or significance
in a programming language. In Python we have 33 keywords some of them are:
try, False, True, class, break, continue, and, as, assert, while, for, in, raise,
except, or, not, if, elif, print, import, etc.

Identifiers: Identifiers are the names given to any variable, function,
class, list, methods, etc. for their identification.
Python is a case-sensitive language and it has some rules and regulations
to name an identifier.

Literals or Values: Literals are the fixed values or data items used in a
source code. Python supports different types of literals such as:
    
    String Literals.
    
    Character Literals: Character literal is also a string literal type in which
    the character is enclosed in single or double-quotes.
    
    Numeric Literals: Integer Literal, Float Literal and Complex Literal
    
    Boolean Literals: Boolean literals have only two values in Python. These are True and False.
    
    Special Literals: Python has a special literal ‘None’. It is used to denote nothing, no values,
    or the absence of value.
    
    Special Literals: Python has a special literal ‘None’. It is used to denote
    nothing, no values, or the absence of value.
    
    Literals Collections: Literals collections in python includes list, tuple, dictionary, and sets.
      
Operators: These are the tokens responsible to perform an operation in an
expression.
"""
# Operators
a = 12
 
 # Unary operator
b = ~ a
 
# Binary operator
c = a+b  
 
# Driver code
print(b)
print(c)

# Output
# -13
# -1
"""
Punctuators: These are the symbols that used in Python to organize the
structures, statements, and expressions. Some of the Punctuators are:
[ ] { } ( ) @  -=  +=  *=  //=  **==  = , etc.
"""
 
PREVIOUS NEXT
Tagged: #python #tokens
ADD COMMENT
Topic
Name
1+4 =