Tokens are the smallest unit of program. There are following tokens in Python:

  • Reserved words
  • Identifiers
  • Literals
  • Operators

Reserved Words 
Reserved Words are also known as keywords which express a special meaning to the compiler and interpreter. Keywords in python are –

return or None and not
asset def class continue break
from finally elif del except
global for if else import
raise try True False pass
nonlocal in as is lambda

An identifier is a sequence of numbers and characters. These are the names given to the basic building blocks in a program. These can be class, variables, functions, object, lists, dictionaries etc.
Rules for defining identifiers are –

  • First character of an identifier can be character, underscore ( _ ) but not digit.
  • No special character except underscore ( _ ) can be used as an identifier.
  • Reserve words cannot be used as an identifier name.
  • Python is a case sensitive language so ‘a’ and ‘A’ are different identifiers.

Learn Java

Literals can be defined as a data that is given in a variable or constant. Python have following literals:-

  • String Literals
  • Numeric Literals
  • Floating Literals
  • Boolean Literals
  • Collection literals

A variable is a memory address that can change and when memory address cannot change then it is known as constant. Variable is a name of the memory location where data is stored. Once a variable is stored then space is allocated in memory. It defines a variable using a combination of numbers, letters and the underscore character.
There are a few rules: a variable must begin with a letter or an underscore, and the variable name is case sensitive.
Assigning Values to Variables
There is no need for explicit declaration to reserve memory. The assignment is done using the equal (=) operator. Some example of legal python variables are –

i = 1
i_j = 2


>>> a = 1
print a

Multiple Assignment:
You can assign a single value to the multiple variables as follows –

a = b = c = 20

Where a, b, c are the variable.
Also you can assign multiple values to the multiple variables as follows –

a = b = c = 20, 25, 30
print a
print b
print c

Learn more about PYTHON TOOLKIT in this insightful blog now!

Recommended Videos

Course Schedule

Name Date
Python Course 2021-01-23 2021-01-24
(Sat-Sun) Weekend batch
View Details
Python Course 2021-01-30 2021-01-31
(Sat-Sun) Weekend batch
View Details
Python Course 2021-02-06 2021-02-07
(Sat-Sun) Weekend batch
View Details

Leave a Reply

Your email address will not be published. Required fields are marked *