Components of Python Language

  • A Components of Python Language ​ is the smallest element in a program that is meaningful to the computer.
  • These Components of Python Language define the structure of the language.
  • It is also known as a token of python language.
The five main components (tokens) of 'Python' language are:
  • The character set
  • The Data types
  • Constants
  • Variables
  • Keywords

The character set

  • Any alphabet, digits, or special symbol used to represent information is denoted by character.
  • The characters in Pythons are grouped into four categories.
1 Letters A – – – Z or a – z
2 Digits 0,1,—-9
3 Special Symbols -.‟@#%'” &*() _-+ = I\{}[]:;”‘< > , . ? /.
4 White spaces blank space, horizontal tab, carriage return, new line, and form feed.

The Data types

  • The power of a programming language depends, among other things, on the range of different types of data it can handle.
  • Data values passed in a program may be of different types.

Note: Each data type will be learned in each different chapter.

Find the Data Type

 type() function: using this function get the data type of any object or variable.

Example
y = 15
print(type(y))

Constants

  • Constants are the fixed values that remain unchanged during the execution of a program and are used in assignment statements.

Variables

  • Variables are the data items whose values may vary during the execution of the program.
Note: Python has no command for declaring a variable.
Rules to defines Variable Names
  • A variable can have a short name (like x and y) or a more descriptive name (age, surname, total_volume). Rules for Python variables:
  • A variable name must start with a letter or the underscore character
  • A variable name cannot start with a number
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case-sensitive (ram, Ram, and RAM are three different variables)
Example to create variable in python
a = "NIELITBHU"
a_var = "NIELITBHU"
_a_var = "NIELITBHU"
aVar = "NIELITBHU"
aVAR = "NIELITBHU"
avar2 = "NIELITBHU"

Keywords

  • Keywords are the words that have been assigned specific meaning in the context of python language programs.
  • Keywords should not be used as variable names to avoid problems.
  • There are 33 keywords are found in the python programming language.

and

continue

for

lambda

try

as

def

from

nonlocal

while

assert

del

global

not

with

async

elif

if

or

yield

False

await

else

import

pass

None

break

except

in

raise

True

class

finally

is

return

English Hindi